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

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

Introduction

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

Prototype

public boolean remove(IPreferenceNode node) 

Source Link

Document

Removes the given preference node if it is managed by this contribution manager.

Usage

From source file:gov.nasa.ensemble.core.rcp.EnsembleWorkbenchWindowAdvisor.java

License:Open Source License

protected final void cleanupPreferencePages() {
    Collection<Pattern> patterns = new HashSet<Pattern>();
    for (String s : getUndesirablePreferencePageIDRegExes())
        patterns.add(Pattern.compile(s));
    if (patterns.size() == 0)
        return;/*from  w  w  w  .  j  a  va  2  s  .c  om*/
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    for (IPreferenceNode node : manager.getRootSubNodes()) {
        for (Pattern pattern : patterns) {
            if (pattern.matcher(node.getId()).matches()) {
                manager.remove(node);
                continue;
            }
        }
        cleanupPreferencePages(node, patterns);
    }
}

From source file:gov.nasa.ensemble.core.rcp.EnsembleWorkbenchWindowAdvisor.java

License:Open Source License

protected final void moveAdvancedPreferencesPages() {
    Collection<Pattern> patterns = new HashSet<Pattern>();
    for (String s : getAdvancedPreferenceRegExp())
        patterns.add(Pattern.compile(s));
    if (patterns.size() == 0)
        return;//from   w ww  .j  ava 2 s.  c o m

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode[] rootSubNodes = manager.getRootSubNodes();

    PreferenceNode advanced = null;
    Pattern advancePattern = Pattern.compile("AdvancedPreferenceNode");
    for (IPreferenceNode node : rootSubNodes) {
        if (advancePattern.matcher(node.getId()).matches()) {
            advanced = (PreferenceNode) node;
            break;
        }
    }
    if (advanced == null)
        return;

    for (IPreferenceNode node : rootSubNodes) {
        for (Pattern pattern : patterns) {
            if (pattern.matcher(node.getId()).matches()) {
                manager.remove(node);
                advanced.add(node);
                continue;
            }
        }
    }

}

From source file:msi.gama.gui.views.GamaPreferencesView.java

License:Open Source License

private GamaPreferencesView(final Shell parent) {
    parentShell = parent;/*  ww  w .ja va2  s  .  co  m*/
    shell = new Shell(parentShell, SWT.TITLE | SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.SHEET);
    final GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = gridLayout.marginHeight = 5;
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 5;
    shell.setLayout(gridLayout);
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();

    // We clean the default preference manager to remove useless preferences
    for (Object elem : preferenceManager.getElements(PreferenceManager.POST_ORDER)) {
        if (elem instanceof IPreferenceNode) {
            String id = ((IPreferenceNode) elem).getId();
            if (preferenceNames.containsKey(id)) {
                preferencePages.put(preferenceNames.get(id), (IPreferenceNode) elem);
            }
            if (id.contains("debug.ui") || id.contains("help.ui") || id.contains("search")
                    || id.contains("Spelling") || id.contains("Linked") || id.contains("Perspectives")
                    || id.contains("Content")) {
                preferenceManager.remove((IPreferenceNode) elem);
            }
            // GuiUtils.debug(((IPreferenceNode) elem).getId());
            // preferenceManager.remove((IPreferenceNode) elem);
        }
    }
    buildContents();
}

From source file:net.sf.logsaw.rcp.ApplicationWorkbenchAdvisor.java

License:Open Source License

@Override
public void postStartup() {
    // Remove the 'Available Software Sites' preference page
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
    pm.remove(
            "org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage/org.eclipse.equinox.internal.p2.ui.sdk.SitesPreferencePage"); //$NON-NLS-1$
}

From source file:org.eclipse.oomph.setup.ui.SetupUIPlugin.java

License:Open Source License

