1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
4 import javax
.jcr
.RepositoryException
;
5 import javax
.jcr
.Session
;
7 import org
.argeo
.jcr
.JcrUtils
;
8 import org
.argeo
.slc
.SlcException
;
9 import org
.argeo
.slc
.SlcTypes
;
10 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
11 import org
.argeo
.slc
.client
.ui
.dist
.editors
.ArtifactVersionEditor
;
12 import org
.argeo
.slc
.client
.ui
.dist
.editors
.ModularDistVersionEditor
;
13 import org
.argeo
.slc
.client
.ui
.dist
.editors
.ModuleEditorInput
;
14 import org
.argeo
.slc
.repo
.RepoService
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.ui
.PartInitException
;
19 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
22 * Open the relevant editor for a given module node of a given repository
23 * workspace. For the time being, modules can be artifacts or
24 * modularDistributions
26 public class OpenModuleEditor
extends AbstractHandler
{
27 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".openModuleEditor";
28 public final static String DEFAULT_LABEL
= "Open relevant editor";
30 // use local node repo and repository factory to retrieve and log to
31 // relevant repository
32 public final static String PARAM_REPO_NODE_PATH
= "param.repoNodePath";
33 // use URI and repository factory to retrieve and ANONYMOUSLY log in
34 // relevant repository
35 public final static String PARAM_REPO_URI
= "param.repoUri";
36 public final static String PARAM_WORKSPACE_NAME
= "param.workspaceName";
37 public final static String PARAM_MODULE_PATH
= "param.modulePath";
39 /* DEPENDENCY INJECTION */
40 private RepoService repoService
;
42 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
43 String repoNodePath
= event
.getParameter(PARAM_REPO_NODE_PATH
);
44 String repoUri
= event
.getParameter(PARAM_REPO_URI
);
45 String workspaceName
= event
.getParameter(PARAM_WORKSPACE_NAME
);
46 String modulePath
= event
.getParameter(PARAM_MODULE_PATH
);
48 Session businessSession
= null;
50 businessSession
= repoService
.getRemoteSession(repoNodePath
,
51 repoUri
, workspaceName
);
53 Node module
= businessSession
.getNode(modulePath
);
54 ModuleEditorInput mei
= new ModuleEditorInput(repoNodePath
,
55 repoUri
, workspaceName
, modulePath
);
57 // Choose correct editor based on its mixin
58 if (module
.isNodeType(SlcTypes
.SLC_MODULAR_DISTRIBUTION
))
59 HandlerUtil
.getActiveWorkbenchWindow(event
).getActivePage()
60 .openEditor(mei
, ModularDistVersionEditor
.ID
);
62 HandlerUtil
.getActiveWorkbenchWindow(event
).getActivePage()
63 .openEditor(mei
, ArtifactVersionEditor
.ID
);
64 } catch (RepositoryException e
) {
65 throw new SlcException("Unexpected error while "
66 + "getting repoNode info for repoNode at path "
68 } catch (PartInitException e
) {
69 throw new SlcException("Unexpected error while "
70 + "opening editor for workspace " + workspaceName
71 + " with URI " + repoUri
+ " and repoNode at path "
74 JcrUtils
.logoutQuietly(businessSession
);
79 /* DEPENDENCY INJECTION */
80 public void setRepoService(RepoService repoService
) {
81 this.repoService
= repoService
;