RSS

Search Engine

Wednesday, June 16, 2010

Calling commands from a button

You can call a command, e.g. in this example "add.command" from a button via the following coding.

   
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
IHandlerService handlerService = (IHandlerService) getSite()
.getService(IHandlerService.class);
try {
handlerService.executeCommand("add.command", null);
} catch (Exception ex) {
throw new RuntimeException("add.command not found");
}

}
});

0 comments:

Post a Comment