Example usage for org.eclipse.jface.preference PreferenceDialog open

List of usage examples for org.eclipse.jface.preference PreferenceDialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceDialog open.

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:org.pwsafe.passwordsafeswt.action.OptionsAction.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.Action#run()
 *///  w  ww. j  av a2  s .c  o  m
@Override
public void run() {
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();

    // Create the preference manager
    PreferenceManager mgr = new PreferenceManager();

    // Create the nodes
    PreferenceNode displayPrefs = new PreferenceNode("display", Messages.getString("OptionsAction.DisplayNode"), //$NON-NLS-1$//$NON-NLS-2$
            null, DisplayPreferences.class.getName());
    PreferenceNode securityPrefs = new PreferenceNode("security", //$NON-NLS-1$
            Messages.getString("OptionsAction.SecurityNode"), null, SecurityPreferences.class //$NON-NLS-1$
                    .getName());
    PreferenceNode passwordPolicyPrefs = new PreferenceNode("policy", //$NON-NLS-1$
            Messages.getString("OptionsAction.PolicyNode"), null, //$NON-NLS-1$
            PasswordPolicyPreferences.class.getName());
    PreferenceNode usernamePrefs = new PreferenceNode("username", //$NON-NLS-1$
            Messages.getString("OptionsAction.UserNameNode"), null, UsernamePreferences.class //$NON-NLS-1$
                    .getName());
    PreferenceNode miscPrefs = new PreferenceNode("misc", Messages.getString("OptionsAction.MiscNode"), null, //$NON-NLS-1$//$NON-NLS-2$
            MiscPreferences.class.getName());

    // Add the nodes
    mgr.addToRoot(displayPrefs);
    mgr.addToRoot(securityPrefs);
    mgr.addToRoot(passwordPolicyPrefs);
    mgr.addToRoot(usernamePrefs);
    mgr.addToRoot(miscPrefs);

    // Create the preferences dialog
    PreferenceDialog dlg = new PreferenceDialog(app.getShell(), mgr);
    Window.setDefaultImage(
            IOUtils.getImage(PasswordSafeJFace.class, "/org/pwsafe/passwordsafeswt/images/clogo.gif")); //$NON-NLS-1$

    // Set the preference store
    dlg.setPreferenceStore(JFacePreferences.getPreferenceStore());

    // Open the dialog
    dlg.open();

    try {
        if (JFacePreferences.getPreferenceStore().needsSaving()) {
            // Be Paranoid - Save the preferences now
            UserPreferences.getInstance().savePreferences();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.python.pydev.debug.newconsole.env.ChooseProcessTypeDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);

    boolean debugButtonCreated = false;
    if (getSuspendedFrame() != null) {
        // when debugger is running and valid frame is selected then
        // displaying debug console as first option
        createDebugButton(area);/*  w w w . j  av a  2 s .c o m*/
        debugButtonCreated = true;
    }

    checkboxForCurrentEditor = new Button(area, SWT.RADIO);
    checkboxForCurrentEditor.setToolTipText(
            "Creates a console with the PYTHONPATH used by the current editor (and Jython/Python/IronPython depending on the project type).");
    configureEditorButton();

    checkboxPython = new Button(area, SWT.RADIO);
    checkboxPython.setToolTipText(
            "Creates a Python console with the PYTHONPATH containing all the python projects in the workspace.");
    configureButton(checkboxPython, "Python", PydevPlugin.getPythonInterpreterManager());

    checkboxJython = new Button(area, SWT.RADIO);
    checkboxJython.setToolTipText(
            "Creates a Jython console with the PYTHONPATH containing all the python projects in the workspace.");
    configureButton(checkboxJython, "Jython", PydevPlugin.getJythonInterpreterManager());

    checkboxIronpython = new Button(area, SWT.RADIO);
    checkboxIronpython.setToolTipText(
            "Creates an IronPython console with the PYTHONPATH containing all the python projects in the workspace.");
    configureButton(checkboxIronpython, "IronPython", PydevPlugin.getIronpythonInterpreterManager());

    checkboxJythonEclipse = new Button(area, SWT.RADIO);
    checkboxJythonEclipse.setToolTipText(
            "Creates a Jython console using the running Eclipse environment (can potentially halt Eclipse depending on what's done).");
    configureButton(checkboxJythonEclipse, "Jython using VM running Eclipse",
            new JythonEclipseInterpreterManager());

    if (!debugButtonCreated) {
        createDebugButton(area);
    }

    link = new Link(area, SWT.LEFT | SWT.WRAP);
    link.setText("<a>Configure interactive console preferences.</a>\n"
            + "I.e.: send contents to console on creation,\n"
            + "connect to variables view, initial commands, etc.");

    link.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
                    InteractiveConsolePrefs.PREFERENCES_ID, null, null);
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    return area;
}

