display the PreferencePage [message #1038860] |
Thu, 11 April 2013 08:41  |
Eclipse User |
|
|
|
Hello,
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() {
super(GRID);
}
public void createFieldEditors() {
addField(new DirectoryFieldEditor("PATH", "&Directory preference:",
getFieldEditorParent()));
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:",
getFieldEditorParent()));
addField(new StringFieldEditor("MySTRING2", "A &text preference:",
getFieldEditorParent()));
}
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("A demonstration of a preference page implementation");
}
}
package de.vogella.preferences.page;
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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package de.vogella.preferences.page.handlers;
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.e4.ui.services.IServiceConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
public class PreferenceHandlerHandler {
@Execute
public void execute(IEclipseContext context, ECommandService commandService, EHandlerService handlerService){
ParameterizedCommand cmd = commandService.createCommand("org.eclipse.ui.window.preferences", null);
handlerService.executeHandler(cmd);
System.out.println(cmd.getCommand().isDefined());
}
}
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
Marc
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24691 seconds