E4 Preferences Dialog [message #1727698] |
Fri, 25 March 2016 12:04 |
Alexander Kerner Messages: 25 Registered: January 2015 |
Junior Member |
|
|
Hi,
I am migrating to E4 right now. I am wondering how to implement the Window -> Preferences Menu. Its quite a basic use case and I tried the approach mentioned here (https://www.eclipse.org/forums/index.php/t/282692/).
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.di.annotations.Execute;
import org.eclipse.e4.core.services.log.Logger;
@SuppressWarnings("restriction")
public class PreferencesHandler {
@Execute
void execute(ECommandService commandService, EHandlerService handlerService, Logger logger) {
Command command = commandService.getCommand("org.eclipse.ui.window.preferences");
// check if the command is defined
System.out.println(command.isDefined());
// activate handler, assumption: the AboutHandler() class exists already
handlerService.activateHandler("my.fancy.app.ui.app.command.preferences",
new PreferencesHandler());
// prepare execution of command
ParameterizedCommand cmd =
commandService.createCommand("org.eclipse.ui.window.preferences", null);
// check if the command can get executed
if (handlerService.canExecute(cmd)){
// execute the command
handlerService.executeHandler(cmd);
} else {
System.err.println("NEIN");
}
}
}
Unfortunately, When I try to execute the command using the handlerService, handlerService.canExecute(cmd) always returns false.
How can I get the PreferencesPages working?
Many thanks!
[Updated on: Fri, 25 March 2016 12:20] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03365 seconds