List of usage examples for org.eclipse.jface.preference PreferencePage getTitle
@Override
public String getTitle()
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 w w .j a va 2s . c om 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; }//ww w . jav 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.nsn.squirrel.preferences.internal.E4PreferenceRegistry.java
License:Open Source License
private void setPreferenceStore(String bundleId, PreferencePage page) { // Affect preference store to this page if this is a // PreferencePage, else, must manage it internally // Set the issue#1 on github : // https://github.com/opcoach/e4Preferences/issues/1 // And manage the extensions of IP initialisePreferenceStoreProviders(); IPreferenceStore store = null;//from ww w . j a v a2s . co m // Get the preference store according to policy. Object data = psProviders.get(bundleId); if (data != null) { if (data instanceof IPreferenceStore) store = (IPreferenceStore) data; else if (data instanceof IPreferenceStoreProvider) store = ((IPreferenceStoreProvider) data).getPreferenceStore(); else if (data instanceof String) store = (IPreferenceStore) context.get((String) data); } else { // Default behavior : create a preference store for this bundle and // remember of it store = new ScopedPreferenceStore(InstanceScope.INSTANCE, bundleId); psProviders.put(bundleId, store); } if (store != null) page.setPreferenceStore(store); else { logger.warn("Unable to set the preferenceStore for page " + page.getTitle() + " defined in bundle " + bundleId); } }
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; }/*from w ww . ja va 2s . com*/ 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
private void setPreferenceStore(String bundleId, PreferencePage page) { // Affect preference store to this page if this is a // PreferencePage, else, must manage it internally // Set the issue#1 on github : // https://github.com/opcoach/e4Preferences/issues/1 // And manage the extensions of IP initialisePreferenceStoreProviders(); IPreferenceStore store = null;/* w ww. ja va 2s . c o m*/ // Get the preference store according to policy. Object data = psProviders.get(bundleId); if (data != null) { if (data instanceof IPreferenceStore) store = (IPreferenceStore) data; else if (data instanceof IPreferenceStoreProvider) store = ((IPreferenceStoreProvider) data).getPreferenceStore(); else if (data instanceof String) store = (IPreferenceStore) context.get((String) data); } else { // Default behavior : create a preference store for this bundle and remember of it store = new ScopedPreferenceStore(InstanceScope.INSTANCE, bundleId); psProviders.put(bundleId, store); } if (store != null) page.setPreferenceStore(store); else { logger.warn("Unable to set the preferenceStore for page " + page.getTitle() + " defined in bundle " + bundleId); } }
From source file:com.programmablefun.ide.App.java
License:Open Source License
private void showPreferences() { PreferencePage pages[] = new PreferencePage[] { new RepositoryPrefPage(codeRepository), new ColorSchemePrefPage(stylesheetRepository, wellKnownWords), }; PreferenceManager mgr = new PreferenceManager(); for (PreferencePage p : pages) { mgr.addToRoot(new PreferenceNode(p.getTitle(), p)); }/*from w ww .j a va 2s .c om*/ PreferenceDialog dlg = new PreferenceDialog(Display.getCurrent().getActiveShell(), mgr); if (dlg.open() == Window.OK) { sourceCodeComposite.setStylesheet(stylesheetRepository.get(settings.getSelectedStylesheet())); settings.save(); } }
From source file:org.eclipse.team.internal.ui.dialogs.PreferencePageContainerDialog.java
License:Open Source License
private void createMultiplePageArea(Composite composite) { // create a tab folder for the page tabFolder = new TabFolder(composite, SWT.NONE); tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); for (int i = 0; i < pages.length; i++) { PreferencePage page = pages[i]; // text decoration options TabItem tabItem = new TabItem(tabFolder, SWT.NONE); tabItem.setText(page.getTitle());// tabItem.setControl(createPageArea(tabFolder, page)); pageMap.put(tabItem, page);//from w ww.j av a 2 s .co m } tabFolder.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updatePageSelection(); } }); updatePageSelection(); }
From source file:org.jboss.tools.common.model.ui.preferences.TabbedPreferencesPage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { this.noDefaultAndApplyButton(); TabFolder tabbedComposite = new TabFolder(parent, SWT.NULL); tabbedComposite.setBackground(parent.getBackground()); for (Iterator iter = pageList.iterator(); iter.hasNext();) { PreferencePage element = (PreferencePage) iter.next(); TabItem newTab = new TabItem(tabbedComposite, SWT.NULL); element.createControl(tabbedComposite); if (element instanceof XMOBasedPreferencesPage) ((XMOBasedPreferencesPage) element).initPageProperties(); newTab.setControl(element.getControl()); newTab.setText(element.getTitle()); }/* w ww . ja v a2 s .com*/ return tabbedComposite; }
From source file:org.jboss.tools.common.model.ui.preferences.TabbedPreferencesPage.java
License:Open Source License
public void addPreferencePage(PreferencePage page) { pageList.add(page);//from w w w. j a v a 2s . c o m if (page instanceof XMOBasedPreferencesPage) { // XMOBasedPreferencesPage xPage = (XMOBasedPreferencesPage)page; map.put(page.getTitle(), page); } }