Example usage for org.eclipse.jface.preference PreferencePage setTitle

List of usage examples for org.eclipse.jface.preference PreferencePage setTitle

Introduction

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

Prototype

@Override
public void setTitle(String title) 

Source Link

Document

The PreferencePage implementation of this IDialogPage method extends the DialogPage implementation to update the preference page container title.

Usage

From source file:at.nucle.e4.plugin.preferences.core.internal.registry.PreferenceRegistry.java

License:Open Source License

public PreferenceManager createPages(PreferenceManager preferenceManager) {
    preferenceManager.removeAll();//from w  ww  .j av a2s.c o  m
    elements.values().forEach(element -> {
        PreferencePage page = null;
        if (element.getAttribute(ATTRIBUTE_CLASS) != null) {
            try {
                Object obj = element.createExecutableExtension(ATTRIBUTE_CLASS);
                if (obj instanceof PreferencePage) {
                    page = (PreferencePage) obj;

                    ContextInjectionFactory.inject(page, context);
                    if ((page.getTitle() == null || page.getTitle().isEmpty())
                            && element.getAttribute(ATTRIBUTE_TITLE) != null) {
                        page.setTitle(element.getAttribute(ATTRIBUTE_TITLE));
                    }

                    setPreferenceStore(page, element.getNamespaceIdentifier());
                    String category = element.getAttribute(ATTRIBUTE_CATEGORY);
                    if (category != null) {
                        preferenceManager.addTo(category,
                                new PreferenceNode(element.getAttribute(ATTRIBUTE_ID), page));
                    } else {
                        preferenceManager
                                .addToRoot(new PreferenceNode(element.getAttribute(ATTRIBUTE_ID), page));
                    }
                } else {
                    System.out.println(TAG + " Object must extend FieldEditorPreferencePage or PreferencePage");
                }
            } catch (CoreException exception) {
                exception.printStackTrace();
            }
        } else {
            System.out.println(TAG + " Attribute class may not be null");
        }
    });
    return preferenceManager;
}

From source file:com.nsn.squirrel.preferences.internal.E4PreferenceRegistry.java

License:Open Source License

