List of usage examples for org.eclipse.jface.preference IPreferenceNode getSubNodes
public IPreferenceNode[] getSubNodes();
From source file:ca.mcgill.cs.swevo.qualyzer.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override public void postWindowCreate() { PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager(); pm.remove("net.sf.colorer.eclipse.PreferencePage"); //$NON-NLS-1$ IPreferenceNode node = pm.remove("org.eclipse.ui.preferencePages.Workbench"); //$NON-NLS-1$ for (IPreferenceNode sub : node.getSubNodes()) { if (sub.getId().equals("org.eclipse.ui.preferencePages.Keys")) //$NON-NLS-1$ {// w w w .j a v a 2 s. com pm.addToRoot(sub); } } String upgradeMessage = QualyzerActivator.getDefault().getUpgradeMessage(); if (upgradeMessage != null) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); boolean error = QualyzerActivator.getDefault().isUpgradeMessageError(); if (error) { MessageDialog.openError(shell, Messages.getString("QualyzerActivator.upgradedTitle"), //$NON-NLS-1$ upgradeMessage); //$NON-NLS-1$ } else { MessageDialog.openInformation(shell, Messages.getString("QualyzerActivator.upgradedTitle"), //$NON-NLS-1$ upgradeMessage); } } }
From source file:com.aptana.ui.preferences.GenericRootPreferencePage.java
License:Open Source License
/** * Creates the links./*from w w w . jav a2 s . c o m*/ */ @SuppressWarnings({ "unchecked" }) protected Control createContents(Composite parent) { // pageNameToId = null if (pageNameToId == null) { pageNameToId = new HashMap<String, String>(); String pageId = getPageId(); // Locate all the pages that are defined as this page children PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); List<IPreferenceNode> nodes = manager.getElements(PreferenceManager.POST_ORDER); for (Iterator<IPreferenceNode> i = nodes.iterator(); i.hasNext();) { IPreferenceNode node = i.next(); if (node.getId().equals(pageId)) { // we found the node, so take its child nodes and add them to the cache IPreferenceNode[] subNodes = node.getSubNodes(); for (IPreferenceNode child : subNodes) { pageNameToId.put(child.getLabelText(), child.getId()); } break; } } } Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); String contentsMessage = getContentsMessage(); if (contentsMessage != null) { Label message = new Label(composite, SWT.WRAP); message.setText(contentsMessage); } Group group = new Group(composite, SWT.NONE); group.setLayout(new GridLayout(1, false)); GridData gd = new GridData(GridData.FILL_HORIZONTAL); group.setLayoutData(gd); group.setText(EplMessages.GenericRootPage_preferences); List<String> pagesNames = new ArrayList<String>(pageNameToId.keySet()); // In case there are no pages to link to, add a label that will indicate that there are no settings if (pagesNames.isEmpty()) { Label label = new Label(group, SWT.NONE); label.setText(EplMessages.GenericRootPage_noAvailablePages); label.setLayoutData(new GridData()); } else { Collections.sort(pagesNames); for (String pageName : pagesNames) { String id = pageNameToId.get(pageName); final Link link = new Link(group, SWT.NONE); link.setText("<a>" + pageName + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ link.addSelectionListener(new LinkSelectionListener(id)); gd = new GridData(); gd.horizontalIndent = 30; link.setLayoutData(gd); } } Group dialogsResetGroup = new Group(composite, SWT.NONE); dialogsResetGroup.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create()); dialogsResetGroup.setLayoutData(GridDataFactory.fillDefaults().create()); dialogsResetGroup.setText(EplMessages.GenericRootPreferencePage_dialogsGroup); Label label = new Label(dialogsResetGroup, SWT.WRAP); label.setText(EplMessages.GenericRootPreferencePage_clearMessagesLabelText); label.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER) .hint(convertVerticalDLUsToPixels(50), SWT.DEFAULT).create()); final Button clearBt = new Button(dialogsResetGroup, SWT.PUSH); clearBt.setText(EplMessages.GenericRootPreferencePage_clearMessagesButtonLabel); clearBt.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false)); // enable the 'reset' button only if there are dialogs to reset. final IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(UIEplPlugin.PLUGIN_ID); String messages = prefs.get(IEplPreferenceConstants.HIDDEN_MESSAGES, null); clearBt.setEnabled(!StringUtil.isEmpty(messages)); clearBt.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { prefs.remove(IEplPreferenceConstants.HIDDEN_MESSAGES); prefs.flush(); clearBt.setEnabled(false); } catch (Exception ex) { IdeLog.logError(UIEplPlugin.getDefault(), ex); } } }); Point point = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd = new GridData(); composite.setLayoutData(gd); gd.heightHint = point.y; return composite; }
From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferenceDialog.java
License:Open Source License
private boolean removePreferenceNode(final IPreferenceNode node, final IPreferenceNode parentNode) { boolean removed; for (final IPreferenceNode pn : parentNode.getSubNodes()) { if (pn == node) { return parentNode.remove(pn); }/*from w w w . j a v a2 s . co m*/ removed = removePreferenceNode(node, pn); if (removed) { return true; } } return false; }
From source file:gov.nasa.ensemble.core.rcp.EnsembleWorkbenchWindowAdvisor.java
License:Open Source License
private void cleanupPreferencePages(IPreferenceNode parent, Collection<Pattern> patterns) { for (IPreferenceNode node : parent.getSubNodes()) { for (Pattern pattern : patterns) { if (pattern.matcher(node.getId()).matches()) { parent.remove(node);/*from w ww .ja v a 2 s .c o m*/ continue; } } cleanupPreferencePages(node, patterns); } }
From source file:net.refractions.udig.style.sld.editor.internal.EditorNodeFilter.java
License:Open Source License
/** * Check to see if the node or any of its children * have an id in the ids.//from w w w. j a v a 2s . c om * @param node WorkbenchPreferenceNode * @return boolean <code>true</code> if node or oe of its children * has an id in the ids. */ private boolean checkNodeAndChildren(IPreferenceNode node) { if (ids.contains(node.getId())) return true; IPreferenceNode[] subNodes = node.getSubNodes(); for (int i = 0; i < subNodes.length; i++) { if (checkNodeAndChildren(subNodes[i])) return true; } return false; }
From source file:org.eclipse.cdt.debug.ui.breakpoints.CBreakpointPropertyDialogAction.java
License:Open Source License
public void run() { CBreakpointContext bpContext = getCBreakpointContext(); if (bpContext != null) { PreferenceDialog dialog = createDialog(bpContext); if (dialog != null) { TreeViewer viewer = dialog.getTreeViewer(); if (viewer != null) { viewer.setComparator(new ViewerComparator() { @Override//from w ww.j av a2s . co m public int category(Object element) { if (element instanceof IPreferenceNode) { IPreferenceNode node = (IPreferenceNode) element; if (PAGE_ID_COMMON.equals(node.getId())) { return 0; } else if (node.getSubNodes() == null || node.getSubNodes().length == 0) { // Pages without children (not categories) return super.category(element) + 1; } } // Categories last. return super.category(element) + 2; } }); // Expand all categories viewer.expandToLevel(TreeViewer.ALL_LEVELS); } dialog.open(); } } }
From source file:org.eclipse.oomph.setup.ui.recorder.PreferenceInitializationDialog.java
License:Open Source License
@Override protected void createUI(Composite parent) { final Object root = new Object(); final Set<String> initializedPreferencePages = RecorderManager.INSTANCE.getInitializedPreferencePages(); checkboxTreeViewer = new ContainerCheckedTreeViewer(parent, SWT.NONE); checkboxTreeViewer.setContentProvider(new ITreeContentProvider() { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { }/*from w w w . j av a2 s . c o m*/ public void dispose() { } public boolean hasChildren(Object element) { return true; } public Object getParent(Object element) { return null; } public Object[] getElements(Object inputElement) { return new Object[] { root }; } public Object[] getChildren(Object parentElement) { List<IPreferenceNode> nodes = new ArrayList<IPreferenceNode>(); if (parentElement == root) { nodes.addAll(Arrays.asList(preferenceManager.getRootSubNodes())); } else { IPreferenceNode preferenceNode = (IPreferenceNode) parentElement; nodes.addAll(Arrays.asList(preferenceNode.getSubNodes())); } return filter(nodes); } private Object[] filter(List<IPreferenceNode> nodes) { for (Iterator<IPreferenceNode> it = nodes.iterator(); it.hasNext();) { IPreferenceNode preferenceNode = it.next(); if (initializedPreferencePages.contains(preferenceNode.getId()) && getChildren(preferenceNode).length == 0) { it.remove(); } } return nodes.toArray(); } }); checkboxTreeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element == root) { return "All Pages"; } IPreferenceNode preferenceNode = (IPreferenceNode) element; return preferenceNode.getLabelText(); } }); filteredTree = ReflectUtil.getValue("filteredTree", preferenceDialog); final TreeViewer viewer = filteredTree.getViewer(); checkboxTreeViewer.setComparator(viewer.getComparator()); checkboxTreeViewer.setInput(preferenceManager); checkboxTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); checkboxTreeViewer.expandAll(); checkboxTreeViewer.setSubtreeChecked(root, true); Set<String> ignoredPreferencePages = RecorderManager.INSTANCE.getIgnoredPreferencePages(); for (IPreferenceNode preferenceNode : preferenceManager.getElements(PreferenceManager.PRE_ORDER)) { if (ignoredPreferencePages.contains(preferenceNode.getId())) { checkboxTreeViewer.setChecked(preferenceNode, false); } } showFirstTimeHelp(this); }
From source file:org.eclipse.ui.internal.dialogs.PreferenceNodeFilter.java
License:Open Source License
/** * Check to see if the node or any of its children * have an id in the ids.//from ww w. j a v a 2s. com * @param node WorkbenchPreferenceNode * @return boolean <code>true</code> if node or oe of its children * has an id in the ids. */ private boolean checkNodeAndChildren(IPreferenceNode node) { if (ids.contains(node.getId())) { return true; } IPreferenceNode[] subNodes = node.getSubNodes(); for (int i = 0; i < subNodes.length; i++) { if (checkNodeAndChildren(subNodes[i])) { return true; } } return false; }
From source file:org.eclipse.ui.internal.dialogs.WorkbenchPreferenceManager.java
License:Open Source License
/** * Removes the node from the manager, searching through all subnodes. * /* w w w .java2s . c o m*/ * @param parent * the node to search * @param nodeToRemove * the node to remove * @return whether the node was removed */ private boolean deepRemove(IPreferenceNode parent, IPreferenceNode nodeToRemove) { if (parent == nodeToRemove) { if (parent == getRoot()) { removeAll(); // we're removing the root return true; } } if (parent.remove(nodeToRemove)) { return true; } IPreferenceNode[] subNodes = parent.getSubNodes(); for (int i = 0; i < subNodes.length; i++) { if (deepRemove(subNodes[i], nodeToRemove)) { return true; } } return false; }
From source file:org.eclipse.ui.internal.registry.PreferencePageParameterValues.java
License:Open Source License
/** * Iterate through the preference page and build the map of preference page * names to ids./*from w ww .j a v a 2s . c o m*/ * * @param values * The Map being populated with parameter values. * @param preferenceNodes * An array of <code>IPreferenceNode</code> to process. * @param namePrefix * A string incorporating the names of each parent * <code>IPreferenceNode</code> up to the root of the * preference page tree. This will be <code>null</code> for the * root level preference page nodes. */ private final void collectParameterValues(final Map values, final IPreferenceNode[] preferenceNodes, final String namePrefix) { for (int i = 0; i < preferenceNodes.length; i++) { final IPreferenceNode preferenceNode = preferenceNodes[i]; final String name; if (namePrefix == null) { name = preferenceNode.getLabelText(); } else { name = namePrefix + WorkbenchMessages.PreferencePageParameterValues_pageLabelSeparator + preferenceNode.getLabelText(); } final String value = preferenceNode.getId(); values.put(name, value); collectParameterValues(values, preferenceNode.getSubNodes(), name); } }