Example usage for org.eclipse.jface.dialogs DialogSettings DialogSettings

List of usage examples for org.eclipse.jface.dialogs DialogSettings DialogSettings

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs DialogSettings DialogSettings.

Prototype

public DialogSettings(String sectionName) 

Source Link

Document

Create an empty dialog settings which loads and saves its content to a file.

Usage

From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.wizards.NewFXGraphWizard.java

License:Open Source License

public NewFXGraphWizard() {
    if (getDialogSettings() == null) {
        DialogSettings settings = new DialogSettings("new-fxgraph");
        try {//from   ww w  .  ja va 2 s .  c  o m
            settings.load(SETTINGS_FILE);
        } catch (IOException e) {
        }
        setDialogSettings(settings);
    }
}

From source file:at.bestsolution.efxclipse.tooling.fxml.wizards.NewFXMLWizard.java

License:Open Source License

public NewFXMLWizard() {
    if (getDialogSettings() == null) {
        DialogSettings settings = new DialogSettings("new-fxml");
        try {/*from  w ww .  j  a v  a2s. com*/
            settings.load(SETTINGS_FILE);
        } catch (IOException e) {
        }
        setDialogSettings(settings);
    }
}

From source file:at.kolli.automation.client.LayoutLoader.java

License:Open Source License

/**
 * run routine to load files from server
 * and generate layout files/*from  w  ww  . j a  va 2s  . c  o  m*/
 * 
 * @serial
 * @see
 * @override
 * @author Alexander Kolli
 * @version 1.00.00, 23.12.2007
 * @since JDK 1.6
 */
