org.eclipse.jface.preference.PreferenceManager Java Examples

The following examples show how to use org.eclipse.jface.preference.PreferenceManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: E4PreferencesHandler.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Optional PreferenceManager pm, MApplication appli)
{
	// Manage the possible null pm (case of pure E4 application. With E3 it
	// will be initialized by org.eclipse.ui.internal.WorkbenchPlugin
	// see line 1536
	if (pm == null)
	{
		pm = new E4PrefManager();
		E4PreferenceRegistry registry = new E4PreferenceRegistry();
		IEclipseContext appliContext = appli.getContext();
		registry.populatePrefManagerWithE4Extensions(pm, appliContext);
		appliContext.set(PreferenceManager.class, pm);
	}
	
	// Can display the standard dialog.
	PreferenceDialog dialog = new PreferenceDialog(shell, pm);
	dialog.create();
	dialog.getTreeViewer().setComparator(new ViewerComparator());
	dialog.getTreeViewer().expandAll();
	dialog.open();
}
 
Example #2
Source File: PropertyLinkArea.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private IPreferenceNode getPreferenceNode(String pageId)
{
	/*
	 * code pulled from org.eclipse.ui.internal.dialogs.PropertyDialog - i'm not sure why this type of class doesn't
	 * already exist for property pages like it does for preference pages since it seems it would be very useful -
	 * guess we're breaking new ground :)
	 */
	PropertyPageManager pageManager = new PropertyPageManager();
	PropertyPageContributorManager.getManager().contribute(pageManager, element);

	Iterator pages = pageManager.getElements(PreferenceManager.PRE_ORDER).iterator();

	while (pages.hasNext())
	{
		IPreferenceNode node = (IPreferenceNode) pages.next();
		if (node.getId().equals(pageId))
		{
			return node;
		}
	}

	return null;
}
 
Example #3
Source File: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
 * 
 * @param id
 *            the id of pref page to show
 * @param page
 *            the actual page to show Copied from org.eclipse.debug.internal.ui.SWTUtil
 */