static void performStartup() {
    if (!PropertiesUtil.isProperty(PREF_HEADLESS)) {
        // These are only to force class loading on a background thread.
        SynchronizerManager.INSTANCE.toString();
        SetupTaskPerformer.RULE_VARIABLE_ADAPTER.toString();
        RecorderManager.INSTANCE.toString();

        final Display display = Display.getDefault();
        display.asyncExec(new Runnable() {
            public void run() {
                if (!isInstallerProduct()) {
                    SetupPropertyTester.setStarting(true);

                    final IWorkbench workbench = PlatformUI.getWorkbench();
                    IExtensionTracker extensionTracker = workbench.getExtensionTracker();
                    if (extensionTracker == null || workbench.getWorkbenchWindowCount() == 0) {
                        display.timerExec(1000, this);
                    } else {
                        if (!SynchronizerManager.ENABLED) {
                            PreferenceManager preferenceManager = workbench.getPreferenceManager();
                            preferenceManager.remove("/" + OomphPreferencePage.ID + "/" + SetupPreferencePage.ID
                                    + "/" + SynchronizerPreferencePage.ID);
                        }/*  w ww  .ja  v a 2 s  . c  om*/

                        if (SetupTaskPerformer.REMOTE_DEBUG) {
                            MessageDialog.openInformation(UIUtil.getShell(), "Remote Debug Pause",
                                    "The setup tasks are paused to allow you to attach a remote debugger");
                        }

                        if (Platform.OS_MACOSX.equals(Platform.getOS())) {
                            new TaskItemDecorator();
                        }

                        RecorderManager.Lifecycle.start(display);
                        plugin.stopRecorder = true;

                        if (!SETUP_SKIP && !isSkipStartupTasks()) {
                            new Job("Setup check") {
                                @Override
                                protected IStatus run(IProgressMonitor monitor) {
                                    try {
                                        performStartup(workbench, monitor);
                                        return Status.OK_STATUS;
                                    } finally {
                                        SetupPropertyTester.setStarting(false);
                                    }
                                }
                            }.schedule();
                        } else {
                            Job mirrorJob = new Job("Initialize Setup Models") {
                                @Override
                                protected IStatus run(IProgressMonitor monitor) {
                                    try {
                                        monitor.beginTask("Loading resources", 10);

                                        ResourceSet resourceSet = SetupCoreUtil.createResourceSet();
                                        resourceSet.getLoadOptions().put(
                                                ECFURIHandlerImpl.OPTION_CACHE_HANDLING,
                                                CacheHandling.CACHE_WITHOUT_ETAG_CHECKING);
                                        mirror(resourceSet, monitor, 10);
                                        SetupContext.setSelf(SetupContext.createSelf(resourceSet));

                                        return Status.OK_STATUS;
                                    } finally {
                                        SetupPropertyTester.setStarting(false);
                                    }
                                }
                            };

                            mirrorJob.schedule();
                        }
                    }
                }
            }
        });
    }
}

From source file:org.eclipse.ui.tests.preferences.PreferencesDialogTest.java

License:Open Source License

/**
 * Test preference dialog with a Workbench manager adding custom nodes to it.
 *//* w  ww .j  a va 2  s. c  o m*/
public void testMixedNodes() {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();

    IPreferencePage page1 = new SamplePreferencePage("Top", "First Sample");
    IPreferenceNode node1 = new PreferenceNode("Top", page1);
    manager.addToRoot(node1);

    IPreferencePage page2 = new SamplePreferencePage("Sub", "Second Sample");
    IPreferenceNode node2 = new PreferenceNode("Sub", page2);
    manager.addToRoot(node2);

    PreferenceDialog dialog = null;
    try {
        dialog = new PreferenceDialog(shell, manager);
        dialog.setBlockOnOpen(false);

        // Check that we can create a dialog with custom preference manager.
        // Should be no exceptions.
        dialog.open();
    } finally {
        if (dialog != null)
            dialog.close();
        manager.remove(node2);
        manager.remove(node1);
    }
}

From source file:org.jkiss.dbeaver.core.application.ApplicationWorkbenchAdvisor.java

License:Open Source License

@Override
public void postStartup() {
    super.postStartup();

    // Remove unneeded pref pages
    PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
    for (String epp : EXCLUDE_PREF_PAGES) {
        pm.remove(epp);
    }//from   w  w w .  ja  v a  2s . c o m

    startVersionChecker();
}

From source file:org.mwc.debrief.core.Startup.java

License:Open Source License