public void run() {
    Boolean bConnected = false;
    short type = 0;
    String user = "";
    String pwd = "";
    String olduser, oldpwd;
    String error = "";
    HashMap<String, Date> folder = new HashMap<String, Date>();
    DialogThread dialog = DialogThread.instance();
    MsgTranslator trans = MsgTranslator.instance();
    MsgClientConnector client;
    String loginname;
    IDialogSettings login = TreeNodes.m_Settings.getSection("loginDialog");

    setName("LayoutLoader");
    client = MsgClientConnector.instance(m_sHost, m_nPort);
    while (!stopping()) {
        try {
            while (getType() == WAIT) {
                stateLock.lock();
                try {
                    // wait until no new content should be loading
                    newStateCondition.await();
                } catch (InterruptedException ex) {
                    System.out.println(
                            "newStateCodition get's InterruptedException, so wait for 100 milliseconds");
                    try {
                        sleep(100);
                    } catch (InterruptedException iex) {
                        System.out.println("cannot sleep 10 milliseconds for wating on LayoutLoader-thread");
                        iex.printStackTrace();
                    }
                } finally {
                    stateLock.unlock();
                }
                if (stopping())
                    return;
            }
            while (!dialog.isOpen() && getType() != WAIT) {
                try {
                    sleep(100);
                } catch (InterruptedException ex) {

                }
                if (stopping())
                    return;
            }
            MsgTranslator.instance().clearErrorPool();
            type = getType();
            if (type == DISPOSE) {
                dialog.setSelection(0);
                dialog.setSteps(1);
                if (HtmTags.showDisposeClient) {
                    if (m_aTreeNodes != null && !m_aTreeNodes.isEmpty()) {
                        TreeNodes.m_nNodeCount = 0;
                        for (TreeNodes node : m_aTreeNodes)
                            TreeNodes.m_nNodeCount += node.count();
                        dialog.setSteps(TreeNodes.m_nNodeCount + 1);
                        for (TreeNodes node : m_aTreeNodes)
                            node.dispose(/*subnodes*/true);
                    }
                }
                dialog.show(trans.translate("closeConnections"));
                //client.closeConnection();
                dialog.nextStep();
                dialog.close();
                return;
            }
            if (type == WAIT)
                continue;
            bConnected = false;
            olduser = user = TreeNodes.m_sUser;
            oldpwd = pwd = TreeNodes.m_sPwd;
            if (type != REFRESH && type != BROKEN && login != null) {
                loginname = null;
                if (type == LayoutLoader.UPDATE)
                    loginname = login.get("lastchangename");
                if (loginname == null)
                    loginname = login.get("lastloginname");
                user = loginname;
            }
            while (!bConnected) {
                if (type == CREATE || type == UPDATE) {
                    if (dialog.verifyUser(user, pwd, error).equals(states.CANCEL))
                        break;
                    user = TreeNodes.m_sUser;
                }
                dialog.needProgressBar();
                dialog.show(trans.translate("dialogConnectionTitle"),
                        trans.translate("dialogConnectionSearchMsg"));

                if (type != REFRESH) {
                    if (type == CREATE || type == BROKEN) {
                        client.openNewConnection(TreeNodes.m_sUser, TreeNodes.m_sPwd);
                    } else
                        client.changeUser(TreeNodes.m_sUser, TreeNodes.m_sPwd, /*bthrow*/true);
                    if (!dialog.isOpen())
                        stopThread();
                    if (stopping())
                        break;
                    type = getType();
                    if (client.hasError()) {
                        Toolkit oKit = Toolkit.getDefaultToolkit();

                        oKit.beep();
                        error = client.getErrorCode();
                        dialog.show(client.getErrorMessage());
                        client.closeConnection();

                    } else
                        bConnected = true;
                } else
                    bConnected = true;
            }

            if (dialog.dialogState().equals(states.RUN)) {
                user = TreeNodes.m_sUser;
                if (login == null) {
                    login = new DialogSettings("loginDialog");
                    login.put("lastloginname", user);
                    login.put("loginnames", user);
                    TreeNodes.m_Settings.addSection(login);
                } else {
                    Boolean exists = false;
                    String names = login.get("loginnames");
                    String[] snames = names.split(":");

                    for (String name : snames) {
                        if (name.equals(user)) {
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                        login.put("loginnames", names + ":" + user);
                    if (type == CREATE)
                        login.put("lastloginname", user);
                    else if (type == UPDATE)
                        login.put("lastchangename", user);
                }

                folder = client.getDirectory("." + TreeNodes.m_sLayoutStyle, /*bthrow*/true);
                if (!client.hasError()) {
                    if (HtmTags.debug) {
                        ArrayList<String> folderKeys = new ArrayList<String>(folder.keySet());

                        Collections.sort(folderKeys);
                        System.out.println("found follow Files on server:");
                        for (String str : folderKeys)
                            System.out.println(str);
                    }
                } else {
                    System.out.println(client.getErrorMessage());
                    return;
                }

                TreeNodes.m_hmDirectory = folder;
                dialog.show(trans.translate("dialogLoadContent"));
                initializeMainWidget(TreeNodes.m_hmDirectory);
                if (dialog.dialogState().equals(DialogThread.states.CANCEL))
                    return;
                if (dialog.dialogState().equals(states.RUN)) {
                    //System.out.println("Close Dialog Box");
                    dialog.close();
                } else
                    // change user back;
                    client.changeUser(olduser, oldpwd, /*bthrow*/true);
            }
            /**
             * create all not currently visible sides
             * in background with lower or higher priority
             */
            if (HtmTags.useBackgroundLoadingPriority > 0) {
                Thread.currentThread().setPriority(HtmTags.useBackgroundLoadingPriority);
                if (createSidesOnBackground()) {
                    setState(WAIT);
                    type = WAIT;
                }
                Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
                if (HtmTags.debug)
                    System.out.println("reading of sides on background was finished");
            }
            setState(WAIT);

        } catch (IOException ex) {
            if (HtmTags.debug) {
                System.out.println("-----------------------------------------------");
                System.out.println(client.getErrorMessage());
                ex.printStackTrace();
                System.out.println("-----------------------------------------------");
            }
            client.closeConnection();
            setState(BROKEN);
            type = WAIT;
        }
    }
    if (HtmTags.debug)
        System.out.println("Ending of thread '" + getName() + "'");
}

From source file:at.kolli.automation.client.LayoutLoader.java

License:Open Source License

protected void execInitialize() {
    String check;//from w ww  .j  a v a 2 s  .com
    Menu menuBar;
    MsgTranslator trans = MsgTranslator.instance();
    FillLayout mainLayout = new FillLayout();
    FillLayout treeLayout = new FillLayout();

    IDialogSettings login;
    //final Composite mainComposite;
    final Group treeComposite;
    int sashWeight[] = { 200, 800 };
    Rectangle monitor;
    int xLocation;
    int yLocation;

    // create menu
    if (HtmTags.nomenu)
    //&&
    //!HtmTags.notree   )
    {
        menuBar = null;
    } else {
        menuBar = new Menu(m_oTopLevelShell, SWT.BAR);
        m_oTopLevelShell.setMenuBar(menuBar);
    }
    if (!HtmTags.nomenu) {
        MenuItem menuTitle = new MenuItem(menuBar, SWT.CASCADE);
        Menu menuList1 = new Menu(m_oTopLevelShell, SWT.DROP_DOWN);
        MenuItem refreshItem = new MenuItem(menuList1, SWT.NULL);
        MenuItem changeUserItem = new MenuItem(menuList1, SWT.NULL);
        new MenuItem(menuList1, SWT.SEPARATOR);
        MenuItem exitItem = new MenuItem(menuList1, SWT.NULL);

        menuTitle.setText(trans.translate("menu_top_app"));
        // first menu list
        menuTitle.setMenu(menuList1);
        refreshItem.setText(trans.translate("menu_app_refresh"));
        changeUserItem.setText(trans.translate("menu_app_changeUser"));
        exitItem.setText(trans.translate("menu_app_exit"));

        // event-handling for MenuItem's
        refreshItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                LayoutLoader loader = LayoutLoader.instance();
                DialogThread dialog = DialogThread.instance(m_oTopLevelShell);
                MsgTranslator trans = MsgTranslator.instance();

                super.widgetSelected(e);
                synchronized (TreeNodes.m_DISPLAYLOCK) {
                    loader.setState(LayoutLoader.REFRESH);
                    dialog.needProgressBar();
                    dialog.needUserVerificationFields();
                    dialog.show(trans.translate("dialogChangeUser"), trans.translate("dialogUserVerification"));
                    dialog.produceDialog(REFRESH);
                    loader.setState(LayoutLoader.WAIT);
                }
            }

        });
        changeUserItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                LayoutLoader loader = LayoutLoader.instance();
                DialogThread dialog = DialogThread.instance(m_oTopLevelShell);
                MsgTranslator trans = MsgTranslator.instance();

                super.widgetSelected(e);
                synchronized (TreeNodes.m_DISPLAYLOCK) {
                    loader.setState(LayoutLoader.UPDATE);
                    dialog.needProgressBar();
                    dialog.needUserVerificationFields();
                    dialog.show(trans.translate("dialogChangeUser"), trans.translate("dialogUserVerification"));
                    dialog.produceDialog(UPDATE);
                }
                if (HtmTags.debug)
                    System.out.println("change user to '" + TreeNodes.m_sUser + "'");
            }

        });
        exitItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {

                LayoutLoader loader = LayoutLoader.instance();

                super.widgetSelected(e);
                m_oTopLevelShell.close();
            }

        });
    }

    // create composites to display
    login = TreeNodes.m_Settings.getSection(TreeNodes.m_sLayoutStyle);
    if (login == null) {
        login = new DialogSettings(TreeNodes.m_sLayoutStyle);
        TreeNodes.m_Settings.addSection(login);
    }
    monitor = Display.getDefault().getPrimaryMonitor().getBounds();
    if (HtmTags.fullscreen) {
        m_nWidth = monitor.width;
        m_nHeight = monitor.height;
    } else {
        check = login.get("xLocation");
        if (check != null) {
            xLocation = login.getInt("xLocation");
            yLocation = login.getInt("yLocation");
            m_nWidth = login.getInt("mainwidth");
            m_nHeight = login.getInt("mainheight");
        } else {
            m_nWidth = 0;
            m_nHeight = 0;
            xLocation = monitor.width / 2;
            yLocation = monitor.height / 2;
            monitor = m_oTopLevelShell.getBounds();
            xLocation -= (monitor.width / 2);
            yLocation -= (monitor.height / 2);
        }
        m_oTopLevelShell.setLocation(xLocation, yLocation);
    }

    mainComposite = new Composite(m_oTopLevelShell, SWT.NONE);
    mainComposite.setBackground(HtmTags.systemColor);
    if (HtmTags.notree) {
        FillLayout fill = new FillLayout();
        RowLayout popupLayout = new RowLayout();

        m_shellForm = new SashForm(mainComposite, SWT.VERTICAL);
        m_oPopupIn = new Composite(m_shellForm, SWT.NONE);
        m_oPopupComposite = new Composite(m_oPopupIn, SWT.NONE);
        m_oMainComposite = new Composite(m_shellForm, SWT.NONE);

        m_shellForm.setBackground(HtmTags.systemColor);
        m_oPopupIn.setBackground(HtmTags.systemColor);
        m_oPopupComposite.setBackground(HtmTags.systemColor);
        m_oMainComposite.setBackground(HtmTags.systemColor);
        fill.marginHeight = 0;
        fill.marginWidth = 0;
        popupLayout.marginHeight = HtmTags.popupPadding;
        popupLayout.marginWidth = HtmTags.popupPadding;
        popupLayout.marginBottom = 0;
        popupLayout.marginTop = 0;
        popupLayout.marginLeft = 0;
        popupLayout.marginRight = 0;
        mainComposite.setLayout(mainLayout);
        m_oPopupIn.setLayout(fill);
        m_oPopupComposite.setLayout(popupLayout);
        treeComposite = null;
        m_oTree = null;

    } else {
        m_shellForm = new SashForm(mainComposite, SWT.HORIZONTAL);
        treeComposite = new Group(m_shellForm, SWT.SHADOW_ETCHED_IN);
        m_oMainComposite = new Composite(m_shellForm, SWT.NONE);
        m_oTree = new Tree(treeComposite, SWT.SINGLE);

        treeComposite.setBackground(HtmTags.systemColor);
        m_oMainComposite.setBackground(HtmTags.systemColor);
        mainLayout.marginHeight = 0;
        mainLayout.marginWidth = 0;
        mainComposite.setLayout(mainLayout);

        check = login.get("sashwidth");
        if (check != null) {
            sashWeight[0] = login.getInt("sashwidth");
            sashWeight[1] = login.getInt("sashheight");
        }
        m_shellForm.setWeights(sashWeight);
        m_shellForm.setLayout(new FillLayout());
    }

    if (!HtmTags.notree) {
        treeLayout.marginWidth = 1;
        treeLayout.marginHeight = 1;
        treeComposite.setLayout(treeLayout);
        treeComposite.setVisible(true);
    }

    m_StackLayout.marginHeight = HtmTags.mainPadding;
    m_StackLayout.marginWidth = HtmTags.mainPadding;
    m_oMainComposite.setLayout(m_StackLayout);

    m_oTopLevelShell.setLayout(new FillLayout());
    m_oTopLevelShell.setText("ppi-client  (physical port interface client)");

    if (!HtmTags.notree) {// add listeners for tree

        m_oTree.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                synchronized (TreeNodes.m_DISPLAYLOCK) {
                    ArrayList<TreeNodes> searchNodes;
                    ArrayList<TreeItem> itemTree = new ArrayList<TreeItem>();
                    TreeItem existItems[] = m_oTree.getItems();
                    TreeItem items[] = m_oTree.getSelection();
                    TreeItem curItem = null;
                    int pos, count;
                    String name = "";

                    if (items.length > 0)
                        curItem = items[0];
                    else
                        return;
                    while (curItem != null) {
                        itemTree.add(0, curItem);
                        curItem = curItem.getParentItem();

                    }
                    searchNodes = m_aTreeNodes;
                    do {
                        curItem = itemTree.get(0);
                        itemTree.remove(0);
                        pos = 0;
                        for (TreeItem s : existItems) {
                            if (s == curItem) {
                                existItems = s.getItems();
                                break;
                            }
                            ++pos;
                        }
                        count = -1;
                        for (TreeNodes node : searchNodes) {
                            if (node.treeDisplay())
                                ++count;
                            if (count == pos) {
                                name += "/" + node.getName();
                                searchNodes = node.getChilds();
                                break;
                            }
                        }
                    } while (itemTree.size() > 0 && searchNodes != null);
                    if (name.length() > 1)
                        name = name.substring(1);
                    if (HtmTags.debug)
                        System.out.println("Treenode " + name + " is selected");
                    m_sAktFolder = name;
                    setCurrentSideVisible(/*inform server by no body*/true);
                }
            }
        });

        if (HtmTags.debug) {
            m_oTree.addTreeListener(new TreeAdapter() {
                public void treeCollapsed(TreeEvent e) {
                    if (HtmTags.debug)
                        System.out.println("collapsed node: " + ((TreeItem) e.item).getText());
                }

                public void treeExpanded(TreeEvent e) {
                    if (HtmTags.debug)
                        System.out.println("expanded node: " + ((TreeItem) e.item).getText());
                }
            });
        }
    }
}

