List of usage examples for org.eclipse.jface.preference PreferenceManager getElements
public List<IPreferenceNode> getElements(int order)
From source file:org.mailster.gui.prefs.ConfigurationDialog.java
License:Open Source License
/** * The preference dialog implementation of this <code>Dialog</code> * framework method sends <code>performOk</code> to all pages of the * preference dialog, then calls <code>handleSave</code> on this dialog to * save any state, and then calls <code>close</code> to close this dialog. *//*from ww w . j ava 2s . co m*/ protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /** * @see org.eclipse.core.runtime.ISafeRunnable#run() */ public void run() { // getButton(IDialogConstants.OK_ID).setEnabled(false); errorOccurred = false; boolean hasFailedOK = false; try { PreferenceManager preferenceManager = getPreferenceManager(); // Notify all the pages and give them a chance to abort Iterator<?> nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null) { if (!page.performOk()) { hasFailedOK = true; return; } } } } catch (Exception e) { handleException(e); } finally { // Don't bother closing if the OK failed if (hasFailedOK) { return; } if (!errorOccurred) { // Give subclasses the choice to save the state of the // preference pages. handleSave(); } close(); } } /** * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ public void handleException(Throwable e) { errorOccurred = true; Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e)); clearLastSelectedNode(); String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$ } }); }
From source file:org.modelio.app.preferences.ModelioPreferenceDialog.java
License:Open Source License
@objid("ea571be5-8067-4949-9647-e2c692636ae8") private static IPreferenceNode findNode(PreferenceManager pm, String categoryId) { for (Object o : pm.getElements(PreferenceManager.POST_ORDER)) { if (o instanceof IPreferenceNode && ((IPreferenceNode) o).getId().equals(categoryId)) { return (IPreferenceNode) o; }//from w ww .j a v a 2 s . co m } return null; }
From source file:scouter.client.util.RCPUtil.java
License:Apache License
public static void printPreferencePages() { System.out.println("=== PreferencePages ==="); 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(); System.out.println(preferenceNode.getId()); }/*from w w w. j a v a 2 s. c o m*/ }
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); }/* w w w .j ava 2 s. c o m*/ } }