From source file:org.python.pydev.pyunit.preferences.PyUnitPrefsPage2.java

License:Open Source License

public static void showPage() {
    String id = "org.python.pydev.prefs.pyunitPage";
    PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(null, id, null, null);
    prefDialog.open();
}

From source file:org.python.pydev.ui.wizards.files.TemplateSelectDialog.java

License:Open Source License

private void createTemplateOptions(Composite topLevel) {
    final TemplateStore templateStore = TemplateHelper.getTemplateStore();
    if (templateStore != null) {
        TemplatePersistenceData[] templateData = templateStore.getTemplateData(false);
        if (templateData != null && templateData.length > 0) {
            //create the template selection
            label = new Label(topLevel, SWT.NONE);
            label.setText("Template");

            templateList = new Table(topLevel, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
            fillTemplateOptions(templateData, templateList);

            templateList.addMouseListener(new MouseListener() {

                public void mouseUp(MouseEvent e) {
                }//from   w  w  w . j ava  2 s .c om

                public void mouseDown(MouseEvent e) {
                }

                public void mouseDoubleClick(MouseEvent e) {
                    okPressed();
                }
            });

            Link link = new Link(topLevel, SWT.NONE);
            link.setText("<a>Config available templates...</a>");

            link.addSelectionListener(new SelectionListener() {
                public void widgetSelected(SelectionEvent e) {
                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
                            "org.python.pydev.prefs.template", null, null);
                    dialog.open();
                    //Fill it after having the settings edited.
                    TemplatePersistenceData[] templateData = templateStore.getTemplateData(false);
                    if (templateData != null && templateData.length > 0) {
                        fillTemplateOptions(templateData, templateList);
                    } else {
                        fillTemplateOptions(new TemplatePersistenceData[0], templateList);
                    }
                }

                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            setLayout(label, templateList, link);
        }
    }
}

From source file:org.rdkit.knime.util.EclipseUtils.java

License:Open Source License

/**
 * Creates a label component that looks like a link and reacts on mouse clicks.
 * When clicking it will open the Eclipse / KNIME preference dialog on the page
 * with the specified ID.//from ww w  . j av a  2 s  .  c  o  m
 * 
 * @param strLabel Link text. Must not be null.
 * @param strPreferenceId Preference page ID to be shown. Must not be null.
 * @param callback Callback method to be called after the preference dialog has been closed.
 *       Can be null.
 * 
 * @return JLabel instance with activate mouse click listener.
 */
public static JLabel createPreferenceLink(final String strLabel, final String strPreferenceId,
        final Callback callback) {
    if (strLabel == null) {
        throw new IllegalArgumentException("Preference label text must not be null.");
    }
    if (strPreferenceId == null) {
        throw new IllegalArgumentException("Preference Page ID must not be null.");
    }

    final JLabel lbPreferenceLink = new JLabel(strLabel, SwingConstants.LEFT);
    lbPreferenceLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lbPreferenceLink.setForeground(Color.blue);

    @SuppressWarnings("unchecked")
    final Map<TextAttribute, Object> attributes = (Map<TextAttribute, Object>) lbPreferenceLink.getFont()
            .getAttributes();
    attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
    lbPreferenceLink.setFont(lbPreferenceLink.getFont().deriveFont(attributes));

    lbPreferenceLink.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            // Open the preferences dialog
            final Display d = Display.getDefault();
            // Run in UI thread
            d.syncExec(new Runnable() {
                @Override
                public void run() {
                    final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(d.getActiveShell(),
                            strPreferenceId, new String[] { strPreferenceId }, null);
                    if (dialog.open() == Window.OK && callback != null) {
                        callback.callback();
                    }
                }
            });
        }
    });

    return lbPreferenceLink;
}

From source file:org.reap.internal.core.persistence.PersistenceManager.java

License:Open Source License

private void showConfigDialog(final PersistenceConfig config) {
    final Display display = Activator.getDefault().getWorkbench().getDisplay();
    display.syncExec(new Runnable() {
        public void run() {
            final PreferenceManager manager = new PreferenceManager();
            final PreferenceDialog dialog = new PreferenceDialog(new Shell(display), manager);
            final PreferencePage page = new PersistenceConfigPage(config);
            final IPreferenceNode node = new PreferenceNode("Datenbank", page);
            manager.addToRoot(node);/*from   ww w . j  ava  2s  . co  m*/
            configDialogState = dialog.open();
        }
    });
}

