List of usage examples for org.eclipse.jface.preference PreferenceNode add
@Override
public void add(IPreferenceNode node)
From source file:com.persistent.util.WAEclipseHelper.java
License:Open Source License
/** * Method creates tree structure of azure property pages. and opens property * dialog with desired property page selected & active. * /*ww w .j a va 2s . c om*/ * @param windowsAzureRole * : worker role * @param pageToDisplay * : property page Id which should be active after opening dialog * @param tabToSelect : In case pageToDisplay is Server Configuration page then * provide tab which should be selected. * @return integer */ public static int openRolePropertyDialog(WindowsAzureRole windowsAzureRole, String pageToDisplay, String tabToSelect) { int retVal = Window.CANCEL; // value corresponding to cancel try { // Node creation PreferenceNode nodeGeneral = new PreferenceNode(Messages.cmhIdGeneral, Messages.cmhLblGeneral, null, WARGeneral.class.toString()); nodeGeneral.setPage(new WARGeneral()); nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral); PreferenceNode nodeCache = new PreferenceNode(Messages.cmhIdCach, Messages.cmhLblCach, null, WARCaching.class.toString()); nodeCache.setPage(new WARCaching()); nodeCache.getPage().setTitle(Messages.cmhLblCach); PreferenceNode nodeCert = new PreferenceNode(Messages.cmhIdCert, Messages.cmhLblCert, null, WARCertificates.class.toString()); nodeCert.setPage(new WARCertificates()); nodeCert.getPage().setTitle(Messages.cmhLblCert); PreferenceNode nodeCmpnts = new PreferenceNode(Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null, WARComponents.class.toString()); nodeCmpnts.setPage(new WARComponents()); nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts); PreferenceNode nodeDebugging = new PreferenceNode(Messages.cmhIdDbg, Messages.cmhLblDbg, null, WARDebugging.class.toString()); nodeDebugging.setPage(new WARDebugging()); nodeDebugging.getPage().setTitle(Messages.cmhLblDbg); PreferenceNode nodeEndPts = new PreferenceNode(Messages.cmhIdEndPts, Messages.cmhLblEndPts, null, WAREndpoints.class.toString()); nodeEndPts.setPage(new WAREndpoints()); nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts); PreferenceNode nodeEnvVars = new PreferenceNode(Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null, WAREnvVars.class.toString()); nodeEnvVars.setPage(new WAREnvVars()); nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars); PreferenceNode nodeLdBlnc = new PreferenceNode(Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null, WARLoadBalance.class.toString()); nodeLdBlnc.setPage(new WARLoadBalance()); nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc); PreferenceNode nodeLclStg = new PreferenceNode(Messages.cmhIdLclStg, Messages.cmhLblLclStg, null, WARLocalStorage.class.toString()); nodeLclStg.setPage(new WARLocalStorage()); nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg); PreferenceNode nodeSrvCnfg = new PreferenceNode(Messages.cmhIdSrvCnfg, Messages.cmhLblSrvCnfg, null, WAServerConfiguration.class.toString()); nodeSrvCnfg.setPage(new WAServerConfiguration(tabToSelect)); nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg); PreferenceNode nodeSslOff = new PreferenceNode(Messages.cmhIdSsl, Messages.cmhLblSsl, null, WASSLOffloading.class.toString()); nodeSslOff.setPage(new WASSLOffloading()); nodeSslOff.getPage().setTitle(Messages.cmhLblSsl); /* * Tree structure creation. Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeGeneral.add(nodeCache); nodeGeneral.add(nodeCert); nodeGeneral.add(nodeCmpnts); nodeGeneral.add(nodeDebugging); nodeGeneral.add(nodeEndPts); nodeGeneral.add(nodeEnvVars); nodeGeneral.add(nodeLdBlnc); nodeGeneral.add(nodeLclStg); nodeGeneral.add(nodeSrvCnfg); nodeGeneral.add(nodeSslOff); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeGeneral); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, windowsAzureRole.getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception ex) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex); } return retVal; }
From source file:com.persistent.util.WAEclipseHelper.java
License:Open Source License
/** * Method creates tree structure of azure deployment project property pages. * and opens property dialog with desired property page selected & active. * /*from ww w .ja v a 2 s . c om*/ * @param pageToDisplay * : property page Id which should be active after opening dialog * @return integer */ public static int openWAProjectPropertyDialog(String pageToDisplay) { int retVal = Window.CANCEL; // value corresponding to cancel // Node creation try { PreferenceNode nodeWindowsAzure = new PreferenceNode(Messages.cmhIdWinAz, Messages.cmhLblWinAz, null, WAWinAzurePropertyPage.class.toString()); nodeWindowsAzure.setPage(new WAWinAzurePropertyPage()); nodeWindowsAzure.getPage().setTitle(Messages.cmhLblWinAz); PreferenceNode nodeRemoteAcess = new PreferenceNode(Messages.cmhIdRmtAces, Messages.cmhLblRmtAces, null, WARemoteAccessPropertyPage.class.toString()); nodeRemoteAcess.setPage(new WARemoteAccessPropertyPage()); nodeRemoteAcess.getPage().setTitle(Messages.cmhLblRmtAces); PreferenceNode nodeRoles = new PreferenceNode(Messages.cmhIdRoles, Messages.cmhLblRoles, null, WARolesPropertyPage.class.toString()); nodeRoles.setPage(new WARolesPropertyPage()); nodeRoles.getPage().setTitle(Messages.cmhLblRoles); PreferenceNode nodeSubscriptions = new PreferenceNode(Messages.cmhIdCrdntls, Messages.cmhLblSubscrpt, null, SubscriptionPropertyPage.class.toString()); nodeSubscriptions.setPage(new SubscriptionPropertyPage()); nodeSubscriptions.getPage().setTitle(Messages.cmhLblSubscrpt); /* * Tree structure creation. Don't change order while adding nodes. * Its the default alphabetical order given by eclipse. */ nodeWindowsAzure.add(nodeRemoteAcess); nodeWindowsAzure.add(nodeRoles); nodeWindowsAzure.add(nodeSubscriptions); PreferenceManager mgr = new PreferenceManager(); mgr.addToRoot(nodeWindowsAzure); // Dialog creation PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr); // make desired property page active. dialog.setSelectedNode(pageToDisplay); dialog.create(); String dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName()); dialog.getShell().setText(dlgTitle); dialog.open(); // return whether user has pressed OK or Cancel button retVal = dialog.getReturnCode(); } catch (Exception e) { PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e); } return retVal; }
From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferenceDialog.java
License:Open Source License
private void addPreferenceNodesRecursive(final ClassTree classTree, final PreferenceNode parentPreferenceNode) { // ignore root of classTree, since it is the Plugin class if (classTree.clazz.getCanonicalName().equals(Plugin.class.getCanonicalName())) { for (final ClassTree ct : classTree.sons) { addPreferenceNodesRecursive(ct, parentPreferenceNode); }//www . j av a 2 s .co m return; } final CustomPreferenceNode preferenceNode; // add nodes for abstract and instantiable but not instantiated plugins preferenceNode = createTypePreferenceNode(classTree.clazz); parentPreferenceNode.add(preferenceNode); // add nodes for instantiated plugins for (final Plugin p : spyglass.getPluginManager().getPluginInstances(classTree.clazz, false)) { try { // add to parent tree node preferenceNode.add(createInstancePreferenceNode(p)); } catch (final Exception e) { log.error("An error occured while adding the preference page for plugin " + p + ". I'll ignore this plugin.", e); } } for (final ClassTree ct : classTree.sons) { addPreferenceNodesRecursive(ct, preferenceNode); } }
From source file:gov.nasa.ensemble.core.rcp.EnsembleWorkbenchWindowAdvisor.java
License:Open Source License
protected final void moveAdvancedPreferencesPages() { Collection<Pattern> patterns = new HashSet<Pattern>(); for (String s : getAdvancedPreferenceRegExp()) patterns.add(Pattern.compile(s)); if (patterns.size() == 0) return;/*from w w w . j ava 2 s. c o m*/ PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode[] rootSubNodes = manager.getRootSubNodes(); PreferenceNode advanced = null; Pattern advancePattern = Pattern.compile("AdvancedPreferenceNode"); for (IPreferenceNode node : rootSubNodes) { if (advancePattern.matcher(node.getId()).matches()) { advanced = (PreferenceNode) node; break; } } if (advanced == null) return; for (IPreferenceNode node : rootSubNodes) { for (Pattern pattern : patterns) { if (pattern.matcher(node.getId()).matches()) { manager.remove(node); advanced.add(node); continue; } } } }
From source file:gov.redhawk.internal.ui.port.nxmplot.view.PlotSettingsAction.java
License:Open Source License
@Override public void run() { PreferenceManager manager = new PreferenceManager(); if (pageBook.getSources().size() > 1) { PlotPreferencePage plotPage = new PlotPreferencePage("Plot", false); plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore()); PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage); manager.addToRoot(plotNode);//w w w . j a v a2 s. c o m for (PlotSource source : pageBook.getSources()) { List<INxmBlock> blockChain = pageBook.getBlockChain(source); String name = source.getInput().getName(); SourcePreferencePage sourcePrefPage = new SourcePreferencePage(name, pageBook, blockChain); PreferenceNode sourceNode = new PreferenceNode(source.toString(), sourcePrefPage); for (INxmBlock block : blockChain) { IPreferencePage page = block.createPreferencePage(); if (page != null) { PreferenceNode blockNode = new PreferenceNode(block.toString(), page); sourceNode.add(blockNode); } } manager.addToRoot(sourceNode); } } else if (pageBook.getSources().size() == 1) { PlotSource source = pageBook.getSources().get(0); List<INxmBlock> blockChain = pageBook.getBlockChain(source); PlotNxmBlock plotBlock = null; for (INxmBlock block : blockChain) { if (block instanceof PlotNxmBlock) { plotBlock = (PlotNxmBlock) block; } } PlotPreferencePage plotPage = new PlotPreferencePage("Plot"); plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore()); plotPage.setBlockPreferenceStore(pageBook.getSharedPlotBlockPreferences()); PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage); manager.addToRoot(plotNode); // String name = entry.getKey().getInput().getName(); // SourcePreferencePage sourcePrefPage = new SourcePreferencePage(name, PlotPageBook2.this); // PreferenceNode sourceNode = new PreferenceNode(entry.getKey().toString(), sourcePrefPage); // manager.addToRoot(sourceNode); for (INxmBlock block : blockChain) { if (plotBlock == block) { continue; } IPreferencePage page = block.createPreferencePage(); if (page != null) { PreferenceNode blockNode = new PreferenceNode(block.toString(), page); manager.addToRoot(blockNode); } } } else { PlotPreferencePage plotPage = new PlotPreferencePage("Plot"); plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore()); plotPage.setBlockPreferenceStore(pageBook.getSharedPlotBlockPreferences()); PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage); manager.addToRoot(plotNode); } PlotPreferenceDialog dialog = new PlotPreferenceDialog(pageBook.getShell(), manager); dialog.open(); }
From source file:net.mldonkey.g2gui.view.pref.Preferences.java
License:Open Source License
/** * @param preferenceStore where to store the values at *///from w w w .j a v a 2 s. c om public Preferences(PreferenceStore preferenceStore) { this.preferenceStore = preferenceStore; /* main page */ PreferencePage g2gui = new G2GuiPref("G2Gui", FieldEditorPreferencePage.GRID); g2gui.setPreferenceStore(preferenceStore); PreferenceNode g2GuiRootNode = new PreferenceNode("G2gui", g2gui); /* display page */ if (PreferenceLoader.loadBoolean("advancedMode")) { PreferencePage preferencePage = new G2GuiDisplay("Display", FieldEditorPreferencePage.GRID); preferencePage.setPreferenceStore(preferenceStore); PreferenceNode g2guiDisplayNode = new PreferenceNode("Display", preferencePage); preferencePage = new G2GuiDisplayConsole("Console", FieldEditorPreferencePage.GRID); preferencePage.setPreferenceStore(preferenceStore); g2guiDisplayNode.add(new PreferenceNode("Console", preferencePage)); preferencePage = new G2GuiDisplayDownloads("Downloads", FieldEditorPreferencePage.GRID); preferencePage.setPreferenceStore(preferenceStore); g2guiDisplayNode.add(new PreferenceNode("Downloads", preferencePage)); preferencePage = new G2GuiDisplayGraphs("Graphs", FieldEditorPreferencePage.GRID); preferencePage.setPreferenceStore(preferenceStore); g2guiDisplayNode.add(new PreferenceNode("Graphs", preferencePage)); g2GuiRootNode.add(g2guiDisplayNode); } /* advanced page */ PreferencePage preferencePage = new G2GuiAdvanced("Advanced", FieldEditorPreferencePage.GRID); preferencePage.setPreferenceStore(preferenceStore); g2GuiRootNode.add(new PreferenceNode("Advanced", preferencePage)); /* windows registry page */ String g2guiexe = System.getProperty("user.dir") + System.getProperty("file.separator") + "g2gui.exe"; if (VersionCheck.isWin32() && new File(g2guiexe).exists()) { preferencePage = new G2GuiWinReg("Windows Registry", FieldEditorPreferencePage.NONE); preferencePage.setPreferenceStore(preferenceStore); g2GuiRootNode.add(new PreferenceNode("Windows Registry", preferencePage)); } /* add all of this to the root node */ addToRoot(g2GuiRootNode); }
From source file:net.sourceforge.eclipsetrader.charts.dialogs.ChartSettingsDialog.java
License:Open Source License
public ChartSettingsDialog(Chart chart, Shell parentShell) { super(parentShell, new PreferenceManager()); this.chart = chart; generalPage = new GeneralPage(chart); PreferenceNode generalNode = new PreferenceNode("general", generalPage); //$NON-NLS-1$ getPreferenceManager().addToRoot(generalNode); for (int r = 0; r < chart.getRows().size(); r++) { ChartRow row = (ChartRow) chart.getRows().get(r); for (int t = 0; t < row.getTabs().size(); t++) { ChartTab tab = (ChartTab) row.getTabs().get(t); PreferenceNode tabNode = new PreferenceNode("tab" + t, new TabsPage(tab)); //$NON-NLS-1$ getPreferenceManager().addToRoot(tabNode); for (int i = 0; i < tab.getIndicators().size(); i++) { ChartIndicator indicator = (ChartIndicator) tab.getIndicators().get(i); Settings settings = new Settings(); for (Iterator iter = indicator.getParameters().keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); settings.set(key, (String) indicator.getParameters().get(key)); }/*from w w w . j av a 2 s . c om*/ IConfigurationElement plugin = getIndicatorPlugin(indicator.getPluginId()); IConfigurationElement[] members = plugin.getChildren("preferencePage"); //$NON-NLS-1$ if (members.length != 0) { PreferenceNode indicatorNode = null; IConfigurationElement item = members[0]; try { Object obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ indicatorNode = new PreferenceNode("indicator", page); //$NON-NLS-1$ tabNode.add(indicatorNode); } for (int p = 1; p < members.length; p++) { obj = item.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof IndicatorPluginPreferencePage) { ((IndicatorPluginPreferencePage) obj).setSettings(settings); IndicatorPage page = new IndicatorPage(indicator, (IndicatorPluginPreferencePage) obj); if (item.getAttribute("title") != null) //$NON-NLS-1$ page.setTitle(item.getAttribute("title")); //$NON-NLS-1$ PreferenceNode node = new PreferenceNode("prefs" + p, page); //$NON-NLS-1$ indicatorNode.add(node); } } } catch (Exception e) { e.printStackTrace(); } } } } } }
From source file:net.sourceforge.eclipsetrader.core.ui.preferences.SecurityPropertiesDialog.java
License:Open Source License
public SecurityPropertiesDialog(Security security, Shell parentShell) { super(parentShell, new PreferenceManager()); this.security = security; getPreferenceManager().addToRoot(new PreferenceNode("general", new GeneralPage())); //$NON-NLS-1$ PreferenceNode node = new PreferenceNode("feed", new PreferencePage("Feeds") { //$NON-NLS-1$ //$NON-NLS-2$ protected Control createContents(Composite parent) { noDefaultAndApplyButton();/*from w w w. j av a 2 s. c o m*/ return new Composite(parent, SWT.NONE); } }); getPreferenceManager().addToRoot(node); node.add(new PreferenceNode("quote", new QuoteFeedPage())); //$NON-NLS-1$ node.add(new PreferenceNode("level2", new Level2FeedPage())); //$NON-NLS-1$ node.add(new PreferenceNode("history", new HistoryFeedPage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("trading", new TradeSourcePage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("intraday", new DataCollectorPage())); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("dividends", new DividendsPage(security))); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("splits", new SplitsPage(security))); //$NON-NLS-1$ getPreferenceManager().addToRoot(new PreferenceNode("notes", new CommentsPage())); //$NON-NLS-1$ }
From source file:net.yatomiya.nicherry.ui.preference.NPreferenceDialog.java
License:Open Source License
static PreferenceManager createPreferenceManager() { PreferenceManager mgr = new PreferenceManager(); PreferenceNode node; mgr.addToRoot(new PreferenceNode("", new AppearancePage())); mgr.addToRoot(new PreferenceNode("?", new NetworkPage())); node = new PreferenceNode("BBS", new BBSPage()); node.add(new PreferenceNode("", new SiteViewPage())); node.add(new PreferenceNode("", new BoardViewPage())); node.add(new PreferenceNode("", new ThreadViewPage())); mgr.addToRoot(node);//w w w . j a va 2 s . c om mgr.addToRoot(new PreferenceNode("", new BBSFilterPage())); mgr.addToRoot(new PreferenceNode("", new ImagePage())); return mgr; }
From source file:org.eclipse.ui.internal.dialogs.PropertyPageContributorManager.java
License:Open Source License
/** * Given the object class, this method will find all the registered matching * contributors and sequentially invoke them to contribute to the property * page manager. Matching algorithm will also check subclasses and * implemented interfaces./*from ww w. j a v a 2 s. c o m*/ * * If object is an IStructuredSelection then attempt to match all the * contained objects. * * @param manager * @param object * @return true if contribution took place, false otherwise. */ public boolean contribute(PropertyPageManager manager, Object object) { Collection result = null; if (object instanceof IStructuredSelection) { Object[] objs = ((IStructuredSelection) object).toArray(); for (int i = 0; i < objs.length; i++) { List contribs = getContributors(objs[i]); if (result == null) result = new LinkedHashSet(contribs); else result.retainAll(contribs); } } else result = getContributors(object); if (result == null || result.size() == 0) { return false; } // Build the category nodes List catNodes = buildNodeList(result); Iterator resultIterator = catNodes.iterator(); // K(CategorizedPageNode) V(PreferenceNode - property page) Map catPageNodeToPages = new HashMap(); // Allow each contributor to add its page to the manager. boolean actualContributions = false; while (resultIterator.hasNext()) { CategorizedPageNode next = (CategorizedPageNode) resultIterator.next(); IPropertyPageContributor ppcont = next.contributor; if (!ppcont.isApplicableTo(object)) { continue; } PreferenceNode page = ppcont.contributePropertyPage(manager, object); if (page != null) { catPageNodeToPages.put(next, page); actualContributions = true; } } // Fixup the parents in each page if (actualContributions) { resultIterator = catNodes.iterator(); while (resultIterator.hasNext()) { CategorizedPageNode next = (CategorizedPageNode) resultIterator.next(); PreferenceNode child = (PreferenceNode) catPageNodeToPages.get(next); if (child == null) continue; PreferenceNode parent = null; if (next.parent != null) parent = (PreferenceNode) catPageNodeToPages.get(next.parent); if (parent == null) { manager.addToRoot(child); } else { parent.add(child); } } } return actualContributions; }