List of usage examples for org.eclipse.jface.preference PreferenceManager addTo
public boolean addTo(String path, IPreferenceNode node)
From source file:at.nucle.e4.plugin.preferences.core.internal.registry.PreferenceRegistry.java
License:Open Source License
public PreferenceManager createPages(PreferenceManager preferenceManager) { preferenceManager.removeAll();// w w w . j a va 2 s .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.nokia.traceviewer.view.TraceViewerView.java
License:Open Source License
public boolean openPreferencePage(TVPreferencePage TVpage) { boolean ret = false; PreferenceManager mgr = new PreferenceManager(); // Create general preference page IPreferencePage generalPage = new TraceViewerPreferencesPage(); generalPage.setTitle(TRACE_VIEWER_TITLE); IPreferenceNode generalNode = new PreferenceNode("1", generalPage); //$NON-NLS-1$ mgr.addToRoot(generalNode);// www . ja v a 2 s. c om // Create advanced preference page IPreferencePage advancedPage = new TraceViewerAdvancedPreferencesPage(); advancedPage.setTitle(Messages.getString("TraceViewerView.AdvancedPageTitle")); //$NON-NLS-1$ IPreferenceNode advancedNode = new PreferenceNode("2", advancedPage); //$NON-NLS-1$ mgr.addTo("1", advancedNode); //$NON-NLS-1$ // Create connection preference page IPreferencePage connectionPage = new TraceViewerConnectionPreferencesPage(); connectionPage.setTitle(Messages.getString("TraceViewerView.ConnectionPageTitle")); //$NON-NLS-1$ IPreferenceNode connectionNode = new PreferenceNode("3", connectionPage); //$NON-NLS-1$ mgr.addTo("1", connectionNode); //$NON-NLS-1$ PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr); dialog.create(); dialog.getTreeViewer().expandAll(); // Switch the page switch (TVpage) { case GENERAL: dialog.getTreeViewer().setSelection(new StructuredSelection(generalNode)); break; case ADVANCED: dialog.getTreeViewer().setSelection(new StructuredSelection(advancedNode)); break; case CONNECTION: dialog.getTreeViewer().setSelection(new StructuredSelection(connectionNode)); break; default: break; } // Open dialog and get return value int ok = dialog.open(); if (ok == Window.OK) { ret = true; } return ret; }
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(/*from w w w .j a va 2s. co m*/ 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( 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(/*from w w w. 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.multicore_association.shim.edit.actions.PreferencesAction.java
License:MIT License
/** * @see org.eclipse.jface.action.Action#run() *//*from w ww .j a va 2s. c o m*/ @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(); } }); }
From source file:org.swtchart.ext.InteractiveChart.java
License:Apache License
/** * Opens the properties dialog./*from w w w.j a v a 2 s.com*/ */ private void openPropertiesDialog() { PreferenceManager manager = new PreferenceManager(); final String chartTitle = "Chart"; PreferenceNode chartNode = new PreferenceNode(chartTitle); chartNode.setPage(new ChartPage(this, resources, chartTitle)); manager.addToRoot(chartNode); final String legendTitle = "Legend"; PreferenceNode legendNode = new PreferenceNode(legendTitle); legendNode.setPage(new LegendPage(this, resources, legendTitle)); manager.addTo(chartTitle, legendNode); final String xAxisTitle = "X Axis"; PreferenceNode xAxisNode = new PreferenceNode(xAxisTitle); xAxisNode.setPage(new AxisPage(this, resources, Direction.X, xAxisTitle)); manager.addTo(chartTitle, xAxisNode); final String gridTitle = "Grid"; PreferenceNode xGridNode = new PreferenceNode(gridTitle); xGridNode.setPage(new GridPage(this, resources, Direction.X, gridTitle)); manager.addTo(chartTitle + "." + xAxisTitle, xGridNode); final String tickTitle = "Tick"; PreferenceNode xTickNode = new PreferenceNode(tickTitle); xTickNode.setPage(new AxisTickPage(this, resources, Direction.X, tickTitle)); manager.addTo(chartTitle + "." + xAxisTitle, xTickNode); final String yAxisTitle = "Y Axis"; PreferenceNode yAxisNode = new PreferenceNode(yAxisTitle); yAxisNode.setPage(new AxisPage(this, resources, Direction.Y, yAxisTitle)); manager.addTo(chartTitle, yAxisNode); PreferenceNode yGridNode = new PreferenceNode(gridTitle); yGridNode.setPage(new GridPage(this, resources, Direction.Y, gridTitle)); manager.addTo(chartTitle + "." + yAxisTitle, yGridNode); PreferenceNode yTickNode = new PreferenceNode(tickTitle); yTickNode.setPage(new AxisTickPage(this, resources, Direction.Y, tickTitle)); manager.addTo(chartTitle + "." + yAxisTitle, yTickNode); final String seriesTitle = "Series"; PreferenceNode plotNode = new PreferenceNode(seriesTitle); plotNode.setPage(new SeriesPage(this, resources, seriesTitle)); manager.addTo(chartTitle, plotNode); final String labelTitle = "Label"; PreferenceNode labelNode = new PreferenceNode(labelTitle); labelNode.setPage(new SeriesLabelPage(this, resources, labelTitle)); manager.addTo(chartTitle + "." + seriesTitle, labelNode); PreferenceDialog dialog = new PreferenceDialog(getShell(), manager); dialog.create(); dialog.getShell().setText("Properties"); dialog.getTreeViewer().expandAll(); dialog.open(); }
From source file:raptor.pref.PreferenceUtils.java
License:BSD License
private static void create() { // Create the preference manager PreferenceManager mgr = new PreferenceManager('/'); mgr.addToRoot(new PreferenceNode("general", new GeneralPage())); mgr.addTo("general", new PreferenceNode("window", new RaptorWindowPage())); mgr.addToRoot(new PreferenceNode("bughouse", new BughousePage())); mgr.addTo("bughouse", new PreferenceNode("buttons", new ActionContainerPage(local.getString("prefUtil1"), local.getString("prefUtil2"), RaptorActionContainer.BugButtons))); mgr.addToRoot(new PreferenceNode("chessBoard", new ChessBoardPage())); mgr.addTo("chessBoard", new PreferenceNode("arrows", new ChessBoardArrowsPage())); mgr.addTo("chessBoard", new PreferenceNode("behavior", new ChessBoardBehaviorPage())); mgr.addTo("chessBoard", new PreferenceNode("colors", new ChessBoardColorsPage())); mgr.addTo("chessBoard", new PreferenceNode("fonts", new ChessBoardFontsPage())); mgr.addTo("chessBoard", new PreferenceNode("highlights", new ChessBoardHighlightsPage())); mgr.addTo("chessBoard", new PreferenceNode("mouseActions", new ChessBoardMouseActions())); mgr.addTo("chessBoard/mouseActions", new PreferenceNode("inactive", new InactiveMouseActionsPage())); mgr.addTo("chessBoard/mouseActions", new PreferenceNode("playing", new PlayingMouseActionsPage())); mgr.addTo("chessBoard/mouseActions", new PreferenceNode("observing", new ObservingMouseActionsPage())); mgr.addTo("chessBoard", new PreferenceNode("toolbar", new ChessBoardToolbarsPage())); mgr.addTo("chessBoard/toolbar", new PreferenceNode("bugSuggest", new ActionContainerPage(local.getString("prefUtil3"), local.getString("prefUtil4"), RaptorActionContainer.BughouseSuggestChessBoard))); mgr.addTo("chessBoard/toolbar", new PreferenceNode("examining", new ActionContainerPage(local.getString("prefUtil5"), local.getString("prefUtil6"), RaptorActionContainer.ExaminingChessBoard))); mgr.addTo("chessBoard/toolbar", new PreferenceNode("inactive", new ActionContainerPage(local.getString("prefUtil7"), local.getString("prefUtil8"), RaptorActionContainer.InactiveChessBoard))); mgr.addTo("chessBoard/toolbar", new PreferenceNode("observing", new ActionContainerPage(local.getString("prefUtil9"), local.getString("prefUtil10"), RaptorActionContainer.ObservingChessBoard))); mgr.addTo("chessBoard/toolbar", new PreferenceNode("playing", new ActionContainerPage(local.getString("prefUtil11"), local.getString("prefUtil12"), RaptorActionContainer.PlayingChessBoard))); mgr.addTo("chessBoard/toolbar", new PreferenceNode("setup", new ActionContainerPage(local.getString("prefUtil13"), local.getString("prefUtil14"), RaptorActionContainer.SetupChessBoard))); mgr.addTo("chessBoard", new PreferenceNode("results", new ChessBoardResultsPage())); mgr.addToRoot(new PreferenceNode("chatConsole", new ChatConsolePage())); // Currently unused but keeping it around in case more options are // added./*from ww w .j av a 2s. c o m*/ mgr.addTo("chatConsole", new PreferenceNode("behavior", new ChatConsoleBehaviorPage())); mgr.addTo("chatConsole", new PreferenceNode("channelColors", new ChatConsoleChannelColorsPage())); mgr.addTo("chatConsole", new PreferenceNode("messageColors", new ChatConsoleMessageColorsPage())); mgr.addTo("chatConsole", new PreferenceNode("toolbar", new ChatConsoleToolbarsPage())); mgr.addTo("chatConsole/toolbar", new PreferenceNode("channel", new ActionContainerPage(local.getString("prefUtil15"), local.getString("prefUtil16"), RaptorActionContainer.ChannelChatConsole))); mgr.addTo("chatConsole/toolbar", new PreferenceNode("main", new ActionContainerPage(local.getString("prefUtil17"), local.getString("prefUtil18"), RaptorActionContainer.MainChatConsole))); mgr.addTo("chatConsole/toolbar", new PreferenceNode("partner", new ActionContainerPage(local.getString("prefUtil19"), local.getString("prefUtil20"), RaptorActionContainer.BughousePartnerChatConsole))); mgr.addTo("chatConsole/toolbar", new PreferenceNode("person", new ActionContainerPage(local.getString("prefUtil21"), local.getString("prefUtil22"), RaptorActionContainer.PersonChatConsole))); mgr.addTo("chatConsole/toolbar", new PreferenceNode("regex", new ActionContainerPage(local.getString("prefUtil23"), local.getString("prefUtil24"), RaptorActionContainer.RegExChatConsole))); mgr.addToRoot(new PreferenceNode("scripts", new ScriptsPage())); mgr.addTo("scripts", new PreferenceNode("actionScripts", new ActionScriptsPage())); mgr.addTo("scripts", new PreferenceNode("actionScriptKeys", new ActionKeyBindingsPage())); mgr.addTo("scripts", new PreferenceNode("regex", new ChatEventScripts())); mgr.addTo("scripts", new PreferenceNode("rightClickScripts", new ChatConsoleRightClickScripts())); mgr.addToRoot(new PreferenceNode("seeks", new SeekPage())); mgr.addToRoot(new PreferenceNode("sounds", new SoundsPage())); mgr.addToRoot(new PreferenceNode("sound process config", new SoundPage())); mgr.addToRoot(new PreferenceNode("speech", new SpeechPage())); mgr.addToRoot(new PreferenceNode("stockfish", new StockfishPage())); // Add the connector preference nodes. Connector[] connectors = ConnectorService.getInstance().getConnectors(); for (Connector connector : connectors) { PreferencePage root = connector.getRootPreferencePage(); if (root != null) { mgr.addToRoot(new PreferenceNode(connector.getShortName(), root)); PreferenceNode[] secondaries = connector.getSecondaryPreferenceNodes(); if (secondaries != null && secondaries.length > 0) { for (PreferenceNode node : secondaries) { mgr.addTo(connector.getShortName(), node); } } } } // Create the preferences dialog dlg = new PreferenceDialog(Raptor.getInstance().getWindow().getShell(), mgr); }