From source file:at.kolli.automation.client.PortServerClient.java

License:Open Source License

/**
 * main method of public PortServerClient to start application
 * //ww  w .ja  v  a  2s  . co  m
 * @param args arguments from starting shell
 * @author Alexander Kolli
 * @version 1.00.00, 02.12.2007
 * @since JDK 1.6
 */
public static void main(String[] args) {
    boolean error = false;
    boolean shellpwd = false;
    LinkedList<String> param = new LinkedList<String>();
    String host;
    String inifile = "client.ini";
    String informServerLeafPage;
    int port = 20004, nPadding, nPopup;
    String lang, maincolor, mainpadding, popuppadding, mousepos, mouseDelay;
    String backgroundLoading;

    HtmTags.debug = false;
    TreeNodes.m_sLayoutStyle = "desktop";
    for (String arg : args) {
        if (arg.substring(0, 2).equals("--")) {
            if (arg.equals("--develop")) {
                HtmTags.showFalse = true;

            } else if (arg.equals("--sync")) {
                HtmTags.syncSWTExec = true;

            } else if (arg.equals("--lock")) {
                HtmTags.lockDebug = true;

            } else if (arg.equals("--dispatch")) {
                HtmTags.dispatchShell = true;

            } else if (arg.equals("--tablestructure")) {
                param.addLast("tablestructure");

            } else if (arg.equals("--colors")) {
                DetectSystemSettingChange.display();
                System.exit(0);

            } else {
                System.out.println("undefined option '" + arg + "'");
                error = true;
            }
        } else if (arg.substring(0, 1).equals("-")) {
            for (int c = 1; c < arg.length(); ++c) {
                String s = arg.substring(c, c + 1);

                if (s.equals("?")) {
                    System.out.println();
                    System.out.println("syntax java -jar ppi-client [options]");
                    System.out.println();
                    System.out.println("       options:");
                    System.out.println("           -?             -  show this help");
                    System.out.println("           -f             -  full screen for main window");
                    System.out.println(
                            "           -m             -  show no normaly menu in menubar (refresh/change user/exit)");
                    System.out.println(
                            "           -t             -  displays no tree for sides, but in the menu-bar");
                    System.out.println("           -w             -  main window without title-bar");
                    System.out.println(
                            "           -d             -  show debug information and content of layout files");
                    System.out.println(
                            "           -u <user>      -  starting binding to server with the given user name");
                    System.out.println(
                            "           -p             -  password will be asking after command on shell");
                    System.out.println(
                            "           -s <style>     -  fetch all layout files from server with this extension");
                    System.out.println("                             default is \"desktop\"");
                    System.out.println(
                            "           -i <ini-file>  -  define new ini-file (default: 'client.ini')");
                    System.out.println(
                            "           --develop      -  show also pages from server which are defined");
                    System.out.println("                             with meta tag display as false or notree");
                    System.out.println("           --tablestructure <color>");
                    System.out.println("                          -  show table structure in defined color.");
                    System.out.println(
                            "                             Some operating systems, like KDE4, do not show shadows when");
                    System.out.println(
                            "                             an table defined with border=\"1\". For this case,");
                    System.out.println(
                            "                             this should be an workaround for developing of layout");
                    System.out.println();
                    System.out.println("       example:");
                    System.out.println("          java -jar ppi-client -fmtwups <user> touchscreen");
                    System.out.println(
                            "                     displays the main window as full screen with no tree and title");
                    System.out.println(
                            "                     Fetch all layout files with extension touchscreen and start the client");
                    System.out.println(
                            "                     with an user and the password will be asked on command line.");
                    System.out.println(
                            "                     and also in the server client folder the touchscreen layout files are given.");
                    System.out.println();
                    System.out.println(
                            "            also the same command would be -fmtw -u <user> -p -s touchscreen");
                    System.exit(0);

                } else if (s.equals("d"))
                    HtmTags.debug = true;
                else if (s.equals("f"))
                    HtmTags.fullscreen = true;
                else if (s.equals("m"))
                    HtmTags.nomenu = true;
                else if (s.equals("t"))
                    HtmTags.notree = true;
                else if (s.equals("w"))
                    HtmTags.notitle = true;
                else if (s.equals("u"))
                    param.addLast("u");
                else if (s.equals("p"))
                    shellpwd = true;
                else if (s.equals("s"))
                    param.addLast("s");
                else if (s.equals("i"))
                    param.addLast("i");
                else {
                    System.out.println("undefined option char '" + s + "`");
                    error = true;
                }
            }
        } else if (param.size() != 0) {
            String s = param.getFirst();

            param.removeFirst();
            if (s.equals("u"))
                TreeNodes.m_sUser = arg;
            else if (s.equals("s"))
                TreeNodes.m_sLayoutStyle = arg;
            else if (s.equals("i"))
                inifile = arg;
            else if (s.equals("tablestructure"))
                HtmTags.tablestructure = arg;
            else {
                System.out.println("undefined parameter '" + arg + "'");
                error = true;
            }
        } else {
            System.out.println("undefined parameter '" + arg + "'");
            error = true;
        }
    }
    if (error)
        System.exit(1);
    if (HtmTags.debug)
        System.out.println("start ppi-java-client");
    try {
        boolean bStop = false;
        String sPort;
        String sBrowser;
        FileInputStream file;
        Properties prop = new Properties();

        if (HtmTags.debug) {
            System.out.println("--------------------------------------------------------------------------");
            System.out.println("read layout files  '*." + TreeNodes.m_sLayoutStyle + "'");
            if (HtmTags.notree)
                System.out.println("show pages inside pop-up menu on top");
            else
                System.out.println("show pages inside tree on left side");
            if (HtmTags.notitle)
                System.out.println("display main client window with no title-bar");
            if (HtmTags.fullscreen)
                System.out.println("display main client window on full screen");
        }
        try {
            file = new FileInputStream(inifile);
            if (HtmTags.debug)
                System.out.println("read property file '" + inifile + "'");

        } catch (Exception ex) {
            if (inifile.equals("client.ini"))
                throw ex;
            System.out.println();
            System.out.println("WARNING: cannot find file '" + inifile + "' for initialization");
            System.out.println("         read standard property file 'client.ini'");
            file = new FileInputStream("client.ini");
            inifile = "client.ini";
        }
        if (HtmTags.debug)
            System.out.println("--------------------------------------------------------------------------");
        prop.load(file);
        lang = prop.getProperty("defaultLang");
        if (lang != null)
            lang = lang.trim();
        informServerLeafPage = prop.getProperty("informServerLeafPage");
        if (informServerLeafPage == null) {
            System.out.println("WARNING: property of informServerLeafPage not set inside '" + inifile + "'");
            System.out.println("         so define with default of false");
            HtmTags.informServerLeafPage = false;

        } else {
            informServerLeafPage = informServerLeafPage.trim();
            informServerLeafPage = informServerLeafPage.toLowerCase();
            if (informServerLeafPage.equals("true") || informServerLeafPage.equals("1")) {
                HtmTags.informServerLeafPage = true;

            } else if (informServerLeafPage.equals("false") || informServerLeafPage.equals("0")) {
                HtmTags.informServerLeafPage = false;

            } else {
                System.out.println(
                        "WARNING: property of informServerLeafPage not set correctly inside '" + inifile + "'");
                System.out.println("         so define with default of false");
                HtmTags.informServerLeafPage = false;
            }
        }
        maincolor = prop.getProperty("maincolor");
        if (maincolor != null)
            maincolor = maincolor.trim();
        host = prop.getProperty("host");
        if (host != null)
            host = host.trim();
        sPort = prop.getProperty("port");
        if (sPort != null)
            sPort = sPort.trim();
        sBrowser = prop.getProperty("browser");
        if (sBrowser != null) {
            sBrowser = sBrowser.trim();
            if (sBrowser.equals("MOZILLA"))
                HtmTags.m_nUseBrowser = SWT.MOZILLA;
            else if (sBrowser.equals("WEBKIT"))
                HtmTags.m_nUseBrowser = SWT.WEBKIT;
            else if (sBrowser.equals("")) {
                System.out.println("WARNING: browser inside '" + inifile + "' defined with null string");
                System.out.println("         so take standard browser for operation system");
            } else {
                System.out.println("WARNING: cannot define spezific browser '" + sBrowser + "'");
                System.out.println("         so take standard browser for operation system");
            }

        }
        mainpadding = prop.getProperty("padding");
        if (mainpadding != null) {
            boolean bfault = false;

            mainpadding = mainpadding.trim();
            nPadding = 10;
            try {
                nPadding = Integer.parseInt(mainpadding);
                if (nPadding < 0)
                    bfault = true;

            } catch (NumberFormatException ex) {
                bfault = true;
            }
            if (bfault)
                System.out.println(
                        "ERROR: padding is set to fault content '" + mainpadding + "' take default 10");
            else
                HtmTags.mainPadding = nPadding;
        }
        popuppadding = prop.getProperty("popuppadding");
        if (popuppadding != null) {
            boolean bfault = false;

            popuppadding = popuppadding.trim();
            nPopup = 3;
            try {
                nPopup = Integer.parseInt(popuppadding);
                if (nPopup < 0)
                    bfault = true;
            } catch (NumberFormatException ex) {
                bfault = true;
            }
            if (bfault)
                System.out.println(
                        "ERROR: popuppadding is set to fault content '" + popuppadding + "' take default 3");
            else
                HtmTags.popupPadding = nPopup;

        }
        backgroundLoading = prop.getProperty("UseBackgroundLoading");
        if (backgroundLoading != null) {
            backgroundLoading = backgroundLoading.trim();
            backgroundLoading = backgroundLoading.toLowerCase();
            if (backgroundLoading.equals("lower"))
                HtmTags.useBackgroundLoadingPriority = Thread.MIN_PRIORITY;
            else if (backgroundLoading.equals("higher"))
                HtmTags.useBackgroundLoadingPriority = Thread.MAX_PRIORITY;
            else
                System.out.println(
                        "### WARNING: undefined UseBackgroundLoadingPriority '" + backgroundLoading + "'");
        }
        mousepos = prop.getProperty("mousemovePos");
        mouseDelay = prop.getProperty("mousemoveDelay");
        if (mousepos != null) {
            String[] split;

            split = mousepos.split(",");
            if (split.length > 0) {
                try {
                    HtmTags.moveMouseX = Integer.parseInt(split[0].trim());

                } catch (NumberFormatException ex) {
                    System.out.println("ERROR: cannot read mouse X position '" + split[0] + "' for moving");
                }
                if (split.length > 1) {
                    try {
                        HtmTags.moveMouseY = Integer.parseInt(split[1].trim());

                    } catch (NumberFormatException ex) {
                        System.out.println("ERROR: cannot read mouse Y position '" + split[1] + "' for moving");
                    }
                }
                HtmTags.moveMouseDelay = 0;
                if (mouseDelay != null) {
                    try {
                        HtmTags.moveMouseDelay = Integer.parseInt(mouseDelay.trim());

                    } catch (NumberFormatException ex) {
                        System.out.println("ERROR: cannot read mouse delay '" + mouseDelay + "' for moving");
                        System.out.println("       so move after 0 milliseconds");
                    }

                }
            }
        }
        file.close();

        if (host == null) {
            System.out.println("ERROR: no host defined in " + inifile + "");
            bStop = true;
        }
        if (sPort == null) {
            System.out.println("ERROR: no port defined in " + inifile + "");
            bStop = true;
        } else {
            try {
                port = Integer.parseInt(sPort);
            } catch (NumberFormatException ex) {
                System.out.println("ERROR: no right port defined in " + inifile + "");
                bStop = true;
            }
        }

        if (lang == null) {
            System.out.println("WARNING: no language defined in " + inifile + "");
            if (!bStop)
                System.out.println("         use default englisch language");
            lang = "en";
        }
        if (bStop)
            System.exit(1);
        if (shellpwd) {
            Console c = System.console();

            if (c != null) {
                if (HtmTags.debug)
                    System.out.println("read password from console with method readPassword()");
                TreeNodes.m_sPwd = new String(c.readPassword("password: "));
            } else {
                int input = 0;

                if (HtmTags.debug)
                    System.out.println("read password from IO string");
                try {
                    while (input != 10) {
                        if (input != 0)
                            TreeNodes.m_sPwd += (char) input;
                        input = System.in.read();
                    }

                } catch (IOException ex) {
                    System.out.println("ERROR on input password");
                    return;
                }
            }
            //if(HtmTags.debug)
            //   System.out.println("get password: '" + TreeNodes.m_sPwd + "'");
            if (TreeNodes.m_sPwd.equals("")) {
                System.out.println("cannot create NULL password ('') for user " + TreeNodes.m_sUser);
                System.exit(1);
            }
        }

    } catch (Exception ex) {
        System.out.println(ex);
        return;
    }
    String os;
    String homeEnv;
    String allUser;
    //RE linux= new RE("Linux");
    RE windows = new RE("Windows");
    File allUserPath, homePath;
    boolean bMsg = HtmTags.debug;
    boolean bError = false;

    os = System.getProperty("os.name");
    if (!windows.match(os)) {
        homeEnv = System.getenv("HOME");
        if (homeEnv == null)
            homeEnv = "";
        allUser = homeEnv;
    } else // maybe it is Windows
    {
        homeEnv = System.getenv("HOMEDRIVE");
        if (homeEnv != null)
            homeEnv += System.getenv("HOMEPATH");
        else
            homeEnv = "";
        allUser = homeEnv; //System.getenv("ALLUSERSPROFILE");
    }
    allUserPath = new File(allUser + File.separator + ".ppi-client" + File.separator + "layout");
    homePath = new File(homeEnv + File.separator + ".ppi-client");
    if (allUser.equals("")) {
        bError = true;
        bMsg = true;
    }
    if (bMsg) {
        System.out.println("found operating system '" + os + "'");
        System.out.println("with follow set path's:");
        //System.out.println("    ALLUSER: '" + allUser + "'");
        System.out.println("    HOME:    '" + homeEnv + "'");
        System.out.println("    Host:     " + host);
        System.out.println("    port:     " + port);
    }
    if (bError) {
        System.out.println("WARNING: can not found all user path");
        TreeNodes.m_bSaveLoacal = false;
    } else {
        if (!allUserPath.isDirectory()) {
            if (!allUserPath.mkdirs()) {
                System.out.println("WARNING: can not create localy path '~" + File.separator + ".ppi-client"
                        + File.separator + "layout" + File.separator + "'");
                TreeNodes.m_bSaveLoacal = false;
            }
        } else
            TreeNodes.m_sLayoutPath = allUserPath.toString();
    }
    if (!homePath.isDirectory()) {
        if (!homePath.mkdirs()) {
            System.out.println("ERROR: can not create home path .ppi-client");
            System.exit(1);
        }
    } else
        TreeNodes.m_sHomePath = homePath.toString();

    TreeNodes.m_Settings = new DialogSettings("settings");
    if (!TreeNodes.loadSettings()) {
        TreeNodes.m_Settings.put("version", 1.0);
    }

    new PortServerClient().startApp(host, port, lang, maincolor);
    TreeNodes.saveSettings();
}

