Example usage for org.eclipse.jface.preference PreferenceManager PRE_ORDER

List of usage examples for org.eclipse.jface.preference PreferenceManager PRE_ORDER

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceManager PRE_ORDER.

Prototype

int PRE_ORDER

To view the source code for org.eclipse.jface.preference PreferenceManager PRE_ORDER.

Click Source Link

Document

Pre-order traversal means visit the root first, then the children.

Usage

From source file:org.netxms.ui.eclipse.tools.ExtendedPropertyDialog.java

License:Open Source License

/**
 * @param shell/*from   w w w .  j a  v  a2 s. c o  m*/
 * @param propertyPageId
 * @param element
 * @param name
 * @return
 */
public static ExtendedPropertyDialog createDialogOn(Shell shell, final String propertyPageId, Object element,
        String name) {
    if (element == null)
        return null;

    PropertyPageManager pageManager = new PropertyPageManager();
    String title = "";//$NON-NLS-1$

    // load pages for the selection
    // fill the manager with contributions from the matching contributors
    PropertyPageContributorManager.getManager().contribute(pageManager, element);
    // testing if there are pages in the manager
    Iterator<?> pages = pageManager.getElements(PreferenceManager.PRE_ORDER).iterator();
    if (!pages.hasNext()) {
        MessageDialogHelper.openInformation(shell, WorkbenchMessages.get().PropertyDialog_messageTitle,
                NLS.bind(WorkbenchMessages.get().PropertyDialog_noPropertyMessage, name));
        return null;
    }
    title = NLS.bind(WorkbenchMessages.get().PropertyDialog_propertyMessage, name);
    ExtendedPropertyDialog propertyDialog = new ExtendedPropertyDialog(shell, pageManager,
            new StructuredSelection(element));

    if (propertyPageId != null) {
        propertyDialog.setSelectedNode(propertyPageId);
    }
    propertyDialog.create();

    propertyDialog.getShell().setText(title);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(propertyDialog.getShell(),
            IWorkbenchHelpContextIds.PROPERTY_DIALOG);

    return propertyDialog;
}

From source file:org.talend.repository.ui.dialog.ProjectSettingsPreferenceDialog.java

License:Open Source License

protected void saveCurrentSettings() {
    SafeRunnable.run(new SafeRunnable() {

        private boolean errorOccurred;

        @Override//from   w w w .j  av  a2s . com
        public void run() {
            errorOccurred = false;
            boolean hasFailedOK = false;
            try {
                Iterator nodes = getPreferenceManager().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 {

                if (hasFailedOK) {
                    setReturnCode(FAILED);
                    return;
                }

                if (!errorOccurred) {

                    handleSave();
                }
                setReturnCode(OK);
            }
        }

        @Override
        public void handleException(Throwable e) {
            errorOccurred = true;

            Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e));

            clearSelectedNode();
            String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$

            Policy.getStatusHandler().show(new Status(IStatus.ERROR, Policy.JFACE, message, e),
                    JFaceResources.getString("Error")); //$NON-NLS-1$ 

        }
    });
}

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  www.j  ava 2s. c om*/
}

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  a v  a  2  s  .co m
    }
}