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.goko.controller.grbl.v09.internal.handlers.GrblConfigurationOpenHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, IGrblControllerService service,
        IEclipseContext context) throws GkException {
    PreferenceManager manager = new PreferenceManager('/');
    GrblConfiguration cfg = service.getConfiguration();
    manager.addToRoot(
            new PreferenceNode("org.goko.controller.grbl.1.device", new GrblConfigurationDialog(cfg)));

    PreferenceDialog dialog = new PreferenceDialog(shell, manager);

    int result = dialog.open();

    if (result == Dialog.OK) {
        try {/*  w ww  .  ja va 2 s  .com*/
            service.setConfiguration(cfg);
        } catch (GkFunctionalException e) {
            LOG.log(e);
            GkDialog.openDialog(shell, e);
        }
    }

}

From source file:org.goko.controller.tinyg.handlers.TinyGConfigurationOpenHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) final Shell shell, ITinygControllerService service,
        IEclipseContext context) throws GkException {

    PreferenceManager manager = new PreferenceManager('/');
    TinyGConfiguration cfg = service.getConfiguration();
    manager.addToRoot(
            new PreferenceNode("org.goko.controller.tinyg.1.device", new TinyGConfigurationDevicePage(cfg)));
    manager.addToRoot(new PreferenceNode("org.goko.controller.tinyg.2.communication",
            new TinyGConfigurationCommunicationPage(cfg)));
    manager.addToRoot(new PreferenceNode("org.goko.controller.tinyg.3.defaultgcode",
            new TinyGConfigurationGCodeDefaultPage(cfg)));
    manager.addToRoot(/*  w ww.ja va2s . c  o m*/
            new PreferenceNode("org.goko.controller.tinyg.4.motion", new TinyGConfigurationMotionPage(cfg)));
    manager.addToRoot(new PreferenceNode("org.goko.controller.tinyg.5.motorMapping",
            new TinyGConfigurationMotorMappingPage(cfg)));
    manager.addTo("org.goko.controller.tinyg.5.motorMapping",
            new PreferenceNode("org.goko.controller.tinyg.5.a.motor1",
                    new TinyGConfigurationMotorPage(cfg, "Motor 1", TinyGConfiguration.MOTOR_1_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.5.motorMapping",
            new PreferenceNode("org.goko.controller.tinyg.5.b.motor2",
                    new TinyGConfigurationMotorPage(cfg, "Motor 2", TinyGConfiguration.MOTOR_2_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.5.motorMapping",
            new PreferenceNode("org.goko.controller.tinyg.5.c.motor3",
                    new TinyGConfigurationMotorPage(cfg, "Motor 3", TinyGConfiguration.MOTOR_3_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.5.motorMapping",
            new PreferenceNode("org.goko.controller.tinyg.5.d.motor4",
                    new TinyGConfigurationMotorPage(cfg, "Motor 4", TinyGConfiguration.MOTOR_4_SETTINGS)));
    manager.addToRoot(
            new PreferenceNode("org.goko.controller.tinyg.6.axis", new TinyGConfigurationAxisMainPage(cfg)));
    manager.addTo("org.goko.controller.tinyg.6.axis", new PreferenceNode("org.goko.controller.tinyg.6.a.xaxis",
            new TinyGConfigurationAxisPage(cfg, "X Axis", TinyGConfiguration.X_AXIS_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.6.axis", new PreferenceNode("org.goko.controller.tinyg.6.b.yaxis",
            new TinyGConfigurationAxisPage(cfg, "Y Axis", TinyGConfiguration.Y_AXIS_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.6.axis", new PreferenceNode("org.goko.controller.tinyg.6.c.zaxis",
            new TinyGConfigurationAxisPage(cfg, "Z Axis", TinyGConfiguration.Z_AXIS_SETTINGS)));
    manager.addTo("org.goko.controller.tinyg.6.axis", new PreferenceNode("org.goko.controller.tinyg.6.d.aaxis",
            new TinyGConfigurationAxisPage(cfg, "A Axis", TinyGConfiguration.A_AXIS_SETTINGS)));

    PreferenceDialog dialog = new PreferenceDialog(shell, manager);

    int result = dialog.open();

    if (result == Dialog.OK) {
        try {
            service.updateConfiguration(cfg);
        } catch (GkFunctionalException e) {
            LOG.log(e);
            GkDialog.openDialog(shell, e);
        }
    }

}

From source file:org.goko.tinyg.handlers.TinyGConfigurationOpenHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, ITinygControllerService service,
        IEclipseContext context) throws GkException {
    PreferenceManager manager = new PreferenceManager('/');
    TinyGConfiguration cfg = service.getConfiguration();
    manager.addToRoot(new PreferenceNode("org.goko.tinyg.1.device", new TinyGConfigurationDevicePage(cfg)));
    manager.addToRoot(/*w  ww . j av a2  s.  co  m*/
            new PreferenceNode("org.goko.tinyg.2.communication", new TinyGConfigurationCommunicationPage(cfg)));
    manager.addToRoot(
            new PreferenceNode("org.goko.tinyg.3.defaultgcode", new TinyGConfigurationGCodeDefaultPage(cfg)));
    manager.addToRoot(new PreferenceNode("org.goko.tinyg.4.motion", new TinyGConfigurationMotionPage(cfg)));
    manager.addToRoot(
            new PreferenceNode("org.goko.tinyg.5.motorMapping", new TinyGConfigurationMotorMappingPage(cfg)));
    manager.addTo("org.goko.tinyg.5.motorMapping", new PreferenceNode("org.goko.tinyg.5.a.motor1",
            new TinyGConfigurationMotorPage(cfg, "Motor 1", TinyGConfiguration.MOTOR_1_SETTINGS)));
    manager.addTo("org.goko.tinyg.5.motorMapping", new PreferenceNode("org.goko.tinyg.5.b.motor2",
            new TinyGConfigurationMotorPage(cfg, "Motor 2", TinyGConfiguration.MOTOR_2_SETTINGS)));
    manager.addTo("org.goko.tinyg.5.motorMapping", new PreferenceNode("org.goko.tinyg.5.c.motor3",
            new TinyGConfigurationMotorPage(cfg, "Motor 3", TinyGConfiguration.MOTOR_3_SETTINGS)));
    manager.addTo("org.goko.tinyg.5.motorMapping", new PreferenceNode("org.goko.tinyg.5.d.motor4",
            new TinyGConfigurationMotorPage(cfg, "Motor 4", TinyGConfiguration.MOTOR_4_SETTINGS)));
    manager.addToRoot(new PreferenceNode("org.goko.tinyg.6.axis", new TinyGConfigurationAxisMainPage(cfg)));
    manager.addTo("org.goko.tinyg.6.axis", new PreferenceNode("org.goko.tinyg.6.a.xaxis",
            new TinyGConfigurationAxisPage(cfg, "X Axis", TinyGConfiguration.X_AXIS_SETTINGS)));
    manager.addTo("org.goko.tinyg.6.axis", new PreferenceNode("org.goko.tinyg.6.b.yaxis",
            new TinyGConfigurationAxisPage(cfg, "Y Axis", TinyGConfiguration.Y_AXIS_SETTINGS)));
    manager.addTo("org.goko.tinyg.6.axis", new PreferenceNode("org.goko.tinyg.6.c.zaxis",
            new TinyGConfigurationAxisPage(cfg, "Z Axis", TinyGConfiguration.Z_AXIS_SETTINGS)));
    manager.addTo("org.goko.tinyg.6.axis", new PreferenceNode("org.goko.tinyg.6.d.aaxis",
            new TinyGConfigurationAxisPage(cfg, "A Axis", TinyGConfiguration.A_AXIS_SETTINGS)));

    PreferenceDialog dialog = new PreferenceDialog(shell, manager);

    dialog.open();
}

From source file:org.gradle.eclipse.preferences.FieldEditorOverlayPage.java

License:Apache License

protected 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(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        public void run() {
            dialog.create();//w w  w. ja  v a 2  s .  c o  m
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.infoglue.igide.helper.Utils.java

License:Open Source License

public static int showPrefs(String desc) {
    desc = "There was an error connecting to CMS\n\n" + desc + "\n\n";

    PreferenceManager p = new PreferenceManager();

    PreferenceNode node = new PreferenceNode("org.infoglue.igide.preferences.InfogluePreferencePage",
            new InfogluePreferencePage());
    node.getPage().setTitle("Infoglue Connection");
    node.getPage().setDescription(desc);
    p.addToRoot(node);
    PreferenceDialog dia = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), p);
    dia.setBlockOnOpen(true);//from  w  ww .ja v  a 2s.  com
    dia.open();
    return dia.getReturnCode();
}

From source file:org.jboss.ide.eclipse.as.wtp.ui.composites.AbstractJREComposite.java

License:Open Source License

protected boolean showPreferencePage(String pageId) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find(pageId);
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(getShell(), manager2);
    dialog.setSelectedNode(pageId);//w w  w  .j av a2 s  . c  om
    dialog.create();
    dialog.setMessage(node.getLabelText());
    return (dialog.open() == Window.OK);
}

From source file:org.jsweet.plugin.preferences.FieldEditorProjectPreferencePage.java

License:Apache License

private void configureWorkspaceSettings() {
    String preferenceNodeId = this.getPreferenceNodeId();
    IPreferencePage preferencePage = newPreferencePage();
    final IPreferenceNode preferenceNode = new PreferenceNode(preferenceNodeId, preferencePage);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(preferenceNode);
    final PreferenceDialog dialog = new PreferenceDialog(this.getControl().getShell(), manager);
    BusyIndicator.showWhile(this.getControl().getDisplay(), new Runnable() {
        @Override//from  w w  w .  j a  va2s .c  o  m
        public void run() {
            dialog.create();
            dialog.setMessage(preferenceNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.mailster.gui.prefs.ConfigurationDialog.java

License:Open Source License

/**
 * Creates the preference tree structure.
 * /*from  w  ww . jav a 2s.  c  om*/
 * @param mgr the <code>PreferenceManager</code> that the <code>PreferenceNode</code>s
 * should be embedded in
 */
private static void createPreferenceTree(PreferenceManager mgr) {
    /* Create the nodes representing the single preference pages */
    ExtendedPreferenceNode generalNode = new ExtendedPreferenceNode(ConfigurationManager.GENERAL_OPTIONS_KEY,
            Messages.getString("generalConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/generalConfig16.png"),
            GeneralConfigurationPage.class.getName());

    ExtendedPreferenceNode languageNode = new ExtendedPreferenceNode(ConfigurationManager.LANGUAGE_OPTIONS_KEY,
            Messages.getString("languageConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/languageConfig16.png"),
            LanguageConfigurationPage.class.getName());

    ExtendedPreferenceNode trayNode = new ExtendedPreferenceNode(ConfigurationManager.TRAY_OPTIONS_KEY,
            Messages.getString("trayConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/trayConfig16.png"), TrayConfigurationPage.class.getName());

    ExtendedPreferenceNode smtpNode = new ExtendedPreferenceNode(ConfigurationManager.SMTP_OPTIONS_KEY,
            Messages.getString("smtpConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/proxyConfig16.png"), SMTPConfigurationPage.class.getName());

    ExtendedPreferenceNode pop3Node = new ExtendedPreferenceNode(ConfigurationManager.POP3_OPTIONS_KEY,
            Messages.getString("pop3ConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/proxyConfig16.png"), POP3ConfigurationPage.class.getName());

    ExtendedPreferenceNode connectionNode = new ExtendedPreferenceNode(
            ConfigurationManager.PROTOCOLS_OPTIONS_KEY, Messages.getString("protocolsConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/connectionConfig16.png"),
            ProtocolsConfigurationPage.class.getName());

    ExtendedPreferenceNode enclosuresNode = new ExtendedPreferenceNode(
            ConfigurationManager.ENCLOSURES_OPTIONS_KEY, Messages.getString("enclosuresConfigurationPageTitle"),
            SWTHelper.getImageDescriptor("wizard/enclosureConfig16.png"),
            EnclosuresConfigurationPage.class.getName());

    /* Add the nodes to the PreferenceManager */
    mgr.addToRoot(generalNode);
    generalNode.add(trayNode);
    generalNode.add(languageNode);

    mgr.addToRoot(enclosuresNode);

    mgr.addToRoot(connectionNode);
    connectionNode.add(smtpNode);
    connectionNode.add(pop3Node);
}

From source file:org.modelio.app.preferences.ModelioPreferenceDialog.java

License:Open Source License

@objid("70ca0447-23a9-4e48-a547-7763389cb376")
private static PreferenceManager configurePreferences(final IEclipseContext context,
        final IExtensionRegistry registry) {
    PreferenceManager pm = new PreferenceManager();
    IContributionFactory factory = context.get(IContributionFactory.class);

    for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREFS_PAGE_XP)) {
        if (!elmt.getName().equals(ELMT_PAGE)) {
            AppPreferences.LOG.warning("unexpected element: %s", elmt.getName());
            continue;
        } else if (isEmpty(elmt.getAttribute(ATTR_ID)) || isEmpty(elmt.getAttribute(ATTR_NAME))) {
            AppPreferences.LOG.warning("missing id and/or name: %s", elmt.getNamespaceIdentifier());
            continue;
        }//  www . jav  a 2  s.  com
        PreferenceNode pn = null;
        if (elmt.getAttribute(ATTR_CLASS) != null) {
            IPreferencePage page = null;
            try {
                String prefPageURI = getClassURI(elmt.getNamespaceIdentifier(), elmt.getAttribute(ATTR_CLASS));
                Object object = factory.create(prefPageURI, context);
                if (!(object instanceof IPreferencePage)) {
                    AppPreferences.LOG.error("Expected instance of IPreferencePage: %s",
                            elmt.getAttribute(ATTR_CLASS));
                    continue;
                }
                page = (IPreferencePage) object;
            } catch (ClassNotFoundException e) {
                AppPreferences.LOG.error(e);
                continue;
            }
            ContextInjectionFactory.inject(page, context);
            if ((page.getTitle() == null || page.getTitle().isEmpty())
                    && elmt.getAttribute(ATTR_NAME) != null) {
                page.setTitle(elmt.getAttribute(ATTR_NAME));
            }
            pn = new PreferenceNode(elmt.getAttribute(ATTR_ID), page);
        } else {
            // FIXME phv EmptyPreferencePage class would bring in an e3 plugin
            // pn = new PreferenceNode(elmt.getAttribute(ATTR_ID),
            // new EmptyPreferencePage(elmt.getAttribute(ATTR_NAME)));
        }
        if (isEmpty(elmt.getAttribute(ATTR_CATEGORY))) {
            pm.addToRoot(pn);
        } else {
            IPreferenceNode parent = findNode(pm, elmt.getAttribute(ATTR_CATEGORY));
            if (parent == null) {
                pm.addToRoot(pn);
            } else {
                parent.add(pn);
            }
        }
    }
    return pm;
}

From source file:org.multicore_association.shim.edit.actions.PreferencesAction.java

License:MIT License

/**
 * @see org.eclipse.jface.action.Action#run()
 *//*from  w w  w .jav a  2  s  .com*/
@Override
public void run() {
    // Set pages to PreferenceManager.
    final PreferenceManager pm = new PreferenceManager();

    final ComponentsPreferencePage page1 = new ComponentsPreferencePage();
    PreferenceNode pnode1 = new PreferenceNode(page1.getTitle());
    pnode1.setPage(page1);
    pm.addToRoot(pnode1);

    MasterComponentPreferencePage page2 = new MasterComponentPreferencePage();
    PreferenceNode pnode2 = new PreferenceNode(page2.getTitle());
    pnode2.setPage(page2);
    pm.addTo(page1.getTitle(), pnode2);

    SlaveComponentPreferencePage page3 = new SlaveComponentPreferencePage();
    PreferenceNode pnode3 = new PreferenceNode(page3.getTitle());
    pnode3.setPage(page3);
    pm.addTo(page1.getTitle(), pnode3);

    ComponentSetPreferencePage page4 = new ComponentSetPreferencePage();
    PreferenceNode pnode4 = new PreferenceNode(page4.getTitle());
    pnode4.setPage(page4);
    pm.addTo(page1.getTitle(), pnode4);

    AddressSpacePreferencePage page5 = new AddressSpacePreferencePage();
    PreferenceNode pnode5 = new PreferenceNode(page5.getTitle());
    pnode5.setPage(page5);
    pm.addToRoot(pnode5);

    CommunicationSetPreferencePage page6 = new CommunicationSetPreferencePage();
    PreferenceNode pnode6 = new PreferenceNode(page6.getTitle());
    pnode6.setPage(page6);
    pm.addToRoot(pnode6);

    CachePreferencePage page7 = new CachePreferencePage();
    PreferenceNode pnode7 = new PreferenceNode(page7.getTitle());
    pnode7.setPage(page7);
    pm.addToRoot(pnode7);

    AccessTypePreferencePage page8 = new AccessTypePreferencePage();
    PreferenceNode pnode8 = new PreferenceNode(page8.getTitle());
    pnode8.setPage(page8);
    pm.addToRoot(pnode8);

    PerformancePreferencePage page9 = new PerformancePreferencePage();
    PreferenceNode pnode9 = new PreferenceNode(page9.getTitle());
    pnode9.setPage(page9);
    pm.addToRoot(pnode9);

    LatencyPreferencePage page10 = new LatencyPreferencePage();
    PreferenceNode pnode10 = new PreferenceNode(page10.getTitle());
    pnode10.setPage(page10);
    pm.addTo(page9.getTitle(), pnode10);

    PitchPreferencePage page11 = new PitchPreferencePage();
    PreferenceNode pnode11 = new PreferenceNode(page11.getTitle());
    pnode11.setPage(page11);
    pm.addTo(page9.getTitle(), pnode11);

    WizardInputPreferencePage page00 = new WizardInputPreferencePage();
    PreferenceNode pnode00 = new PreferenceNode(page00.getTitle());
    pnode00.setPage(page00);
    pm.addToRoot(pnode00);

    // starts the wizard.
    final Display display = Display.getDefault();

    Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {

        /**
         * @see java.lang.Runnable#run()
         */
        @Override
        public void run() {
            final PreferenceDialog dialog = new PreferenceDialog(display.getActiveShell(), pm);
            dialog.setSelectedNode(page1.getTitle());
            dialog.setMinimumPageSize(640, 480);

            // if you want to expand PreferenceDialog's TreeViewer, 
            // call 'create' method.
            dialog.create();
            dialog.getTreeViewer().expandAll();

            dialog.open();
        }
    });
}