]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/commands/EditNode.java
2f82dc2b49a4ae2093862c5648cb48481be7c588
1 package org
.argeo
.jcr
.ui
.explorer
.commands
;
3 import java
.util
.HashMap
;
6 import javax
.jcr
.Property
;
7 import javax
.jcr
.nodetype
.NodeType
;
9 import org
.argeo
.eclipse
.ui
.ErrorFeedback
;
10 import org
.argeo
.eclipse
.ui
.jcr
.editors
.NodeEditorInput
;
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
.PartInitException
;
15 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
17 /** Generic command to open a path in an editor. */
18 public class EditNode
extends AbstractHandler
{
19 public final static String EDITOR_PARAM
= "editor";
21 private String defaultEditorId
;
23 private Map
<String
, String
> nodeTypeToEditor
= new HashMap
<String
, String
>();
25 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
26 String path
= event
.getParameter(Property
.JCR_PATH
);
28 String type
= event
.getParameter(NodeType
.NT_NODE_TYPE
);
30 type
= NodeType
.NT_UNSTRUCTURED
;
32 String editorId
= event
.getParameter(NodeType
.NT_NODE_TYPE
);
34 editorId
= nodeTypeToEditor
.containsKey(type
) ? nodeTypeToEditor
35 .get(type
) : defaultEditorId
;
37 NodeEditorInput nei
= new NodeEditorInput(path
);
40 HandlerUtil
.getActiveWorkbenchWindow(event
).getActivePage()
41 .openEditor(nei
, editorId
);
42 } catch (PartInitException e
) {
43 ErrorFeedback
.show("Cannot open " + editorId
+ " with " + path
44 + " of type " + type
, e
);
46 // TODO Auto-generated method stub
50 public void setDefaultEditorId(String defaultEditorId
) {
51 this.defaultEditorId
= defaultEditorId
;