From source file:ca.uvic.chisel.javasketch.FilterSettings.java

License:Open Source License

/**
 * Creates /*  ww  w .  j a  v  a 2  s .c  om*/
 * @param file
 * @throws IOException 
 */
private FilterSettings() {
    this.settings = new DialogSettings(JAVA_SKETCH_FILTER);
    referenceProjects = new IJavaProject[0];
    listeners = new ListenerList();
    initializeDefaultSettings();
}

From source file:ch.elexis.base.ch.labortarif_2009.ui.dialogs.EalSelektor.java

License:Open Source License

@Override
protected IDialogSettings getDialogSettings() {
    return new DialogSettings("loincselector"); //$NON-NLS-1$
}

From source file:ch.elexis.core.ui.dialogs.DiagnoseSelektor.java

License:Open Source License

@Override
protected IDialogSettings getDialogSettings() {
    return new DialogSettings("diagnoseselektor"); //$NON-NLS-1$
}

From source file:com.aljoschability.rendis.ui.runtime.ActivatorImpl.java

License:Open Source License

private IDialogSettings createDialogSettings() {
    IDialogSettings dialogSettings = new DialogSettings(WORKBENCH);

    // see bug 69387
    IPath path = Platform.getStateLocation(getBundle());
    if (path != null) {
        // try r/w state area in the local file system
        String readWritePath = path.append(DIALOG_SETTINGS).toOSString();
        File settingsFile = new File(readWritePath);
        if (settingsFile.exists()) {
            try {
                dialogSettings.load(readWritePath);
            } catch (IOException e) {
                // load failed so ensure we have an empty settings
                dialogSettings = new DialogSettings(WORKBENCH);
            }/*from   ww  w. jav a 2s  .co m*/

            return dialogSettings;
        }
    }

    // otherwise look for bundle specific dialog settings
    URL dsURL = FileLocator.find(getBundle(), new Path(DIALOG_SETTINGS), null);
    if (dsURL == null) {
        return dialogSettings;
    }

    InputStream is = null;
    try {
        is = dsURL.openStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, ENCODING));
        dialogSettings.load(reader);
    } catch (IOException e) {
        // load failed so ensure we have an empty settings
        dialogSettings = new DialogSettings(WORKBENCH);
    } finally {
        try {
            if (is != null) {
                is.close();
            }
        } catch (IOException e) {
            // do nothing
        }
    }

    return dialogSettings;
}

