Example usage for org.eclipse.jface.preference PreferenceDialog getPreferenceManager

List of usage examples for org.eclipse.jface.preference PreferenceDialog getPreferenceManager

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceDialog getPreferenceManager.

Prototype

public PreferenceManager getPreferenceManager() 

Source Link

Document

Returns the preference mananger used by this preference dialog.

Usage

From source file:com.nokia.s60tools.ui.preferences.PreferenceUtils.java

License:Open Source License

/**
 * Open a preference page tab by ID introduced in <code>plugin.xml</code>
 * /*from  www  . j av  a2 s.c  om*/
 * If the preference page contains tabs, and one tab is wanted to open, use this. 
 * 
 * @param preferencePageID ID for preference page
 * @param preferencePageTabID ID for preference page tab under preference page with ID <preferencePageID>
 * @param shell {@link Shell}
 */
// Warning comes from org.eclipse.jface.preference.PreferenceManager.getElements(int) because it uses raw List type as return value   
@SuppressWarnings("unchecked")
public static void openPreferencePage(String preferencePageID, String preferencePageTabID, Shell shell) {

    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, preferencePageID, null, null);

    List<IPreferenceNode> elemns = dialog.getPreferenceManager().getElements(PreferenceManager.PRE_ORDER);
    IPreferenceNode preferenceNode = null;
    //check all preference pages, if required is found
    for (Iterator<IPreferenceNode> iterator = elemns.iterator(); iterator.hasNext();) {
        preferenceNode = iterator.next();
        if (preferenceNode.getId().equals(preferencePageTabID)) {
            break;
        }
    }

    //If required preference page tab was found, set that as selection
    if (preferenceNode != null) {
        dialog.getTreeViewer().setSelection(new StructuredSelection(preferenceNode));
    }

    dialog.open();

}

From source file:com.nokia.tools.carbide.ui.productsupport.perspectivehack.CarbideMenuCustomizer.java

License:Open Source License

@Override
protected void customizeMenu(MenuManager mgr) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (MENU_WINDOW.equals(mgr.getId())) {
        // Preference -filter
        replaceAction(mgr, MENU_WINDOW_PREFERENCES, new Runnable() {
            public void run() {
                PreferenceDialog prefdlg = PreferencesUtil.createPreferenceDialogOn(
                        Display.getCurrent().getActiveShell(), GENERAL_PREFERENCES_ID,
                        new String[] { GENERAL_PREFERENCES_ID, EXTERNALTOOLS_PREFERENCES_ID,
                                THIRDPARTYICONS_PREFERENCES_ID, PLUGINHANDLING_PREFERENCES_ID,
                                COMPONENTSTORE_PREFERENCES_ID, PATHHANDLING_PREFERENCES_ID,
                                STARTUPTIPS_PREFERENCES_ID, EXAMPLETHEMES_PREFERENCES_ID
                        /*
                        * UPDATE_INSTALL_PREFERENCES_ID,
                        * AUTOMATIC_UPDATES_PREFERENCES_ID
                        *//*from ww  w .  ja v a 2 s  .c  o  m*/
                }, null);
                PreferenceManager pManager = prefdlg.getPreferenceManager();
                pManager.remove(PREFERENCES_ANT);
                pManager.remove(PREFERENCES_JAVA);
                pManager.remove(PREFERENCES_RUN_DEBUG);
                pManager.remove(PREFERENCES_TEAM);
                prefdlg.open();
            }
        });

        // // Remove Other -command under Show View in Window-menu
        // for (IContributionItem item2 : mgr.getItems()) {
        // if (SHOW_VIEW_ID.equals(item2.getId())) {
        // if (item2 instanceof MenuManager) {
        // MenuManager mgr2 = (MenuManager) item2;
        // mgr2.getMenu().addMenuListener(
        // new MenuAdapter() {
        //
        // /*
        // * (non-Javadoc)
        // *
        // * @see
        // org.eclipse.swt.events.MenuAdapter#menuShown(org.eclipse.swt.events.MenuEvent)
        // */
        // @Override
        // public void menuShown(MenuEvent e) {
        // Menu menu = ((Menu) e.widget);
        // // removes show other and
        // // separator
        // MenuItem[] items = menu
        // .getItems();
        // if (items.length > 2) {
        // items[items.length - 1]
        // .dispose();
        // items[items.length - 2]
        // .dispose();
        // }
        // }
        //
        // });
        // }
        // }
        // }

    } else if (MENU_FILE.equals(mgr.getId())) {
        removePropertiesMenuItem(mgr);
        // Import replacement
        IContributionItem contrib = mgr.find(MENU_FILE_IMPORT);
        if (contrib instanceof ActionContributionItem) {
            mgr.replaceItem(MENU_FILE_IMPORT, new ActionContributionItem(new ImportAction(window)));
        }

        // Export replacement
        contrib = mgr.find(MENU_FILE_EXPORT);
        if (contrib instanceof ActionContributionItem) {
            mgr.replaceItem(MENU_FILE_EXPORT, new ActionContributionItem(new ExportAction(window)));
        }

    } else if (MENU_HELP.equals(mgr.getId())) {
        replaceAction(mgr, MENU_HELP_ABOUT, new Runnable() {
            public void run() {
                new CarbideAboutDialog(Display.getCurrent().getActiveShell()).open();
            }
        });
    }
}

