Example usage for org.eclipse.jface.preference PreferenceManager addToRoot

List of usage examples for org.eclipse.jface.preference PreferenceManager addToRoot

Introduction

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

Prototype

public void addToRoot(IPreferenceNode node) 

Source Link

Document

Adds the given preference node as a subnode of the root.

Usage

From source file:org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin.java

License:Open Source License

/**
 * Displays the given preference page./* www . j  a  va2s.com*/
 * 
 * @param id pref page id
 * @param page pref page
 * @deprecated use <code>JDIDebugUIPlugin#showPreferencePage(String pageId)</code>, which uses the <code>PreferenceUtils</code> framework for opening pages.
 */
@Deprecated
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(JDIDebugUIPlugin.getActiveWorkbenchShell(), manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(JDIDebugUIPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
}

From source file:org.eclipse.jst.pagedesigner.ui.dialogs.StyleDialog.java

License:Open Source License

/**
 * @param parentShell/*from   w  ww .  j a  v a  2  s.  c o  m*/
 * @param manager
 * @param element 
 * @param style 
 */
public StyleDialog(Shell parentShell, PreferenceManager manager, IDOMElement element,
        CSSPropertyContext style) {
    super(parentShell, manager);
    manager.addToRoot(new TextPreferenceNode(element, style));
    manager.addToRoot(new BackgroudPreferenceNode(element, style));
    manager.addToRoot(new BlockPreferenceNode(element, style));
    manager.addToRoot(new BoxPreferenceNode(element, style));
    manager.addToRoot(new BorderPreferenceNode(element, style));
    manager.addToRoot(new ListPreferenceNode(element, style));
    manager.addToRoot(new PositioningPreferenceNode(element, style));
    manager.addToRoot(new ExtensionsPreferenceNode(element, style));
}

From source file:org.eclipse.jst.server.generic.ui.internal.JRESelectDecorator.java

License:Open Source License

protected boolean showPreferencePage(GenericServerComposite composite) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage") //$NON-NLS-1$
            .findSubNode("org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"); //$NON-NLS-1$
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    final PreferenceDialog dialog = new PreferenceDialog(composite.getShell(), manager2);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(composite.getDisplay(), new Runnable() {
        public void run() {
            dialog.create();//  www. ja v  a2 s  .  co  m
            if (dialog.open() == Window.OK)
                result[0] = true;
        }
    });
    return result[0];
}

From source file:org.eclipse.jst.server.jetty.ui.internal.JettyRuntimeComposite.java

License:Open Source License

protected boolean showPreferencePage() {
    String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage";

    // should be using the following API, but it only allows a single
    // preference page instance.
    // see bug 168211 for details
    // PreferenceDialog dialog =
    // PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[]
    // { id }, null);
    // return (dialog.open() == Window.OK);

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage")
            .findSubNode(id);//from www  .  j av  a 2s  . c o m
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}

From source file:org.eclipse.jst.server.tomcat.ui.internal.TomcatRuntimeComposite.java

License:Open Source License

protected boolean showPreferencePage() {
    String id = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage";

    // should be using the following API, but it only allows a single preference page instance.
    // see bug 168211 for details
    //PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null);
    //return (dialog.open() == Window.OK);      

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage")
            .findSubNode(id);// w  w w.ja v  a 2s .  c  o  m
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}

From source file:org.eclipse.jubula.client.ui.rcp.extensions.ProjectPropertyExtensionHandler.java

License:Open Source License

/**
 * This method creates all property pages which were created by using the
 * extension point of ClientGUI.//from   ww  w .  j ava  2 s  . c om
 * 
 * @param es
 *            The edit support for the pages.
 * @param mgr
 *            The manager, where the pages should be added.
 * @return list of these pages
 */
