1 package org
.argeo
.suite
.workbench
.commands
;
4 import javax
.jcr
.Repository
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.Session
;
8 import org
.argeo
.connect
.ui
.workbench
.AppWorkbenchService
;
9 import org
.argeo
.connect
.ui
.workbench
.NodeEditorInput
;
10 import org
.argeo
.jcr
.JcrUtils
;
11 import org
.argeo
.suite
.SuiteException
;
12 import org
.argeo
.suite
.workbench
.AsUiPlugin
;
13 import org
.eclipse
.core
.commands
.AbstractHandler
;
14 import org
.eclipse
.core
.commands
.ExecutionEvent
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.ui
.IWorkbenchPage
;
17 import org
.eclipse
.ui
.IWorkbenchWindow
;
18 import org
.eclipse
.ui
.PartInitException
;
19 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
21 /** Workaround to enable opening of a default editor */
22 public class OpenEntityEditor
extends AbstractHandler
{
23 public final static String ID
= AsUiPlugin
.PLUGIN_ID
+ ".openEntityEditor";
25 public final static String PARAM_JCR_ID
= "param.jcrId";
26 // public final static String PARAM_OPEN_FOR_EDIT = "param.openForEdit";
27 // public final static String PARAM_CTAB_ID = "param.cTabId";
29 private Repository repository
;
30 private AppWorkbenchService appWorkbenchService
;
32 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
33 NodeEditorInput eei
= null;
35 Session session
= null;
36 String jcrId
= event
.getParameter(PARAM_JCR_ID
);
38 session
= repository
.login();
40 entity
= session
.getNodeByIdentifier(jcrId
);
41 eei
= new NodeEditorInput(jcrId
);
45 String editorId
= appWorkbenchService
.getEntityEditorId(entity
);
46 if (editorId
!= null) {
47 IWorkbenchWindow iww
= HandlerUtil
.getActiveWorkbenchWindow(event
);
48 IWorkbenchPage iwp
= iww
.getActivePage();
49 iwp
.openEditor(eei
, editorId
);
51 } catch (PartInitException pie
) {
52 throw new SuiteException("Unexpected PartInitException while opening entity editor", pie
);
53 } catch (RepositoryException e
) {
54 throw new SuiteException("unexpected JCR error while opening editor", e
);
56 JcrUtils
.logoutQuietly(session
);
61 public void setRepository(Repository repository
) {
62 this.repository
= repository
;
65 public void setAppWorkbenchService(AppWorkbenchService appWorkbenchService
) {
66 this.appWorkbenchService
= appWorkbenchService
;