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

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

Introduction

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

Prototype

public void addToRoot(IPreferenceNode node) 

Source Link

Document

Adds the given preference node as a subnode of the root.

Usage

From source file:com.aptana.js.debug.ui.internal.actions.DetailOptionsActionDelegate.java

License:Open Source License

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *///from  w w w  .j  a  va 2s  .c  o m
public void run(IAction action) {
    final IPreferenceNode targetNode = new PreferenceNode("com.aptana.debug.ui.preferences.jsDetailFormatters", //$NON-NLS-1$
            new JSDetailFormattersPreferencePage());

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(UIUtils.getActiveShell(), manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(DebugUiPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
}

From source file:com.bdaum.overlayPages.FieldEditorOverlayPage.java

License:Open Source License

/**
 * Show a single preference pages/*ww  w  . j  a v  a 2  s.c  o  m*/
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(final String id, final IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    final PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:com.blackducksoftware.integration.eclipseplugin.popupmenu.handlers.OpenProjectPreferences.java

License:Apache License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    final PreferenceManager mgr = new PreferenceManager(preferencePathSeparatorCharacter);

    final DependencyInformationService depService = new DependencyInformationService();
    final FilePathGavExtractor extractor = new FilePathGavExtractor();
    final ProjectInformationService projService = new ProjectInformationService(depService, extractor);
    final WorkspaceInformationService workspaceService = new WorkspaceInformationService(projService);

    final String projectPrefId = workspaceService.getSelectedProject();
    final IndividualProjectPreferences prefPage = new IndividualProjectPreferences(projectPrefId,
            projectPrefId);//www . j  a  v  a  2 s.  c o  m
    final PreferenceNode prefNode = new PreferenceNode(projectPrefId, prefPage);
    mgr.addToRoot(prefNode);
    final PreferenceDialog prefDialog = new PreferenceDialog(activeShell, mgr);
    prefDialog.open();
    return null;
}

From source file:com.iw.plugins.spindle.ui.util.UIUtils.java

License:Mozilla Public License

public static boolean showPreferencePage(Shell shell, String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
        public void run() {
            dialog.create();/*from   w ww .  ja v a2  s . c  om*/
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
    return result[0];
}

From source file:com.liferay.ide.ui.util.SWTUtil.java

License:Open Source License

public static boolean showPreferencePage(String id, Shell shell) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage") //$NON-NLS-1$
            .findSubNode(id);/*  w w  w.  ja v a  2  s  .c o  m*/
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(shell, manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}

From source file:com.mentor.nucleus.bp.core.CorePlugin.java

License:Open Source License

public static PreferenceManager getProjectPreferenceManager(Preferences projectNode) {
    PreferenceManager pm = new PreferenceManager();
    PreferenceNode pn = new BridgePointProjectReferencesPreferenceNode(projectNode);
    pm.addToRoot(pn);
    pn = new BridgePointProjectActionLanguagePreferenceNode(projectNode);
    pm.addToRoot(pn);//from  ww  w . ja v  a2 s  .  c  o m
    return pm;
}

From source file:com.microsoft.azuretools.core.utils.PluginUtil.java

License:Open Source License

/**
 * Method opens property dialog with only desired property page.
 *
 * @param nodeId/*  w ww  .j a va  2s .  co m*/
 *            : Node ID of property page
 * @param nodeLbl
 *            : Property page name
 * @param classObj
 *            : Class object of property page
 * @return
 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
         * If showing storage accounts preference page, don't show
         * properties for title as its common repository.
         */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName());
        }
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(PluginUtil.getParentShell(), Messages.rolsDlgErr,
                Messages.projDlgErrMsg, e);
    }
    return retVal;
}

From source file:com.microsoftopentechnologies.wacommon.utils.PluginUtil.java

License:Open Source License

/**
 * Method opens property dialog with only desired property page.
 * /*  www  .j av a2s . com*/
 * @param nodeId
 *            : Node ID of property page
 * @param nodeLbl
 *            : Property page name
 * @param classObj
 *            : Class object of property page
 * @return
 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
         * If showing storage accounts preference page, don't show
         * properties for title as its common repository.
         */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName());
        }
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e);
    }
    return retVal;
}

From source file:com.mindquarry.desktop.preferences.PreferenceUtilities.java

License:Open Source License

public static PreferenceManager getDefaultPreferenceManager() {
    PreferenceManager mgr = new PreferenceManager();

    GeneralSettingsPage general = new GeneralSettingsPage();
    mgr.addToRoot(new PreferenceNode(GeneralSettingsPage.NAME, general));

    ServerProfilesPage profiles = new ServerProfilesPage();
    PreferenceNode profilesNode = new PreferenceNode(ServerProfilesPage.NAME, profiles);
    mgr.addToRoot(profilesNode);/*from   w w  w. j a va  2  s .  c  o m*/

    ProxySettingsPage proxy = new ProxySettingsPage();
    mgr.addToRoot(new PreferenceNode(ProxySettingsPage.NAME, proxy));

    return mgr;
}

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
 *//* w  w w.  j  a  v a2s  . co  m*/
@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();
}