private void removePreferencePages() {
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
    if (preferenceManager == null) {
        return;//from www  .j  a  v  a2s. co m
    }
    preferenceManager.remove("org.eclipse.debug.ui.DebugPreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.LaunchingPreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.ViewManagementPreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.ConsolePreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.StringVariablePreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.PerspectivePreferencePage");
    preferenceManager.remove("org.eclipse.debug.ui.LaunchConfigurations");
    preferenceManager.remove("org.eclipse.debug.ui.LaunchDelegatesPreferencePage");
    preferenceManager.remove("org.eclipse.team.ui.TeamPreferences");
    preferenceManager.remove("org.eclipse.wst.xml.ui.propertyPage.project.validation");
}

From source file:org.talend.commons.ui.utils.workbench.preferences.PreferencesHelper.java

License:Open Source License

/**
 * /*  w w  w .  j  ava 2 s. c  o  m*/
 * Use the BFS(Breadth First Search) to remove the preferences ids.
 */
public static boolean removePages(String[] prefIds) {
    if (prefIds == null || prefIds.length == 0) {
        return false;
    }
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();

    List<String> removedIds = new ArrayList<String>();
    IPreferenceNode[] rootSubNodes = preferenceManager.getRootSubNodes();
    for (IPreferenceNode node : rootSubNodes) {
        String id = node.getId();
        if (ArrayUtils.contains(prefIds, id)) {
            preferenceManager.remove(node);
            removedIds.add(id);
        }
    }
    // do for children
    for (IPreferenceNode node : rootSubNodes) {
        removePages(node, prefIds, removedIds);
    }
    //
    List<String> doList = new ArrayList<String>(Arrays.asList(prefIds));
    doList.removeAll(removedIds);

    return doList.isEmpty(); // have done for all, so empty.
}

From source file:org.talend.dataprofiler.rcp.intro.ApplicationWorkbenchWindowAdvisor.java

License:Open Source License

@SuppressWarnings("restriction")
@Override//  w ww.  j  a va 2  s . co  m
public void postWindowOpen() {

    this.getWindowConfigurer().getWindow().getShell().setMaximized(true);
    super.postWindowOpen();
    ChangePerspectiveAction.getAction().switchTitle();

    IWorkbenchWindowConfigurer workbenchWindowConfigurer = getWindowConfigurer();

    // hide Preference page
    PreferenceManager preferenceManager = workbenchWindowConfigurer.getWindow().getWorkbench()
            .getPreferenceManager();
    preferenceManager.remove(
            "org.eclipse.debug.ui.DebugPreferencePage" + WorkbenchPlugin.PREFERENCE_PAGE_CATEGORY_SEPARATOR
                    + "org.eclipse.ui.externaltools.ExternalToolsPreferencePage");

    // hide toolBar item
    IActionBarConfigurer actionBarConfigurer = workbenchWindowConfigurer.getActionBarConfigurer();
    ICoolBarManager coolBarManager = actionBarConfigurer.getCoolBarManager();
    IContributionItem toolBarItem = coolBarManager.find("org.eclipse.debug.ui.launchActionSet");
    if (toolBarItem != null) {
        coolBarManager.remove(toolBarItem);
    }

    // hide run menu
    // hide Help->Install New Software and Help->Check For Updates
    // hide File->Open File...
    IMenuManager menuManager = actionBarConfigurer.getMenuManager();
    IContributionItem[] menuItems = menuManager.getItems();
    for (IContributionItem menuItem : menuItems) {
        // Hack to remove the Run menu - it seems you cannot do this using the
        // "org.eclipse.ui.activities" extension
        // Hack to remove the Navigate menu -which can't be removed by "org.eclipse.ui.activities
        if ("org.eclipse.ui.run".equals(menuItem.getId()) || "navigate".equals(menuItem.getId())) { //$NON-NLS-1$//$NON-NLS-2$
            menuManager.remove(menuItem);
        }
        if ("file".equals(menuItem.getId())) { //$NON-NLS-1$
            hideFileActions(menuItem);
        }
        if ("help".equals(menuItem.getId())) { //$NON-NLS-1$
            hideHelpActions(menuItem);
        }
    }
    ITDQRepositoryService tdqRepositoryService = (ITDQRepositoryService) org.talend.core.GlobalServiceRegister
            .getDefault().getService(ITDQRepositoryService.class);
    if (tdqRepositoryService != null) {
        tdqRepositoryService.addPartListener();
        tdqRepositoryService.addSoftwareSystemUpdateListener();
    }

}