List of usage examples for org.eclipse.jface.preference IPreferenceNode getId
public String getId();
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$ {/* ww w .j av a2 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.formatter.ui.dialogs.PropertyLinkArea.java
License:Open Source License
@SuppressWarnings("rawtypes") private IPreferenceNode getPreferenceNode(String pageId) { /*//w w w .j a va 2s . c o m * code pulled from org.eclipse.ui.internal.dialogs.PropertyDialog - i'm not sure why this type of class doesn't * already exist for property pages like it does for preference pages since it seems it would be very useful - * guess we're breaking new ground :) */ PropertyPageManager pageManager = new PropertyPageManager(); PropertyPageContributorManager.getManager().contribute(pageManager, element); Iterator pages = pageManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (pages.hasNext()) { IPreferenceNode node = (IPreferenceNode) pages.next(); if (node.getId().equals(pageId)) { return node; } } return null; }
From source file:com.aptana.formatter.ui.dialogs.PropToPrefLinkArea.java
License:Open Source License
@SuppressWarnings("rawtypes") private IPreferenceNode getPreferenceNode(String pageId) { Iterator iterator = PlatformUI.getWorkbench().getPreferenceManager() .getElements(PreferenceManager.PRE_ORDER).iterator(); while (iterator.hasNext()) { IPreferenceNode next = (IPreferenceNode) iterator.next(); if (next.getId().equals(pageId)) { return next; }//from w w w . j a va 2 s .c om } return null; }
From source file:com.aptana.ui.preferences.GenericRootPreferencePage.java
License:Open Source License
/** * Creates the links.//from w w w. j av 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:com.google.dart.tools.deploy.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
private void filterUnwantedPreferenceNodes() { PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager(); for (Object elem : preferenceManager.getElements(PreferenceManager.POST_ORDER)) { if (elem instanceof IPreferenceNode) { IPreferenceNode node = (IPreferenceNode) elem; if (isBlacklisted(node)) { if (!preferenceManager.remove(node)) { for (IPreferenceNode rootNode : preferenceManager.getRootSubNodes()) { if (rootNode.findSubNode(node.getId()) != null) { rootNode.remove(node); }//from w ww . ja v a 2s . c om } } } } } }
From source file:com.google.dart.tools.deploy.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
private boolean isBlacklisted(IPreferenceNode node) { String nodeId = node.getId(); for (String blacklistedId : PREF_BLACKLIST) { if (nodeId.matches(blacklistedId)) { return true; }//from w w w . j a v a 2 s. c o m } return false; }
From source file:com.googlecode.goclipse.ui.GoUIPlugin.java
License:Open Source License
protected void checkPrefPageIdIsValid(String prefId) { Shell shell = WorkbenchUtils.getActiveWorkbenchShell(); PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(shell, prefId, null, null); assertNotNull(prefDialog); // Don't create, just eagerly check that it exits, that the ID is correct ISelection selection = prefDialog.getTreeViewer().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.getFirstElement() instanceof IPreferenceNode) { IPreferenceNode prefNode = (IPreferenceNode) ss.getFirstElement(); if (prefNode.getId().equals(prefId)) { return; // Id exists }/*from ww w. j av a2s .c om*/ } } assertFail(); }
From source file:com.mindquarry.desktop.preferences.dialog.FilteredPreferenceDialog.java
License:Open Source License
/** * Find the <code>IPreferenceNode</code> that has data the same id as the * supplied value.//from ww w .j a va 2s .co m * * @param nodeId the id to search for. * @return <code>IPreferenceNode</code> or <code>null</code> if not * found. */ protected IPreferenceNode findNodeMatching(String nodeId) { List nodes = preferenceManager.getElements(PreferenceManager.POST_ORDER); for (Iterator i = nodes.iterator(); i.hasNext();) { IPreferenceNode node = (IPreferenceNode) i.next(); if (node.getId().equals(nodeId)) { return node; } } return null; }
From source file:com.mindquarry.desktop.preferences.dialog.FilteredPreferenceDialog.java
License:Open Source License
/** * Save the currently selected node.//from ww w . j a v a 2 s . c o m */ private void setSelectedNode() { String storeValue = null; IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection(); if (selection.size() == 1) { IPreferenceNode node = (IPreferenceNode) selection.getFirstElement(); storeValue = node.getId(); } setSelectedNodePreference(storeValue); }
From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java
License:Apache License
/** * Open the preference page with the specified ID * @param nodeID the id of preference page to show *///from ww w . j a va2 s .c om @SuppressWarnings("unchecked") public static void openPreference(Shell shell, String nodeID) { // Makes the network preferences dialog manager PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager(); IPreferenceNode networkNode = null; for (IPreferenceNode node : (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) { if (node.getId().equals(nodeID)) { networkNode = node; break; } } PreferenceManager prefMan = new PreferenceManager(); if (networkNode != null) { prefMan.addToRoot(networkNode); } PreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog(shell, prefMan); preferencesDialog.create(); preferencesDialog.open(); }