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

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

Introduction

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

Prototype

public PreferenceDialog(Shell parentShell, PreferenceManager manager) 

Source Link

Document

Creates a new preference dialog under the control of the given preference manager.

Usage

From source file:org.eclipse.mat.ui.rcp.actions.OpenPreferenceAction.java

License:Open Source License

@Override
public void run() {
    if (reg == null)
        reg = new PreferenceRegistry();

    PreferenceManager manager = new PreferenceManager('/');
    // Recreate tree structure
    Map<String, Node> nodes = new LinkedHashMap<String, Node>();
    for (Node node : reg.delegates()) {
        node.subNode = false;//from ww  w .  j ava  2 s  . com
        for (IPreferenceNode subNode : node.getSubNodes())
            node.remove(subNode.getId());
        nodes.put(node.getId(), node);
    }
    for (Node node : reg.delegates()) {
        if (node.getCategory() != null && nodes.containsKey(node.getCategory())) {
            nodes.get(node.getCategory()).add(node);
            node.subNode = true;
        }
    }
    List<Node> toSort = new ArrayList<Node>();
    for (Node node : nodes.values()) {
        if (!node.subNode)
            toSort.add(node);
    }
    Collections.sort(toSort, new Comparator<Node>() {

        public int compare(Node object1, Node object2) {
            return object1.getLabelText().compareTo(object2.getLabelText());
        }

    });
    for (Node node : toSort) {
        manager.addToRoot(node);
    }

    PreferenceDialog dialog = new PreferenceDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), manager);
    dialog.open();
}

From source file:org.eclipse.ocl.common.ui.internal.preferences.AbstractProjectPreferencePage.java

License:Open Source License

/**
 * When the project-specific link is activated, install the project-specific property page.
 *//* ww w . j a  va  2s. co  m*/
final void doLinkActivated(Link link) {
    IPreferencePage page = createClonePage();
    page.setTitle(getTitle());
    final IPreferenceNode targetNode = new PreferenceNode(pluginId, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.eclipse.pde.internal.ui.correction.ConfigureTargetPlatformResolution.java

License:Open Source License

@Override
public void run(IMarker marker) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    PreferenceDialog preferenceDialog = new PreferenceDialog(shell,
            PlatformUI.getWorkbench().getPreferenceManager());
    preferenceDialog.setSelectedNode(TargetPlatformPreferencePage.PAGE_ID);
    preferenceDialog.open();//  w w w.  j  a  va 2 s.c o  m
}

From source file:org.eclipse.php.internal.debug.ui.preferences.phps.ShowPHPsPreferences.java

License:Open Source License

protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);//from  w ww . j  av a  2  s  .c om
    final PreferenceDialog dialog = new PreferenceDialog(PHPDebugUIPlugin.getActiveWorkbenchShell(), manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(PHPDebugUIPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
}

From source file:org.eclipse.php.internal.server.ui.builtin.PHPRuntimeComposite.java

License:Open Source License

protected boolean showPreferencePage() {
    String id = "org.eclipse.php.debug.ui.preferencesphps.PHPsPreferencePage";

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.php.ui.preferences.PHPBasePreferencePage").findSubNode(id);
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);/*from   w w  w  .j ava  2  s  .  com*/
    PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}

From source file:org.eclipse.php.internal.ui.util.SWTUtil.java

License:Open Source License

/**
 * This method allows us to open the preference dialog on the specific page,
 * in this case the perspective page//  w  ww.  ja  v a  2 s . co  m
 * 
 * @param id
 *            the id of pref page to show
 * @param page
 *            the actual page to show Copied from
 *            org.eclipse.debug.internal.ui.SWTUtil
 */
public static void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(DebugUIPlugin.getShell(), manager);
    BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.eclipse.ptp.pldt.wizards.wizardPages.AbstractProjectWizardPage.java

License:Open Source License

private void showPreferenceDialog(String type) {
    PreferenceManager mgr = new PreferenceManager();
    IPreferencePage preferencePage = getPreferencePage();
    preferencePage.setTitle(type);/*w w  w .j  a  va2s  .  c  o m*/
    IPreferenceNode node = new PreferenceNode("1", preferencePage); //$NON-NLS-1$
    mgr.addToRoot(node);
    Shell shell = Display.getCurrent().getActiveShell();
    PreferenceDialog dialog = new PreferenceDialog(shell, mgr);
    dialog.create();
    // must do dialog.create() before setting message
    dialog.setMessage(preferencePage.getTitle());
    dialog.open();
}

From source file:org.eclipse.reddeer.jface.test.preference.PreferenceDialogTest.java

License:Open Source License

@BeforeClass
public static void openPreferenceDialog() {
    Display.asyncExec(new Runnable() {

        @Override//  w w  w .  ja v a 2  s .c o m
        public void run() {
            PreferenceManager mgr = new PreferenceManager();
            PreferenceNode node = new PreferenceNode("one", new MyPreferencePage());
            mgr.addToRoot(node);

            preference = new PreferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    mgr);
            preference.open();

        }
    });
}

From source file:org.eclipse.tcf.internal.debug.ui.launch.setup.WizardLoginPage.java

License:Open Source License

private void openProtocolPreferences(Shell shell, String title) {
    try {/* w  w  w .j a v  a 2s  .  c  o  m*/
        PreferenceManager mgr = new PreferenceManager();
        IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui",
                "preferencePages");
        IExtension[] extensions = point.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            IConfigurationElement[] e = extensions[i].getConfigurationElements();
            for (int j = 0; j < e.length; j++) {
                String nm = e[j].getName();
                if (nm.equals("page")) { //$NON-NLS-1$
                    String cnm = e[j].getAttribute("class"); //$NON-NLS-1$
                    if (cnm == null)
                        continue;
                    if (!cnm.startsWith("org.eclipse.jsch."))
                        continue;
                    String id = e[j].getAttribute("id"); //$NON-NLS-1$
                    if (id == null)
                        id = cnm;
                    Bundle bundle = Platform.getBundle(extensions[i].getNamespaceIdentifier());
                    Class<?> c = bundle.loadClass(cnm);
                    IPreferencePage page = (IPreferencePage) c.newInstance();
                    String pnm = e[j].getAttribute("name"); //$NON-NLS-1$
                    if (pnm != null)
                        page.setTitle(pnm);
                    mgr.addToRoot(new PreferenceNode(id, page));
                }
            }
        }
        PreferenceDialog dialog = new PreferenceDialog(shell, mgr);
        dialog.create();
        dialog.setMessage(title);
        dialog.open();
    } catch (Throwable err) {
        String msg = err.getLocalizedMessage();
        if (msg == null || msg.length() == 0)
            msg = err.getClass().getName();
        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        mb.setText("Error");
        mb.setMessage("Cannot open preferences dialog:\n" + msg);
        mb.open();
    }
}

From source file:org.eclipse.titan.executor.properties.FieldEditorPropertyPage.java

License:Open Source License

protected void showPreferencePage(final String id, final IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);/*  w  w  w. j a v  a  2s  .  c  o m*/
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}