public static void showPreferencePage(String id, IPreferencePage page)
{
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(UIUtils.getActiveShell(), manager);
	BusyIndicator.showWhile(getStandardDisplay(), new Runnable()
	{
		public void run()
		{
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example #4
Source File: CppStylePropertyPage.java    From CppStyle with MIT License 5 votes vote down vote up
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(getControl()
			.getShell(), manager);
	BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
		public void run() {
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example #5
Source File: AnnotationStyleViewPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
        IStatusLineManager statusLineManager) {
  super.makeContributions(menuManager, toolBarManager, statusLineManager);
  
  // TODO: Figure out how to use open properties dialog action here correctly
  // see http://wiki.eclipse.org/FAQ_How_do_I_open_a_Property_dialog%3F
  
  IAction action = new Action() {
    @Override
    public void run() {
      super.run();
      
      ISelection sel = new StructuredSelection(new AnnotationTypeNode(editor, null));
      PropertyPage page = new EditorAnnotationPropertyPage();
      page.setElement(new AnnotationTypeNode(editor, null));
      page.setTitle("Styles");
      PreferenceManager mgr = new PreferenceManager();
      IPreferenceNode node = new PreferenceNode("1", page);
      mgr.addToRoot(node);
      PropertyDialog dialog = new PropertyDialog(getSite().getShell(), mgr, sel);
      dialog.create();
      dialog.setMessage(page.getTitle());
      dialog.open();
    }
  };
  
  action.setImageDescriptor(CasEditorPlugin
          .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
  
  toolBarManager.add(action);
}
 
Example #6
Source File: PreferenceUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static IPreferenceNode findNodeMatching(String nodeId) {
    List<?> nodes = PlatformUI.getWorkbench().getPreferenceManager().getElements(PreferenceManager.POST_ORDER);
    for (Iterator<?> i = nodes.iterator(); i.hasNext();) {
        final IPreferenceNode node = (IPreferenceNode) i.next();
        if (node.getId().equals(nodeId)) {
            return node;
        }
    }
    return null;
}
 
Example #7
Source File: E4PreferenceRegistry.java    From e4Preferences with Eclipse Public License 1.0 5 votes vote down vote up
private 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;
		}
	}
	return null;
}
 
Example #8
Source File: PreviewPreferencePage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private IPreferenceNode getPreferenceNode( String pageId )
{
	Iterator iterator = PlatformUI.getWorkbench( )
			.getPreferenceManager( )
			.getElements( PreferenceManager.PRE_ORDER )
			.iterator( );
	while ( iterator.hasNext( ) )
	{
		IPreferenceNode next = (IPreferenceNode) iterator.next( );
		if ( next.getId( ).equals( pageId ) )
			return next;
	}
	return null;
}
 
Example #9
Source File: Preferences.java    From Rel with Apache License 2.0 5 votes vote down vote up
public Preferences(Shell parent) {
PreferenceManager preferenceManager = new PreferenceManager();

PreferenceNode general = new PreferenceNode("General", new PreferencePageGeneral());
preferenceManager.addToRoot(general);

PreferenceNode cmd = new PreferenceNode("Command line", new PreferencePageCmd());
preferenceManager.addToRoot(cmd);

PreferenceNode display = new PreferenceNode("Display", new PreferencePageDisplay());
preferenceManager.addToRoot(display);

preferenceDialog = new PreferenceDialog(parent, preferenceManager);
preferenceDialog.setPreferenceStore(preferences);
}
 
Example #10
Source File: ApplicationWorkbenchAdvisor.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void postStartup() {
	PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
	pm.remove("org.eclipse.ui.preferencePages.Workbench");
	pm.remove("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage");
	pm.remove("org.eclipse.team.ui.TeamPreferences");
	pm.remove("org.eclipse.debug.ui.DebugPreferencePage");
	
	super.postStartup();
}
 
Example #11
Source File: PropToPrefLinkArea.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
private IPreferenceNode getPreferenceNode(String pageId)
{
	Iterator iterator = PlatformUI.getWorkbench().getPreferenceManager().getElements(PreferenceManager.PRE_ORDER)
			.iterator();
	while (iterator.hasNext())
	{
		IPreferenceNode next = (IPreferenceNode) iterator.next();
		if (next.getId().equals(pageId))
		{
			return next;
		}
	}
	return null;
}
 
Example #12
Source File: FieldEditorOverlayPage.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(getControl()
			.getShell(), manager);
	BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
		public void run() {
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example #13
Source File: HsPreferenceDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public HsPreferenceDialog(Shell parentShell, PreferenceManager manager) {
	super(parentShell, manager);
	setMinimumPageSize(450, 450);
}
 
Example #14
Source File: ProjectSettingDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public ProjectSettingDialog(Shell parentShell, PreferenceManager manager) {
	super(parentShell, manager);
	this.preferenceManager = manager;
	setMinimumPageSize(600, 400);
	setHelpAvailable(true);
}
 
Example #15
Source File: Config.java    From pmTrans with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void showConfigurationDialog(Shell parent) throws PmTransException {
	// Create the preference manager
	PreferenceManager mgr = new PreferenceManager();

	// Create the nodes
	PreferenceNode playbackNode = new PreferenceNode("playbackPreferences");
	PreferencePage playbackPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new IntegerFieldEditor(SHORT_REWIND,
					"Short rewind duration (in sec)",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(LONG_REWIND,
					"Long rewind duration (in sec)", getFieldEditorParent()));
			addField(new IntegerFieldEditor(REWIND_AND_PLAY,
					"Rewind-and-resume duartion duration (in sec)",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(LOOP_FRECUENCY,
					"Loops frecuency (in seconds)", getFieldEditorParent()));
			addField(new IntegerFieldEditor(LOOP_LENGHT,
					"Loop rewind lenght (in seconds)",
					getFieldEditorParent()));
		}
	};
	playbackPage.setTitle("Playback preferences");
	playbackNode.setPage(playbackPage);

	PreferenceNode shortcutsNode = new PreferenceNode(
			"shortcutsPreferences");
	PreferencePage shortcutsPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new ShortcutFieldEditor(SHORT_REWIND_KEY,
					"Short rewind", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(LONG_REWIND_KEY,
					"Long rewind", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(PAUSE_KEY, "Pause and resume",
					getFieldEditorParent()));
			addField(new ShortcutFieldEditor(AUDIO_LOOPS_KEY,
					"Enable audio loops", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(SLOW_DOWN_KEY,
					"Slow down audio playback", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(SPEED_UP_KEY,
					"Speed up audio playback", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(TIMESTAMP_KEY,
					"Insert timestamp", getFieldEditorParent()));
		}
	};
	shortcutsPage.setTitle("Shortcuts preferences");
	shortcutsNode.setPage(shortcutsPage);

	PreferenceNode generalNode = new PreferenceNode("generalPreferences");
	PreferencePage generalPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new IntegerFieldEditor(AUDIO_FILE_CACHE_LENGHT,
					"Max size of the \"recent audio files\" list",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(TEXT_FILE_CACHE_LENGHT,
					"Max size of the \"recent text files\" list",
					getFieldEditorParent()));
			// TODO add a separator here
			addField(new BooleanFieldEditor(AUTO_SAVE, "Auto save",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(AUTO_SAVE_TIME,
					"Auto save frecuency (in minutes)",
					getFieldEditorParent()));
		}
	};
	generalPage.setTitle("General preferences");
	generalNode.setPage(generalPage);

	mgr.addToRoot(playbackNode);
	mgr.addToRoot(shortcutsNode);
	mgr.addToRoot(generalNode);
	PreferenceDialog dlg = new PreferenceDialog(parent, mgr);
	dlg.setPreferenceStore(this);

	if (dlg.open() == PreferenceDialog.OK)
		try {
			save();
		} catch (IOException e) {
			throw new PmTransException("Unable to save preferences", e);
		}
}
 
Example #16
Source File: PreferenceUtil.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public static void openPreferenceDialog(IWorkbenchWindow window, final String defaultId) {
	PreferenceManager mgr = window.getWorkbench().getPreferenceManager();
	mgr.remove("net.heartsome.cat.ui.preferencePages.Perspectives");
	mgr.remove("org.eclipse.ui.preferencePages.Workbench");
	mgr.remove("org.eclipse.update.internal.ui.preferences.MainPreferencePage");
	mgr.remove("org.eclipse.help.ui.browsersPreferencePage");
	final Object[] defaultNode = new Object[1];
	HsPreferenceDialog dlg = new HsPreferenceDialog(window.getShell(), mgr);
	dlg.create();

	final List<Image> imageList = new ArrayList<Image>();
	dlg.getTreeViewer().setLabelProvider(new PreferenceLabelProvider() {
		public Image getImage(Object element) {
			String id = ((IPreferenceNode) element).getId();
			if (defaultId != null && id.equals(defaultId)) {
				defaultNode[0] = element;
			}
			Image image = null;
			if (SystemPreferencePage.ID.equals(id)) {
				// 系统菜单
				image = Activator.getImageDescriptor("images/preference/system/system.png").createImage();
				imageList.add(image);
				return image;
			} else if ("org.eclipse.ui.preferencePages.Keys".equals(id)) {
				// 系统 > 快捷键菜单
				image = Activator.getImageDescriptor("images/preference/system/keys.png").createImage();
				imageList.add(image);
				return image;
			} else if ("org.eclipse.ui.net.proxy_preference_page_context".equals(id)) {
				// 网络连接
				image = Activator.getImageDescriptor("images/preference/system/network.png").createImage();
				imageList.add(image);
				return image;
			}  else {
				return null;
			}
		}
	});

	if (defaultNode[0] != null) {
		dlg.getTreeViewer().setSelection(new StructuredSelection(defaultNode), true);
		dlg.getTreeViewer().getControl().setFocus();
	}

	dlg.open();

	// 清理资源
	for (Image img : imageList) {
		if (img != null && !img.isDisposed()) {
			img.dispose();
		}
	}
	imageList.clear();
}
 
Example #17
Source File: ProjectSettingDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public ProjectSettingDialog(Shell parentShell, PreferenceManager manager) {
	super(parentShell, manager);
	this.preferenceManager = manager;
	setMinimumPageSize(600, 400);
	setHelpAvailable(true);
}
 
Example #18
Source File: HsPreferenceDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public HsPreferenceDialog(Shell parentShell, PreferenceManager manager) {
	super(parentShell, manager);
	setMinimumPageSize(450, 450);
}
 
Example #19
Source File: StyleBuilder.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private static PreferenceManager createPreferenceManager(
		ReportElementHandle handle, AbstractThemeHandle theme )
{
	PreferenceManager preferenceManager = new PreferenceManager( '/' );

	// Get the pages from the registry
	List<IPreferenceNode> pageContributions = new ArrayList<IPreferenceNode>( );

	// adds preference pages into page contributions.
	pageContributions.add( new StylePreferenceNode( "General", //$NON-NLS-1$
			new GeneralPreferencePage( handle, theme ) ) );
	pageContributions.add( new StylePreferenceNode( "Font", //$NON-NLS-1$
			new FontPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Size", //$NON-NLS-1$
			new SizePreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Background", //$NON-NLS-1$
			new BackgroundPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Block", //$NON-NLS-1$
			new BlockPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Box", //$NON-NLS-1$
			new BoxPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Border", //$NON-NLS-1$
			new BorderPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Number Format", //$NON-NLS-1$
			new FormatNumberPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "DateTime Format", //$NON-NLS-1$
			new FormatDateTimePreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "String Format", //$NON-NLS-1$
			new FormatStringPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "PageBreak", //$NON-NLS-1$
			new PageBreakPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Map", //$NON-NLS-1$
			new MapPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Highlights", //$NON-NLS-1$
			new HighlightsPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Comments", //$NON-NLS-1$
			new CommentsPreferencePage( handle ) ) );

	// Add the contributions to the manager
	Iterator<IPreferenceNode> it = pageContributions.iterator( );
	while ( it.hasNext( ) )
	{
		IPreferenceNode node = it.next( );
		preferenceManager.addToRoot( node );
	}
	return preferenceManager;
}
 
Example #20
Source File: BonitaPreferenceDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createOtherCategoryLine(final Composite menuComposite) {
    final Composite otherRowComposite = createRow(menuComposite, null, Messages.BonitaPreferenceDialog_Other, 3);

    final ToolItem tltmValidation = createTool(otherRowComposite, null, Pics.getImage(PicsConstants.validation),
            Pics.getImage(PicsConstants.validationDisabled), CONSTRAINTS_PAGE_ID);

    final ToolItem tltmAdvancedSettings = createTool(otherRowComposite, null,
            Pics.getImage(PicsConstants.preferenceAdvanced),
            Pics.getImage(PicsConstants.preferenceAdvanceddisabled), ADVANCED_PAGE_ID);

    final ToolItem eclipseItem = createTool(otherRowComposite, null, Pics.getImage(PicsConstants.preferenceEclipse),
            Pics.getImage(PicsConstants.preferenceEclipseDisabled), null);
    eclipseItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {

            final Set<String> preferencesToShow = new HashSet<>();
            for (final Object elem : PlatformUI.getWorkbench().getPreferenceManager()
                    .getElements(PreferenceManager.POST_ORDER)) {
                if (elem instanceof IPreferenceNode) {
                    //REMOVE BONITA PREFS
                    if (!((IPreferenceNode) elem).getId().contains("org.bonitasoft")) {
                        preferencesToShow.add(((IPreferenceNode) elem).getId());
                    }
                }
            }

            final WorkbenchPreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(null, null);
            dialog.showOnly(preferencesToShow.toArray(new String[] {}));
            dialog.open();
        }
    });

    final Label lblValidation = createItemLabel(otherRowComposite, null, Messages.BonitaPreferenceDialog_Validation);
    final Label lblAdvanced = createItemLabel(otherRowComposite, null, Messages.BonitaPreferenceDialog_Advanced);
    final Label eclipseLabel = createItemLabel(otherRowComposite, null, Messages.EclipsePreferences);

    putInItemPerPreferenceNode(CONSTRAINTS_PAGE_ID, tltmValidation);
    putInLabelPerPreferenceNode(CONSTRAINTS_PAGE_ID, lblValidation);

    putInItemPerPreferenceNode(ADVANCED_PAGE_ID, tltmAdvancedSettings);
    putInLabelPerPreferenceNode(ADVANCED_PAGE_ID, lblAdvanced);

    putInItemPerPreferenceNode(ECLIPSE_PAGE_ID, eclipseItem);
    putInLabelPerPreferenceNode(ECLIPSE_PAGE_ID, eclipseLabel);
}
 
Example #21
Source File: ApplicationWorkbenchWindowAdvisor.java    From tlaplus with MIT License 4 votes vote down vote up
public void postWindowOpen() {
	final PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
	final IPreferenceNode[] rootSubNodes = preferenceManager.getRootSubNodes();

	// @see Bug #191 in general/bugzilla/index.html
	final List<String> filters = new ArrayList<String>();
	filters.add("org.eclipse.compare");
	// The following three preferences are shown because the Toolbox uses
	// the local history feature provided by o.e.team.ui
	filters.add("org.eclipse.team.ui");
	filters.add("org.eclipse.ui.trace");
	filters.add("org.eclipse.jsch.ui");

	// Filter out Pdf4Eclipse preference page.
	filters.add("de.vonloesch.pdf4Eclipse");
	
	// Filter out GraphViz
	filters.add("com.abstratt.graphviz.ui");
	
	// Clean the preferences
	final List<IPreferenceNode> elements = preferenceManager.getElements(PreferenceManager.POST_ORDER);
	for (Iterator<IPreferenceNode> iterator = elements.iterator(); iterator.hasNext();) {
		final IPreferenceNode elem = iterator.next();
		if (elem instanceof IPluginContribution) {
			final IPluginContribution aPluginContribution = (IPluginContribution) elem;
			if (filters.contains(aPluginContribution.getPluginId())) {
				final IPreferenceNode node = (IPreferenceNode) elem;

				// remove from root node
				preferenceManager.remove(node);

				// remove from all subnodes
				for (int i = 0; i < rootSubNodes.length; i++) {
					final IPreferenceNode subNode = rootSubNodes[i];
					subNode.remove(node);
				}
			}
		}
	}
	super.postWindowOpen();
	
	// At this point in time we can be certain that the UI is fully
	// instantiated (views, editors, menus...). Thus, register
	// listeners that connect the UI to the workspace resources.
	ToolboxLifecycleParticipantManger.postWorkbenchWindowOpen();
}
 
Example #22
Source File: UnwantedPreferenceManager.java    From tlaplus with MIT License 4 votes vote down vote up
public void initialize()
{
    if (Activator.getDefault().getWorkbench() == null)
    {
        return;
    }
    PreferenceManager pm = Activator.getDefault().getWorkbench().getPreferenceManager();

    if (pm != null)
    {
        /*
         * Subpages need to be removed by calling the remove method
         * on their parent. Pages with no parent can be removed
         * by calling the remove method on the preference manager.
         * 
         * Getting the appropriate id of the page to remove can be done
         * using the code that is commented at the end of this method.
         * It will print out the name followed by the id of every preference page.
         */
        IPreferenceNode generalNode = pm.find("org.eclipse.ui.preferencePages.Workbench");
        if (generalNode != null)
        {
            // these are sub pages of general that we want removed
            generalNode.remove("org.eclipse.ui.preferencePages.Workspace");
            generalNode.remove("org.eclipse.ui.preferencePages.ContentTypes");
            // We no longer want to remove this node.
            // We only want to remove one of its sub nodes.
            // generalNode.remove("org.eclipse.ui.preferencePages.Views");
            // we only want to remove some subnodes of the Editors page
            IPreferenceNode editorsNode = generalNode.findSubNode("org.eclipse.ui.preferencePages.Editors");
            if (editorsNode != null)
            {
                // remove File Associations page
                editorsNode.remove("org.eclipse.ui.preferencePages.FileEditors");
                // want to remove only some subnodes of the Text Editors page
                IPreferenceNode textEditorsNode = editorsNode
                        .findSubNode("org.eclipse.ui.preferencePages.GeneralTextEditor");
                if (textEditorsNode != null)
                {
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.Spelling");
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.QuickDiff");
                    textEditorsNode.remove("org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage");
                }
            }
            generalNode.remove("org.eclipse.ui.preferencePages.Perspectives");
            generalNode.remove("org.eclipse.equinox.security.ui.category");
            IPreferenceNode appearanceNode = generalNode.findSubNode("org.eclipse.ui.preferencePages.Views");
            if (appearanceNode != null)
            {
                // Removes the label decorators node that is a sub node of
                // the appearance node.
                // We want to keep the other sub node, colors and fonts
                // because it allows for setting the font for
                // the module editor.
                appearanceNode.remove("org.eclipse.ui.preferencePages.Decorators");
            }
        }

        // remove Install/Update
        pm.remove("org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage");

        // remove the sub node of help
        IPreferenceNode helpNode = pm.find("org.eclipse.help.ui.browsersPreferencePage");
        if (helpNode != null)
        {
            helpNode.remove("org.eclipse.help.ui.contentPreferencePage");
        }
    }
}
 
Example #23
Source File: E4PreferencesAddon.java    From e4Preferences with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * This method is invoked when the preference manager changes in the context. 
 * It can be possible in 2 cases : 
 *   <ul>
 *   
 *   <li> E3 mixed mode with E4 pref plugins -> the org.eclipse.ui.internal.WorkbenchPlugin set it after the creation of this addon. 
 *        In this case we must complete the E3 init with the E4 preferences extensions.  </li>
 *   <li> pure E4 mode : in this case, the com.opcoach.e4.preferences.handlers.E4PreferencesHandler was called to initialize the Preference manager if it is not preset. In this case
 *   nothing special to do...</li> 
 *    </ul>
 * @param ctx
 * @param pm
 */
@Inject @Optional
public void initializePreferenceManager(IEclipseContext ctx, PreferenceManager pm) {
	// First time it can be null because init is not finished but we register that we are interesting in
	if (pm == null || pm instanceof E4PrefManager)
		return;
	
	// Here we got a E3 preference manager, we must complete its content. 
	// If we enter here, it is because Fill this context with the additional E4 pref pages. 
	E4PreferenceRegistry registry = new E4PreferenceRegistry();
	registry.populatePrefManagerWithE4Extensions(pm, ctx);	
	
}