From source file:com.bdaum.zoom.operations.internal.gen.AbstractGalleryGenerator.java

License:Open Source License

protected String generateImageList(boolean relative, boolean boost) {
    Shell shell = adaptable.getAdapter(Shell.class);
    File manifest = new File(imageFolder, "imagelist.xml"); //$NON-NLS-1$
    DialogSettings newsettings = new DialogSettings("images"); //$NON-NLS-1$
    DialogSettings settings = new DialogSettings("images"); //$NON-NLS-1$
    try {/*from w  w w  .  ja  v  a2 s  . c  om*/
        settings.load(manifest.getAbsolutePath());
    } catch (IOException e1) {
        // ignore
    }
    Map<String, WebParameter> parameters = gallery.getParameter();
    StringBuilder sb = new StringBuilder();
    ICore activator = CoreActivator.getDefault();
    IDbManager dbManager = activator.getDbManager();
    int thumbnailSizeInPixel = getThumbnailSizeInPixel(gallery.getThumbSize());
    int i = 0;
    boolean first = true;
    for (Storyboard storyboard : gallery.getStoryboard()) {
        if (selectedStoryboard != null && selectedStoryboard != storyboard)
            continue;
        maxImageWidthInSection = -1;
        maxImageHeightInSection = -1;
        String sectionSnippet = getSectionHeader(++i);
        Map<String, String> sectionvars = null;
        if (sectionSnippet != null) {
            sectionvars = getSectionSnippetVars((StoryboardImpl) storyboard, i);
            StringBuffer generated = generateSnippet(parameters, sectionvars, sectionSnippet);
            if (sb.length() > 0 && generated.length() > 0)
                sb.append('\n');
            sb.append(generated);
        }
        boolean enlarge = storyboard.getEnlargeSmall();
        int imageSizeInPixels = getImageSizeInPixels(storyboard.getImageSize());
        List<String> exhibits = storyboard.getExhibit();
        try (Assetbox box = new Assetbox(null, status, false)) {
            for (String id : exhibits) {
                WebExhibitImpl exhibit = dbManager.obtainById(WebExhibitImpl.class, id);
                if (exhibit != null) {
                    String assetId = exhibit.getAsset();
                    AssetImpl asset = dbManager.obtainAsset(assetId);
                    if (asset != null) {
                        int isize = imageSizeInPixels;
                        if (boost) {
                            int width = asset.getWidth();
                            int height = asset.getHeight();
                            if (width != 0 && height != 0) {
                                double ratio = (double) width / height;
                                if (ratio < 1d)
                                    ratio = 1d / ratio;
                                isize *= ratio;
                            }
                        }
                        String copyright = null;
                        if (gallery.getAddWatermark()) {
                            copyright = asset.getCopyright();
                            if (copyright == null || copyright.isEmpty())
                                copyright = gallery.getCopyright();
                            if (copyright != null && copyright.isEmpty())
                                copyright = null;
                        }
                        File originalFile = box.obtainFile(asset);
                        Rectangle bounds = null;
                        if (originalFile != null) {
                            URI uri = box.getUri();
                            boolean includeMetadata = exhibit.getIncludeMetadata();
                            int rotation = asset.getRotation();
                            IDialogSettings manifestSection = createManifestEntry(newsettings, uri, rotation,
                                    isize, thumbnailSizeInPixel, getBigImageSize(), includeMetadata, copyright,
                                    enlarge, gallery.getRadius(), gallery.getAmount(), gallery.getThreshold(),
                                    gallery.getApplySharpening());
                            String imageName = Core.getFileName(uri, false) + ".jpg"; //$NON-NLS-1$
                            File imageFile = new File(imageFolder, imageName);
                            File bigFile = bigFolder != null ? new File(bigFolder, imageName) : null;
                            File thumbnail = thumbnailFolder == null ? null
                                    : new File(thumbnailFolder, imageName);
                            Rectangle imageDims = manifestEntryModified(settings, imageFile, thumbnail, uri,
                                    rotation, isize, thumbnailSizeInPixel, getBigImageSize(), includeMetadata,
                                    copyright, enlarge, gallery.getRadius(), gallery.getAmount(),
                                    gallery.getThreshold(), gallery.getApplySharpening());
                            if (imageDims == null) {
                                UnsharpMask umask = gallery.getApplySharpening()
                                        ? ImageActivator.getDefault().computeUnsharpMask(gallery.getRadius(),
                                                gallery.getAmount(), gallery.getThreshold())
                                        : null;
                                Rectangle bigImageSize = getBigImageSize();
                                ZImage zimage = null;
                                try {
                                    zimage = CoreActivator.getDefault().getHighresImageLoader().loadImage(null,
                                            status, originalFile, rotation, asset.getFocalLengthIn35MmFilm(),
                                            bigImageSize == null ? computeImageBounds(isize) : bigImageSize, 1d,
                                            enlarge ? Double.MAX_VALUE : 1d, true, ImageConstants.SRGB, null,
                                            umask, null, fileWatcher, opId, this);
                                } catch (UnsupportedOperationException e) {
                                    // do nothing
                                }
                                Image image = null;
                                Image bigImage = null;
                                try {
                                    if (bigImageSize != null) {
                                        bigImage = zimage == null ? null
                                                : zimage.getSwtImage(shell.getDisplay(), true, ZImage.CROPPED,
                                                        bigImageSize.width, bigImageSize.height);
                                        if (bigImage != null) {
                                            image = new Image(shell.getDisplay(), ImageUtilities
                                                    .downSample(bigImage.getImageData(), isize, isize, 0));
                                            bigFile = decorateImage(bigImage, bigFile, asset, copyright,
                                                    includeMetadata);
                                            imageFile = decorateImage(image, imageFile, asset, copyright,
                                                    includeMetadata);
                                            if (thumbnail != null && thumbnailSizeInPixel > 0)
                                                thumbnail = generateThumbnail(thumbnail, image,
                                                        thumbnailSizeInPixel);
                                        }
                                    } else {
                                        image = zimage == null ? null
                                                : zimage.getSwtImage(shell.getDisplay(), true, ZImage.CROPPED,
                                                        isize, isize);
                                        if (image != null) {
                                            imageFile = decorateImage(image, imageFile, asset, copyright,
                                                    includeMetadata);
                                            if (thumbnail != null && thumbnailSizeInPixel > 0)
                                                thumbnail = generateThumbnail(thumbnail, image,
                                                        thumbnailSizeInPixel);
                                        }
                                    }
                                } finally {
                                    if (bigImage != null)
                                        bigImage.dispose();
                                    if (image != null) {
                                        bounds = image.getBounds();
                                        image.dispose();
                                        updateSection(manifestSection, bounds);
                                    }
                                }
                            } else {
                                bounds = imageDims;
                                if (filter != null && !filter.isEmpty()) {
                                    imageFile = generateImage(asset, imageFile, null, includeMetadata,
                                            jpegQuality);
                                    if (bigFile != null)
                                        bigFile = generateImage(asset, bigFile, null, includeMetadata,
                                                jpegQuality);
                                }
                            }
                            File copiedFile = new File(originalsFolder, originalFile.getName());
                            boolean downloadable = exhibit.getDownloadable() && needsOriginals();
                            if (originalModified(settings, copiedFile, downloadable, uri)) {
                                if (downloadable)
                                    copiedFile = copyImage(originalFile, copiedFile);
                                else {
                                    copiedFile.delete();
                                    copiedFile = null;
                                }
                            }
                            Map<String, String> vars = getImageSnippetVars(exhibit, asset, storyboard,
                                    thumbnail == null ? null
                                            : (relative) ? thumbnail.getName()
                                                    : thumbnailFolder.getName() + '/' + thumbnail.getName(),
                                    imageFile == null ? null
                                            : (relative) ? imageFile.getName()
                                                    : imageFolder.getName() + '/' + imageFile.getName(),
                                    bigFile == null ? null
                                            : (relative) ? bigFile.getName()
                                                    : bigFolder.getName() + '/' + bigFile.getName(),
                                    copiedFile == null ? null
                                            : (relative) ? copiedFile.getName()
                                                    : originalsFolder == null ? null
                                                            : originalsFolder.getName() + '/'
                                                                    + copiedFile.getName(),
                                    i);
                            if (bounds != null) {
                                vars.put(IMAGE_WIDTH, String.valueOf(bounds.width));
                                vars.put(IMAGE_HEIGHT, String.valueOf(bounds.height));
                                if (bounds.width > maxImageWidthInSection)
                                    maxImageWidthInSection = bounds.width;
                                if (bounds.height > maxImageHeightInSection)
                                    maxImageHeightInSection = bounds.height;
                            } else {
                                vars.put(IMAGE_WIDTH, "-1"); //$NON-NLS-1$
                                vars.put(IMAGE_HEIGHT, "-1"); //$NON-NLS-1$
                            }
                            String snippet = getImageSnippet(first);
                            first = false;
                            StringBuffer generated = generateSnippet(parameters, vars, snippet);
                            if (sb.length() > 0 && generated.length() > 0)
                                sb.append('\n');
                            sb.append(generated);
                        }
                    }
                }
                monitor.worked(1);
                if (monitor.isCanceled())
                    return ""; //$NON-NLS-1$
            }
        }
        if (sectionSnippet != null) {
            StringBuffer generated = generateSnippet(parameters, sectionvars,
                    sectionSnippet = getSectionFooter());
            if (sb.length() > 0 && generated.length() > 0)
                sb.append('\n');
            sb.append(generated);
        }
    }
    manifest.delete();
    try {
        newsettings.save(manifest.getAbsolutePath());
    } catch (IOException e) {
        // ignore
    }
    return sb.toString();
}