List of usage examples for org.eclipse.jface.preference PreferenceManager PreferenceManager
public PreferenceManager(final char separatorChar)
From source file:com.blackducksoftware.integration.eclipseplugin.popupmenu.handlers.OpenProjectPreferences.java
License:Apache License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final Shell activeShell = HandlerUtil.getActiveShell(event); final PreferenceManager mgr = new PreferenceManager(preferencePathSeparatorCharacter); final DependencyInformationService depService = new DependencyInformationService(); final FilePathGavExtractor extractor = new FilePathGavExtractor(); final ProjectInformationService projService = new ProjectInformationService(depService, extractor); final WorkspaceInformationService workspaceService = new WorkspaceInformationService(projService); final String projectPrefId = workspaceService.getSelectedProject(); final IndividualProjectPreferences prefPage = new IndividualProjectPreferences(projectPrefId, projectPrefId);/*from w ww . jav a 2 s. c o m*/ final PreferenceNode prefNode = new PreferenceNode(projectPrefId, prefPage); mgr.addToRoot(prefNode); final PreferenceDialog prefDialog = new PreferenceDialog(activeShell, mgr); prefDialog.open(); return null; }
From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java
License:Open Source License
private static PreferenceManager createPreferenceManager(ReportElementHandle handle, AbstractThemeHandle theme) {/*from ww w. j a va 2 s . c o m*/ PreferenceManager preferenceManager = new PreferenceManager('/'); // Get the pages from the registry List<IPreferenceNode> pageContributions = new ArrayList<IPreferenceNode>(); // adds preference pages into page contributions. pageContributions.add(new StylePreferenceNode("General", //$NON-NLS-1$ new GeneralPreferencePage(handle, theme))); pageContributions.add(new StylePreferenceNode("Font", //$NON-NLS-1$ new FontPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Size", //$NON-NLS-1$ new SizePreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Background", //$NON-NLS-1$ new BackgroundPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Block", //$NON-NLS-1$ new BlockPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Box", //$NON-NLS-1$ new BoxPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Border", //$NON-NLS-1$ new BorderPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Number Format", //$NON-NLS-1$ new FormatNumberPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("DateTime Format", //$NON-NLS-1$ new FormatDateTimePreferencePage(handle))); pageContributions.add(new StylePreferenceNode("String Format", //$NON-NLS-1$ new FormatStringPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("PageBreak", //$NON-NLS-1$ new PageBreakPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Map", //$NON-NLS-1$ new MapPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Highlights", //$NON-NLS-1$ new HighlightsPreferencePage(handle))); pageContributions.add(new StylePreferenceNode("Comments", //$NON-NLS-1$ new CommentsPreferencePage(handle))); // Add the contributions to the manager Iterator<IPreferenceNode> it = pageContributions.iterator(); while (it.hasNext()) { IPreferenceNode node = it.next(); preferenceManager.addToRoot(node); } return preferenceManager; }
From source file:org.eclipse.mat.ui.rcp.actions.OpenPreferenceAction.java
License:Open Source License
@Override public void run() { if (reg == null) reg = new PreferenceRegistry(); PreferenceManager manager = new PreferenceManager('/'); // Recreate tree structure Map<String, Node> nodes = new LinkedHashMap<String, Node>(); for (Node node : reg.delegates()) { node.subNode = false;/*from w ww .ja v a2 s . com*/ for (IPreferenceNode subNode : node.getSubNodes()) node.remove(subNode.getId()); nodes.put(node.getId(), node); } for (Node node : reg.delegates()) { if (node.getCategory() != null && nodes.containsKey(node.getCategory())) { nodes.get(node.getCategory()).add(node); node.subNode = true; } } List<Node> toSort = new ArrayList<Node>(); for (Node node : nodes.values()) { if (!node.subNode) toSort.add(node); } Collections.sort(toSort, new Comparator<Node>() { public int compare(Node object1, Node object2) { return object1.getLabelText().compareTo(object2.getLabelText()); } }); for (Node node : toSort) { manager.addToRoot(node); } PreferenceDialog dialog = new PreferenceDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), manager); dialog.open(); }
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(/* w w w . j a v a 2 s .co m*/ 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 { 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(// w w w. j av a2s . c o 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 ww .ja v a2 s . c om*/ 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.talend.repository.ui.dialog.ProjectSettingDialog.java
License:Open Source License
/** * get all projectsettingPage node dynamic. need get the different result each time. because the tester will calc * dymamic./*from w ww. j a v a2 s. c o m*/ * * @return PreferenceManager */ private PreferenceManager getNodeManager() { // PreferenceManager manager = new PreferenceManager(WorkbenchPlugin.PREFERENCE_PAGE_CATEGORY_SEPARATOR); PreferenceManager manager = new PreferenceManager('/'); IExtensionRegistry registry = Platform.getExtensionRegistry(); IConfigurationElement[] configurationElements = registry .getConfigurationElementsFor("org.talend.repository.projectsetting_page"); //$NON-NLS-1$ Map<String, List<IPreferenceNode>> hasCategoriesNodes = new HashMap<String, List<IPreferenceNode>>(); for (IConfigurationElement element : configurationElements) { ProjectSettingNode node = new ProjectSettingNode(element); try { IPreferencePage page = (IPreferencePage) element.createExecutableExtension("class"); //$NON-NLS-1$ node.setPage(page); String id = element.getAttribute("id");//$NON-NLS-1$ IConfigurationElement[] testers = element.getChildren("tester"); if (testers != null && testers.length == 1) { // currently, only one tester is supported. try { IProjectSettingPageTester pageTester = (IProjectSettingPageTester) testers[0] .createExecutableExtension("class"); if (pageTester != null) { if (!pageTester.valid(element, node)) { continue; // don't add this page node. } } } catch (CoreException ex) { // can't create the tester log.log(Level.WARN, "can't create the project setting tester for " + id, ex); } } page.setDescription(element.getAttribute("description")); //$NON-NLS-1$ page.setTitle(element.getAttribute("title")); //$NON-NLS-1$ } catch (CoreException e) { ExceptionHandler.process(e); } // add all into root. manager.addToRoot(node); // has category String category = node.getCategory(); if (category != null && category.length() > 0) { List<IPreferenceNode> list = hasCategoriesNodes.get(category); if (list == null) { list = new ArrayList<IPreferenceNode>(); hasCategoriesNodes.put(category, list); } list.add(node); } } // add the speciall node for maven custom if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) { IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault() .getService(IMavenUIService.class); IPreferenceNode mavenCostomSetup = manager.find("projectsetting.MavenCustomSetup"); mavenUIService.addCustomMavenSettingChildren(mavenCostomSetup); } // find parent nodes for category Map<String, IPreferenceNode> parentNodesMap = new HashMap<String, IPreferenceNode>(); for (String category : hasCategoriesNodes.keySet()) { IPreferenceNode parent = manager.find(category); if (parent != null) { parentNodesMap.put(category, parent); } } // process children nodes for (String category : hasCategoriesNodes.keySet()) { List<IPreferenceNode> list = hasCategoriesNodes.get(category); if (list != null) { IPreferenceNode parent = parentNodesMap.get(category); Collections.sort(list, COMPARATOR); for (IPreferenceNode node : list) { // if the parent is not valid or not existed. the node won't show also. manager.remove(node); // remove from root node. if (parent != null) { // the parent existed. parent.add(node); } } } } // sort the root nodes List<IPreferenceNode> rootSubNodesList = new ArrayList<IPreferenceNode>( Arrays.asList(manager.getRootSubNodes())); Collections.sort(rootSubNodesList, COMPARATOR); manager.removeAll(); // clean all to re-add for order // add the sorted list to manager for (IPreferenceNode rootSubNode : rootSubNodesList) { manager.addToRoot(rootSubNode); } return manager; }
From source file:org.xwalk.ide.eclipse.xdt.wizards.export.ExportProjectWizard.java
License:Apache License
private void showQuickPreferenceDialog() { IPreferencePage page = new settingPage(); PreferenceManager mgr = new PreferenceManager('/'); IPreferenceNode node = new PreferenceNode("1", page); mgr.addToRoot(node);//from w w w . j av a 2s. com PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr); dialog.create(); dialog.setMessage(page.getTitle()); 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 w w w . j a v 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); }