public static List<AbstractProjectPropertyPage> createPages(EditSupport es, PreferenceManager mgr) {
    List<AbstractProjectPropertyPage> tmp = new ArrayList<AbstractProjectPropertyPage>();
    // With all extensions of my extension point...
    for (IExtension ext : ExtensionUtils.getExtensions(PROPERTY_ID)) {
        // ...and then all children which represent the page.
        for (IConfigurationElement prop : ext.getConfigurationElements()) {
            // Institate the class dynamically
            AbstractProjectPropertyPage page = null;
            try {
                page = (AbstractProjectPropertyPage) prop.createExecutableExtension(EP_CLASS);
            } catch (CoreException e) {
                LOG.error(Messages.CoreException, e);
                continue; // If the creation of the class fails
            }

            // Set the edit support
            page.setEditSupport(es);

            // Adding the page with the proper title to the manager
            page.setTitle(prop.getAttribute(EP_NAME));
            IPreferenceNode node = new PreferenceNode(prop.getAttribute(EP_ID), page);
            mgr.addToRoot(node);
            tmp.add(page);
        }
    }
    return tmp;
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.project.ProjectPropertiesHandler.java

License:Open Source License

/**
 * Creates the project property pages.//www .ja va  2  s. co m
 * 
 * @param es The edit support.
 * @param mgr The preference manager.
 * @return the created general property page.
 */
private ProjectGeneralPropertyPage createPages(EditSupport es, PreferenceManager mgr) {

    ProjectGeneralPropertyPage generalPage = new ProjectGeneralPropertyPage(es);
    generalPage.setTitle(Messages.PropertiesActionPage1);
    IPreferenceNode generalNode = new PreferenceNode(Constants.PROJECT_PROPERTY_ID, generalPage);
    mgr.addToRoot(generalNode);

    PropertyPage langPage = new ProjectLanguagePropertyPage(es);
    langPage.setTitle(Messages.PropertiesActionPage2);
    IPreferenceNode langNode = new PreferenceNode(Constants.PROJECT_PROPERTY_ID, langPage);
    mgr.addToRoot(langNode);

    PropertyPage autPage = new AUTPropertyPage(es);
    autPage.setTitle(Messages.PropertiesActionPage3);
    IPreferenceNode autNode = new PreferenceNode(Constants.AUT_PROPERTY_ID, autPage);
    mgr.addToRoot(autNode);

    ProjectUsedPropertyPage usedPage = new ProjectUsedPropertyPage(es);
    usedPage.setTitle(Messages.PropertiesActionPage4);
    IPreferenceNode usedNode = new PreferenceNode(Constants.REUSED_PROJECT_PROPERTY_ID, usedPage);
    mgr.addToRoot(usedNode);

    ProjectALMPropertyPage almPage = new ProjectALMPropertyPage(es);
    almPage.setTitle(Messages.PropertiesActionPage5);
    IPreferenceNode almNode = new PreferenceNode(Constants.ALM_PROJECT_PROPERTY_ID, almPage);
    mgr.addToRoot(almNode);

    generalPage.addOkListener(usedPage);

    return generalPage;
}

From source file:org.eclipse.jubula.client.ui.rcp.handlers.project.ProjectPropertyDialog.java

License:Open Source License

/**
 * Creates the project property pages./* w w  w . j av a 2 s  .  co m*/
 * 
 * @param es The edit support.
 * @param mgr The preference manager.
 * @return the created general property page.
 */
private static final ProjectGeneralPropertyPage createPages(EditSupport es, PreferenceManager mgr) {

    ProjectGeneralPropertyPage generalPage = new ProjectGeneralPropertyPage(es);
    generalPage.setTitle(Messages.PropertiesActionPage1);
    IPreferenceNode generalNode = new PreferenceNode(Constants.PROJECT_PROPERTY_ID, generalPage);
    mgr.addToRoot(generalNode);

    PropertyPage autPage = new AUTPropertyPage(es);
    autPage.setTitle(Messages.PropertiesActionPage3);
    IPreferenceNode autNode = new PreferenceNode(Constants.AUT_PROPERTY_ID, autPage);
    mgr.addToRoot(autNode);

    ProjectUsedPropertyPage usedPage = new ProjectUsedPropertyPage(es);
    usedPage.setTitle(Messages.PropertiesActionPage4);
    IPreferenceNode usedNode = new PreferenceNode(Constants.REUSED_PROJECT_PROPERTY_ID, usedPage);
    mgr.addToRoot(usedNode);

    ProjectALMPropertyPage almPage = new ProjectALMPropertyPage(es);
    almPage.setTitle(Messages.PropertiesActionPage5);
    IPreferenceNode almNode = new PreferenceNode(Constants.ALM_PROJECT_PROPERTY_ID, almPage);
    mgr.addToRoot(almNode);

    generalPage.addOkListener(usedPage);
    generalPage.addOkListener(almPage);

    return generalPage;
}

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  www.  ja va  2  s .  c  o  m*/
        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.
 *//*from w  w w  . j  ava  2 s. c om*/
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();
        }
    });
}