From source file:org.rubypeople.rdt.internal.ui.preferences.PreferencePageSupport.java

License:Open Source License

/**
 * Open the given preference page in a preference dialog.
 * @param shell The shell to open on/*w  w w.  ja v  a2 s  .  c  om*/
 * @param id The id of the preference page as in the plugin.xml 
 * @param page An instance of the page. Note that such a page should also set its own
 * title to correctly show up.
 * @return Returns <code>true</code> if the user ended the page by pressing OK.
 */
public static boolean showPreferencePage(Shell shell, String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
    return result[0];
}

From source file:org.seasar.s2junit4plugin.wizard.NewS2JUnit4TypeWizardPage.java

License:Apache License

private void typePageLinkActivated(SelectionEvent e) {
    IJavaProject project = getJavaProject();
    if (project != null) {
        PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), project.getProject(),
                CodeTemplatePreferencePage.PROP_ID, null, null);
        dialog.open();
    } else {//from w  w  w . java2s.  co  m
        String title = NewWizardMessages.NewTypeWizardPage_configure_templates_title;
        String message = NewWizardMessages.NewTypeWizardPage_configure_templates_message;
        MessageDialog.openInformation(getShell(), title, message);
    }
}

From source file:org.sonar.ide.eclipse.internal.ui.properties.SonarProjectPropertyBlock.java

License:Open Source License

private void addServerData(Composite container, ProjectProperties projectProperties) {
    // Create group
    Group group = new Group(container, SWT.NONE);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;//from w  w  w .  ja  va 2  s . c o m
    data.grabExcessHorizontalSpace = true;
    group.setLayoutData(data);
    group.setText(Messages.SonarProjectPropertyBlock_label_host);
    GridLayout gridLayout = new GridLayout(3, false);
    group.setLayout(gridLayout);

    // Create select list of servers.
    serversCombo = new Combo(group, SWT.READ_ONLY);
    List<Host> servers = SonarCorePlugin.getServersManager().getHosts();
    String defaultServer = projectProperties.getUrl();
    int index = -1;
    for (int i = 0; i < servers.size(); i++) {
        Host server = servers.get(i);
        if (StringUtils.equals(defaultServer, server.getHost())) {
            index = i;
        }
        serversCombo.add(server.getHost());
    }
    if (index == -1) {
        serversCombo.add(defaultServer);
        index = servers.size();
    }
    serversCombo.select(index);

    // Create open preference button.
    serverConfigButton = new Button(group, SWT.PUSH);
    serverConfigButton.setText(Messages.SonarProjectPropertyBlock_action_server);
    serverConfigButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    serverConfigButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog preference = PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    ISonarConstants.PLUGIN_ID + ".preferences.SonarPreferencePage", null, null);
            if (preference != null && (preference.open() == Window.OK)) {
                serversCombo.removeAll();
                List<Host> servers = SonarCorePlugin.getServersManager().getHosts();
                for (Host server : servers) {
                    serversCombo.add(server.getHost());
                }
                serversCombo.select(servers.size() - 1);
            }
        }
    });
}

From source file:org.springframework.ide.eclipse.internal.uaa.preferences.UaaDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite parent2 = (Composite) super.createDialogArea(parent);

    Composite composite = new Composite(parent2, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(composite);

    Link link = new Link(composite, SWT.NONE | SWT.WRAP);
    link.setText(MESSAGE.replace("%name%", PLATFORM_NAME));
    link.addSelectionListener(new SelectionAdapter() {
        @Override/*from ww w .j  a  v a2s  .  c  om*/
        public void widgetSelected(SelectionEvent e) {
            if ("tou".equals(e.text)) {
                UaaUtils.openUrl("http://www.springsource.org/uaa/terms_of_use");
            } else if ("faq".equals(e.text)) {
                UaaUtils.openUrl("http://www.springsource.org/uaa/faq");
            } else if ("prefs".equals(e.text)) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        close();
                        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
                                "org.springframework.ide.eclipse.uaa.preferencePage", null, null);
                        dialog.open();
                        setReturnCode(CANCEL);
                    }
                });
            }
        }
    });
    link.setFont(parent.getFont());

    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
            .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT)
            .grab(true, false).applyTo(link);

    composite.pack();
    return parent;
}