List of usage examples for org.eclipse.jface.preference PreferenceManager remove
public boolean remove(IPreferenceNode node)
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.// w ww . ja va 2s . com * * @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:scouter.client.util.RCPUtil.java
License:Apache License
public static void hidePreference(String[] ids) { // List<String> list = Arrays.asList(ids); PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager(); // @SuppressWarnings("unchecked") // List<IPreferenceNode> preferenceNodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER); // for (Iterator<IPreferenceNode> it = preferenceNodes.iterator(); it.hasNext();) { // IPreferenceNode preferenceNode = (IPreferenceNode)it.next(); // if (list.contains(preferenceNode.getId())) { // preferenceManager.remove(preferenceNode); // } // }/* w w w . j ava2s .c o m*/ for (String id : ids) { preferenceManager.remove(id); } }
From source file:scouter.window.util.RCPUtil.java
License:Apache License
public static void hidePreference(String[] ids) { List<String> list = Arrays.asList(ids); PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager(); @SuppressWarnings("unchecked") List<IPreferenceNode> preferenceNodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER); for (Iterator<IPreferenceNode> it = preferenceNodes.iterator(); it.hasNext();) { IPreferenceNode preferenceNode = (IPreferenceNode) it.next(); if (list.contains(preferenceNode.getId())) { preferenceManager.remove(preferenceNode); }//from w w w .j ava 2s. co m } }
From source file:sernet.gs.ui.rcp.main.ApplicationWorkbenchAdvisor.java
License:Open Source License
/** * removes prefPages that were loaded from plugins but not needed * currently thats:/*from ww w. j a v a 2 s .co m*/ * - org.eclipse.datatools.connectivity.ui.preferences.dataNode * - org.eclipse.birt.report.designer.ui.preferences * - org.eclipse.birt.chart.ui.swt.fieldassist.preferences.FieldAssistPreferencePage */ private void removeUnneededPrefPages() { PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager(); // add id of prefPage to remove here String[] prefPageIDsToRemove = new String[] { "org.eclipse.datatools.connectivity.ui.preferences.dataNode", "org.eclipse.birt.report.designer.ui.preferences", "org.eclipse.birt.chart.ui.swt.fieldassist.preferences.FieldAssistPreferencePage" }; Set<String> idSet = new HashSet<String>(); for (String s : prefPageIDsToRemove) { idSet.add(s); } for (IPreferenceNode node : pm.getRootSubNodes()) { if (idSet.contains(node.getId())) { // removing prefPages pm.remove(node); } } }
From source file:sernet.gs.ui.rcp.main.preferences.ShowPreferencesAction.java
License:Open Source License
public void run() { PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode[] nodes = manager.getRootSubNodes(); for (int i = 0; i < nodes.length; ++i) { if (nodes[i].getId().equals("org.eclipse.ui.preferencePages.Workbench")) { IPreferenceNode[] subNodes = nodes[i].getSubNodes(); for (IPreferenceNode subNode : subNodes) { if (!subNode.getId().equals("org.eclipse.ui.net.NetPreferences")) { nodes[i].remove(subNode.getId()); } else { manager.addToRoot(subNode); }/*from ww w.j a va 2s. c o m*/ manager.remove(nodes[i]); } } if (nodes[i].getId().equals("org.eclipse.help.ui.browsersPreferencePage") //$NON-NLS-1$ || nodes[i].getId().equals("org.eclipse.help.ui.appserverPreferencePage") //$NON-NLS-1$ ) { manager.remove(nodes[i]); } } //|| nodes[i].getId().equals("org.eclipse.update.internal.ui.preferences.MainPreferencePage") //$NON-NLS-1$ final PreferenceDialog dialog = new PreferenceDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), manager); if (prefPage != null) { dialog.setSelectedNode(prefPage); } BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), new Runnable() { public void run() { dialog.create(); dialog.open(); } }); }