From source file:org.apache.commons.jelly.tags.jface.preference.PreferencePageTag.java

License:Apache License

public void doTag(XMLOutput output) throws JellyTagException {
    // check location
    PreferenceDialogTag dialogTag = (PreferenceDialogTag) findAncestorWithClass(PreferenceDialogTag.class);
    if (dialogTag == null) {
        throw new JellyTagException("This tag must be nested within a <preferenceDialog>");
    }/*  w  w  w.  ja  v  a  2 s  .c  o  m*/

    // check for missing attributes
    if (filename == null) {
        throw new MissingAttributeException("filename");
    }
    if (title == null) {
        throw new MissingAttributeException("title");
    }

    // build new PreferenceNode with same title as the PreferencePage
    PreferenceDialog dialog = dialogTag.getPreferenceDialog();
    PreferenceNode node = new PreferenceNode(title);

    // build new PreferencePage
    page = new PreferencePageImpl(title);

    // add node to PreferenceManager
    node.setPage(page);
    dialog.getPreferenceManager().addToRoot(node);

    // used by PreferencePageImpl
    this.output = output;
}

From source file:org.eclipse.bpmn2.modeler.ui.preferences.Bpmn2HomePreferencePage.java

License:Open Source License

public static IPreferencePage getPage(IPreferencePageContainer container, String nodeId) {
    PreferenceDialog pd = (PreferenceDialog) container;
    PreferenceManager pm = pd.getPreferenceManager();

    List nodes = pm.getElements(PreferenceManager.POST_ORDER);
    for (Iterator i = nodes.iterator(); i.hasNext();) {
        IPreferenceNode node = (IPreferenceNode) i.next();
        if (node.getId().equals(nodeId)) {
            return node.getPage();
        }//from   w  w w  .j a  v a 2s .co  m
    }
    return null;
}

From source file:org.eclipse.dltk.internal.ui.wizards.buildpath.newsourcepage.ConfigureBuildPathAction.java

License:Open Source License

public void run() {
    if (fProject != null) {
        // TODO retrieve the page id via project nature
        PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), fProject, null, null,
                null);//from www  .  j av a2 s.  c  o m
        // search for the language specific page
        final List elements = dialog.getPreferenceManager().getElements(PreferenceManager.PRE_ORDER);
        for (Iterator i = elements.iterator(); i.hasNext();) {
            final IPreferenceNode node = (IPreferenceNode) i.next();
            final String nodeId = node.getId();
            if (nodeId.endsWith("BuildpathProperties")) { //$NON-NLS-1$
                // recreate dialog and select page found
                dialog.close();
                dialog = PreferencesUtil.createPropertyDialogOn(getShell(), fProject, nodeId, null, null);
                break;
            }
        }
        dialog.open();
    }
}

From source file:org.eclipse.php.internal.ui.actions.ConfigurePHPIncludePathAction.java

License:Open Source License

public void run() {
    if (fProject != null) {
        // TODO retrieve the page id via project nature
        PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), fProject, null, null,
                null);//from   w w  w  .  ja  v a2s .  co  m
        // search for the language specific page
        final List elements = dialog.getPreferenceManager().getElements(PreferenceManager.PRE_ORDER);
        for (Iterator i = elements.iterator(); i.hasNext();) {
            final IPreferenceNode node = (IPreferenceNode) i.next();
            final String nodeId = node.getId();
            if (nodeId.endsWith("IncludepathProperties")) { //$NON-NLS-1$
                // recreate dialog and select page found
                dialog.close();
                dialog = PreferencesUtil.createPropertyDialogOn(getShell(), fProject, nodeId, null, null);
                break;
            }
        }
        dialog.open();
    }
}