1 package org
.argeo
.cms
.ui
.workbench
.commands
;
5 import org
.argeo
.cms
.ui
.workbench
.WorkbenchUiPlugin
;
6 import org
.argeo
.cms
.ui
.workbench
.internal
.jcr
.parts
.JcrQueryEditorInput
;
7 import org
.argeo
.cms
.ui
.workbench
.internal
.jcr
.parts
.NodeEditorInput
;
8 import org
.argeo
.cms
.ui
.workbench
.jcr
.DefaultNodeEditor
;
9 import org
.argeo
.cms
.ui
.workbench
.jcr
.GenericJcrQueryEditor
;
10 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.ui
.IWorkbenchPage
;
15 import org
.eclipse
.ui
.PartInitException
;
16 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
18 /** Open a {@link Node} editor of a specific type given the node path */
19 public class OpenEditor
extends AbstractHandler
{
20 public final static String ID
= WorkbenchUiPlugin
.PLUGIN_ID
+ ".openEditor";
22 public final static String PARAM_PATH
= "param.jcrNodePath";
23 public final static String PARAM_EDITOR_ID
= "param.editorId";
25 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
26 String editorId
= event
.getParameter(PARAM_EDITOR_ID
);
28 IWorkbenchPage activePage
= HandlerUtil
.getActiveWorkbenchWindow(
29 event
).getActivePage();
30 if (DefaultNodeEditor
.ID
.equals(editorId
)) {
31 String path
= event
.getParameter(PARAM_PATH
);
32 NodeEditorInput nei
= new NodeEditorInput(path
);
33 activePage
.openEditor(nei
, DefaultNodeEditor
.ID
);
34 } else if (GenericJcrQueryEditor
.ID
.equals(editorId
)) {
35 JcrQueryEditorInput editorInput
= new JcrQueryEditorInput(
36 GenericJcrQueryEditor
.ID
, null);
37 activePage
.openEditor(editorInput
, editorId
);
39 } catch (PartInitException e
) {
40 throw new EclipseUiException(
41 "Cannot open editor of ID " + editorId
, e
);