I have one RCP program, with 3 parts – 2 views(on left, 2 parts) and various editors(on right and the other part).
On my views i have trees and I can open the editor (other part).
On editor i can open another editor, but i need past an object when I call the editor, i make it on : addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {....
my button:
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand("XPTO.command", null);
} catch (Exception ex) {
throw new RuntimeException(
"XPTO");
}
}
});
my command:
public class CallEditors extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
System.out.println("calledEditor");
// Get the view
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
Editor navEditor = (Editor) page.findEditor(Editor.IDI);
}
}
thanks
I have the answer:
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
// Get the view
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
Object obj = btnNewButton.getData();
if (obj != null) {
xPTO input = new xPTO();
try {
page.openEditor(input, xptoEditor.ID, false);
} catch (PartInitException e1) {
throw new RuntimeException(e1);
}
}
}
Use
IWorkbenchPage#openEditor(..)