1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.workbench.commands;
17
18 import javax.jcr.Node;
19
20 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
21 import org.argeo.cms.ui.workbench.internal.jcr.parts.JcrQueryEditorInput;
22 import org.argeo.cms.ui.workbench.internal.jcr.parts.NodeEditorInput;
23 import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
24 import org.argeo.cms.ui.workbench.jcr.GenericJcrQueryEditor;
25 import org.argeo.eclipse.ui.EclipseUiException;
26 import org.eclipse.core.commands.AbstractHandler;
27 import org.eclipse.core.commands.ExecutionEvent;
28 import org.eclipse.core.commands.ExecutionException;
29 import org.eclipse.ui.IWorkbenchPage;
30 import org.eclipse.ui.PartInitException;
31 import org.eclipse.ui.handlers.HandlerUtil;
32
33
34 public class OpenEditor extends AbstractHandler {
35 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".openEditor";
36
37 public final static String PARAM_PATH = "param.jcrNodePath";
38 public final static String PARAM_EDITOR_ID = "param.editorId";
39
40 public Object execute(ExecutionEvent event) throws ExecutionException {
41 String editorId = event.getParameter(PARAM_EDITOR_ID);
42 try {
43 IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(
44 event).getActivePage();
45 if (DefaultNodeEditor.ID.equals(editorId)) {
46 String path = event.getParameter(PARAM_PATH);
47 NodeEditorInput nei = new NodeEditorInput(path);
48 activePage.openEditor(nei, DefaultNodeEditor.ID);
49 } else if (GenericJcrQueryEditor.ID.equals(editorId)) {
50 JcrQueryEditorInput editorInput = new JcrQueryEditorInput(
51 GenericJcrQueryEditor.ID, null);
52 activePage.openEditor(editorInput, editorId);
53 }
54 } catch (PartInitException e) {
55 throw new EclipseUiException(
56 "Cannot open editor of ID " + editorId, e);
57 }
58 return null;
59 }
60 }