Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » display the PreferencePage
display the PreferencePage [message #1038860] Thu, 11 April 2013 12:41 Go to next message
Marc Meier is currently offline Marc MeierFriend
Messages: 9
Registered: April 2013
Junior Member

I used the PrefernecePage tutorial by Lars Vogella.

Unfortunately it does not happen correctly.

Here are my classes:
public class MyPreferencePage1 extends FieldEditorPreferencePage implements
    IWorkbenchPreferencePage {

  public MyPreferencePage1() {


  public void createFieldEditors() {
    addField(new DirectoryFieldEditor("PATH", "&Directory preference:",
    addField(new BooleanFieldEditor("BOOLEAN_VALUE",
        "&An example of a boolean preference", getFieldEditorParent()));

    addField(new RadioGroupFieldEditor("CHOICE",
        "An example of a multiple-choice preference", 1,
        new String[][] { { "&Choice 1", "choice1" },
            { "C&hoice 2", "choice2" } }, getFieldEditorParent()));
    addField(new StringFieldEditor("MySTRING1", "A &text preference:",
    addField(new StringFieldEditor("MySTRING2", "A &text preference:",

  public void init(IWorkbench workbench) {
    setDescription("A demonstration of a preference page implementation");


import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator extends AbstractUIPlugin {
	// The shared instance
		private static Activator plugin;

	private static BundleContext context;

	static BundleContext getContext() {
		return context;

	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;

	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	public void stop(BundleContext bundleContext) throws Exception {
		Activator.context = null;
	public static Activator getDefault() {
		return plugin;


 * Copyright (c) 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * Contributors:
 *     IBM Corporation - initial API and implementation

import javax.inject.Named;

import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.e4.core.commands.ECommandService;
import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;

public class PreferenceHandlerHandler {
	public void execute(IEclipseContext context, ECommandService commandService, EHandlerService handlerService){ 
		ParameterizedCommand cmd = commandService.createCommand("org.eclipse.ui.window.preferences", null); 

I have linked the class PreferenceHandler with a menu item.
But when I run this menu item, it does not open the Prefernce Page. What is wrong?

thanks for your help

Re: display the PreferencePage [message #1038990 is a reply to message #1038860] Thu, 11 April 2013 15:39 Go to previous messageGo to next message
Phil Beauvoir is currently offline Phil BeauvoirFriend
Messages: 23
Registered: October 2012
Junior Member
Do you set the static variable

plugin = this;

in your Activator? Looking at the code you posted, you aren't doing this.
Re: display the PreferencePage [message #1039407 is a reply to message #1038990] Fri, 12 April 2013 06:06 Go to previous messageGo to next message
Marc Meier is currently offline Marc MeierFriend
Messages: 9
Registered: April 2013
Junior Member
Yes thats true, i have changed it ... but the Preference Page does not open.

		ParameterizedCommand cmd = commandService.createCommand("org.eclipse.ui.window.preferences", null); 

Is this Code correctly ?
Re: display the PreferencePage [message #1039478 is a reply to message #1038860] Fri, 12 April 2013 08:01 Go to previous messageGo to next message
Mateusz Malinowski is currently offline Mateusz MalinowskiFriend
Messages: 33
Registered: March 2013
Location: Bristol
If you are using E4 (what I believe you do), I would suggest to get rid of IWorkbenchPreferencePage.

Simply create your class as you do, put things from init() method to the constructor (you won't be using this interface), give the method createFieldEditors() annotation @Override.

Have you also created an extension point org.eclipse.ui.preferencePages in your plugin?

You may find this thread worthy viewing:

I just saw that in your Activator you are extending AbstractUIPlugin which uses RCP 3. Personally, I would suggest extending Plugin from org.eclipse.core.runtime package. You don't use there any AbstractUIPlugin's methods, so that should be fine. Even if you need them, you can easily write them yourself.

[Updated on: Fri, 12 April 2013 08:07]

Report message to a moderator

Re: display the PreferencePage [message #1045431 is a reply to message #1038860] Sat, 20 April 2013 08:20 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1049
Registered: July 2009
Senior Member

The example you referening too, has been written for Eclipse 3.x and does not yet work on Eclipse4.x.

Best regards, Lars Vogel
Previous Topic:ActionHandler behavior change in Eclipse 4?
Next Topic:ContextInjectionFactory.invoke with own annotations.
Goto Forum:

Current Time: Wed Oct 07 12:47:26 GMT 2015

Powered by FUDForum. Page generated in 0.02740 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software