public PreferenceManager getPreferenceManager() {

    // Remember of the unbounded nodes to order parent pages.
    // Map<category, list of children> (all nodes except root nodes)
    Map<String, Collection<IPreferenceNode>> childrenNodes = new HashMap<String, Collection<IPreferenceNode>>();
    if (pm != null)
        return pm;
    pm = new PreferenceManager();
    IContributionFactory factory = context.get(IContributionFactory.class);
    for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREFS_PAGE_XP)) {
        String bundleId = elmt.getNamespaceIdentifier();
        if (!elmt.getName().equals(ELMT_PAGE)) {
            logger.warn("unexpected element: {0}", elmt.getName());
            continue;
        } else if (isEmpty(elmt.getAttribute(ATTR_ID)) || isEmpty(elmt.getAttribute(ATTR_NAME))) {
            logger.warn("missing id and/or name: {}", bundleId);
            continue;
        }//from  w  w  w. ja v a 2 s. c  o  m
        PreferenceNode pn = null;
        if (elmt.getAttribute(ATTR_CLASS) != null) {
            PreferencePage page = null;
            try {
                String prefPageURI = getClassURI(bundleId, elmt.getAttribute(ATTR_CLASS));
                Object object = factory.create(prefPageURI, context);
                if (!(object instanceof PreferencePage)) {
                    logger.error("Expected instance of PreferencePage: {0}", elmt.getAttribute(ATTR_CLASS));
                    continue;
                }
                page = (PreferencePage) object;
                setPreferenceStore(bundleId, page);
            } catch (ClassNotFoundException e) {
                logger.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 {
            pn = new PreferenceNode(elmt.getAttribute(ATTR_ID),
                    new EmptyPreferencePage(elmt.getAttribute(ATTR_NAME)));
        }
        // Issue 2 : Fix bug on order (see :
        // https://github.com/opcoach/e4Preferences/issues/2)
        // Add only pages at root level and remember of child pages for
        // categories
        String category = elmt.getAttribute(ATTR_CATEGORY);
        if (isEmpty(category)) {
            pm.addToRoot(pn);
        } else {
            /*
             * IPreferenceNode parent = findNode(pm, category); if (parent
             * == null) { // No parent found, but may be the extension has
             * not been read yet. So remember of it unboundedNodes.put(pn,
             * category); } else { parent.add(pn); }
             */
            // Check if this category is already registered.
            Collection<IPreferenceNode> children = childrenNodes.get(category);
            if (children == null) {
                children = new ArrayList<IPreferenceNode>();
                childrenNodes.put(category, children);
            }
            children.add(pn);
        }
    }
    // Must now bind pages that has not been added in nodes (depends on the
    // preference page read order)
    // Iterate on all possible categories
    Collection<String> categoriesDone = new ArrayList<String>();
    while (!childrenNodes.isEmpty()) {
        for (String cat : Collections.unmodifiableSet(childrenNodes.keySet())) {
            // Is this category already in preference manager ? If not add
            // it later...
            IPreferenceNode parent = findNode(pm, cat);
            if (parent != null) {
                // Can add the list of children to this parent page...
                for (IPreferenceNode pn : childrenNodes.get(cat)) {
                    parent.add(pn);
                }
                // Ok This parent page is done. Can remove it from map
                // outside of this loop
                categoriesDone.add(cat);
            }
        }
        for (String keyToRemove : categoriesDone)
            childrenNodes.remove(keyToRemove);
        categoriesDone.clear();
    }
    return pm;
}

From source file:com.opcoach.e4.preferences.internal.E4PreferenceRegistry.java

License:Open Source License

public PreferenceManager getPreferenceManager() {

    // Remember of the unbounded nodes to order parent pages.
    // Map<category, list of children> (all nodes except root nodes)
    Map<String, Collection<IPreferenceNode>> childrenNodes = new HashMap<String, Collection<IPreferenceNode>>();

    if (pm != null)
        return pm;

    pm = new PreferenceManager();
    IContributionFactory factory = context.get(IContributionFactory.class);

    for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREFS_PAGE_XP)) {
        String bundleId = elmt.getNamespaceIdentifier();
        if (!elmt.getName().equals(ELMT_PAGE)) {
            logger.warn("unexpected element: {0}", elmt.getName());
            continue;
        } else if (isEmpty(elmt.getAttribute(ATTR_ID)) || isEmpty(elmt.getAttribute(ATTR_NAME))) {
            logger.warn("missing id and/or name: {}", bundleId);
            continue;
        }/*  www. j av  a 2 s.  c  o m*/
        PreferenceNode pn = null;
        if (elmt.getAttribute(ATTR_CLASS) != null) {
            PreferencePage page = null;
            try {
                String prefPageURI = getClassURI(bundleId, elmt.getAttribute(ATTR_CLASS));
                Object object = factory.create(prefPageURI, context);
                if (!(object instanceof PreferencePage)) {
                    logger.error("Expected instance of PreferencePage: {0}", elmt.getAttribute(ATTR_CLASS));
                    continue;
                }
                page = (PreferencePage) object;
                setPreferenceStore(bundleId, page);

            } catch (ClassNotFoundException e) {
                logger.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 {
            pn = new PreferenceNode(elmt.getAttribute(ATTR_ID),
                    new EmptyPreferencePage(elmt.getAttribute(ATTR_NAME)));
        }

        // Issue 2 : Fix bug on order (see :
        // https://github.com/opcoach/e4Preferences/issues/2)
        // Add only pages at root level and remember of child pages for
        // categories
        String category = elmt.getAttribute(ATTR_CATEGORY);
        if (isEmpty(category)) {
            pm.addToRoot(pn);
        } else {
            /*
             * IPreferenceNode parent = findNode(pm, category); if (parent
             * == null) { // No parent found, but may be the extension has
             * not been read yet. So remember of it unboundedNodes.put(pn,
             * category); } else { parent.add(pn); }
             */
            // Check if this category is already registered.
            Collection<IPreferenceNode> children = childrenNodes.get(category);
            if (children == null) {
                children = new ArrayList<IPreferenceNode>();
                childrenNodes.put(category, children);
            }
            children.add(pn);
        }
    }

    // Must now bind pages that has not been added in nodes (depends on the
    // preference page read order)
    // Iterate on all possible categories
    Collection<String> categoriesDone = new ArrayList<String>();

    while (!childrenNodes.isEmpty()) {
        for (String cat : Collections.unmodifiableSet(childrenNodes.keySet())) {
            // Is this category already in preference manager ? If not add
            // it later...
            IPreferenceNode parent = findNode(pm, cat);
            if (parent != null) {
                // Can add the list of children to this parent page...
                for (IPreferenceNode pn : childrenNodes.get(cat)) {
                    parent.add(pn);
                }
                // Ok This parent page is done. Can remove it from map
                // outside of this loop
                categoriesDone.add(cat);
            }
        }

        for (String keyToRemove : categoriesDone)
            childrenNodes.remove(keyToRemove);
        categoriesDone.clear();

    }

    return pm;
}

From source file:net.sourceforge.eclipsetrader.trading.wizards.accounts.AccountSettingsDialog.java

License:Open Source License

public AccountSettingsDialog(Account account, Shell parentShell) {
    super(parentShell, new PreferenceManager());
    this.account = account;

    generalPage = new GeneralPage(account);
    getPreferenceManager().addToRoot(new PreferenceNode("general", generalPage));

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(CorePlugin.ACCOUNT_PROVIDERS_EXTENSION_POINT);
    if (extensionPoint != null) {
        IConfigurationElement[] members = extensionPoint.getConfigurationElements();
        for (int i = 0; i < members.length; i++) {
            if (members[i].getAttribute("id").equals(account.getPluginId())) //$NON-NLS-1$
            {/*www.j  av a 2  s  . com*/
                members = members[i].getChildren("preferencePage");
                for (int ii = 0; ii < members.length; ii++) {
                    try {
                        PreferencePage preferencePage = (PreferencePage) members[ii]
                                .createExecutableExtension("class");
                        if (members[ii].getAttribute("name") != null)
                            preferencePage.setTitle(members[ii].getAttribute("name"));
                        preferencePage.setPreferenceStore(account.getPreferenceStore());
                        getPreferenceManager()
                                .addToRoot(new PreferenceNode("page" + String.valueOf(ii), preferencePage));
                    } catch (Exception e) {
                        CorePlugin.logException(e);
                    }
                }
                break;
            }
        }
    }
}

From source file:net.sourceforge.eclipsetrader.trading.wizards.systems.TradingSystemSettingsDialog.java

License:Open Source License

public TradingSystemSettingsDialog(TradingSystem system, Shell parentShell) {
    super(parentShell, new PreferenceManager());
    this.system = system;

    baseParameters = new BaseParametersPage() {
        public void createControl(Composite parent) {
            super.createControl(parent);
            setAccount(TradingSystemSettingsDialog.this.system.getAccount());
            setSecurity(TradingSystemSettingsDialog.this.system.getSecurity());
            setMaxExposure(TradingSystemSettingsDialog.this.system.getMaxExposure());
            setMaxAmount(TradingSystemSettingsDialog.this.system.getMaxAmount());
            setMinAmount(TradingSystemSettingsDialog.this.system.getMinAmount());
        }/*from  w  w  w. j av a 2 s .c o m*/

        public void performFinish() {
            TradingSystemSettingsDialog.this.system.setAccount(baseParameters.getAccount());
            TradingSystemSettingsDialog.this.system.setSecurity(baseParameters.getSecurity());
            TradingSystemSettingsDialog.this.system.setMaxExposure(baseParameters.getMaxExposure());
            TradingSystemSettingsDialog.this.system.setMaxAmount(baseParameters.getMaxAmount());
            TradingSystemSettingsDialog.this.system.setMinAmount(baseParameters.getMinAmount());
        }
    };
    baseParameters.setPageComplete(true);

    getPreferenceManager().addToRoot(new PreferenceNode("base", new CommonDialogPage(baseParameters) {
        protected Control createContents(Composite parent) {
            Control control = super.createContents(parent);
            return control;
        }
    }));

    IConfigurationElement[] members = TradingPlugin.getTradingSystemPluginPreferencePages(system.getPluginId());
    try {
        for (int i = 0; i < members.length; i++) {
            final TradingSystemPluginPreferencePage preferencePage = (TradingSystemPluginPreferencePage) members[i]
                    .createExecutableExtension("class");
            preferencePage.init(system.getSecurity(), system.getParameters());
            PreferencePage page = new PreferencePage() {
                protected Control createContents(Composite parent) {
                    noDefaultAndApplyButton();

                    Control control = preferencePage.createContents(parent);
                    return control;
                }

                public boolean performOk() {
                    preferencePage.performOk();
                    TradingSystemSettingsDialog.this.system.getParameters()
                            .putAll(preferencePage.getParameters());
                    return super.performOk();
                }
            };
            page.setTitle(members[i].getAttribute("name"));
            getPreferenceManager().addToRoot(new PreferenceNode("plugin" + String.valueOf(i), page));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.talend.designer.maven.ui.setting.repository.node.RepositoryPreferenceNode.java

License:Open Source License

@Override
public void createPage() {
    PreferencePage page = createPreferencePage();
    if (imageDescriptor != null) {
        page.setImageDescriptor(imageDescriptor);
    } else {//from  www. j  a  va2s  . c o m
        Image labelImage = getLabelImage();
        if (labelImage != null) {
            page.setImageDescriptor(ImageDescriptor.createFromImageData(labelImage.getImageData()));
        }
    }
    if (page instanceof AbstractProjectSettingPage) {
        ((AbstractProjectSettingPage) page).setPrefNodeId(this.getId());
    }

    page.setTitle(getLabelText());
    this.setPage(page);
}