1 package org
.argeo
.slc
.client
.ui
.dist
.editors
;
4 import javax
.jcr
.Repository
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.RepositoryFactory
;
7 import javax
.jcr
.Session
;
9 import org
.argeo
.cms
.security
.Keyring
;
10 import org
.argeo
.jcr
.JcrUtils
;
11 import org
.argeo
.slc
.SlcException
;
12 import org
.argeo
.slc
.SlcNames
;
13 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
14 import org
.argeo
.slc
.repo
.RepoUtils
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.ui
.IEditorInput
;
17 import org
.eclipse
.ui
.IEditorSite
;
18 import org
.eclipse
.ui
.PartInitException
;
19 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
21 /** Browse, analyse and modify a workspace containing software distributions */
22 public class DistWorkspaceEditor
extends FormEditor
implements SlcNames
{
23 private static final long serialVersionUID
= 5373719580281643675L;
25 // private final static Log log =
26 // LogFactory.getLog(DistributionEditor.class);
27 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".distWorkspaceEditor";
29 /* DEPENDENCY INJECTION */
30 private RepositoryFactory repositoryFactory
;
31 private Repository localRepository
;
32 private Keyring keyring
;
35 private Node repoNode
;
36 // Session that provides the node in the home of the local repository
37 private Session localSession
= null;
38 // The business Session on optionally remote repository
39 private Session businessSession
;
40 private DistWkspEditorInput editorInput
;
43 public void init(IEditorSite site
, IEditorInput input
)
44 throws PartInitException
{
45 editorInput
= (DistWkspEditorInput
) input
;
47 localSession
= localRepository
.login();
48 if (editorInput
.getRepoNodePath() != null
49 && localSession
.nodeExists(editorInput
.getRepoNodePath()))
50 repoNode
= localSession
.getNode(editorInput
.getRepoNodePath());
52 businessSession
= RepoUtils
.getRemoteSession(
53 repositoryFactory
, keyring
, repoNode
, editorInput
.getUri(),
54 editorInput
.getWorkspaceName());
55 } catch (RepositoryException e
) {
56 throw new PartInitException("Cannot log to workspace "
57 + editorInput
.getName(), e
);
59 setPartName(editorInput
.getWorkspaceName());
60 super.init(site
, input
);
64 protected void addPages() {
66 addPage(new DistWkspSearchPage(this, "Details ", businessSession
));
67 addPage(new DistWkspBrowserPage(this, "Maven ", businessSession
));
68 addPage(new WkspCategoryBaseListPage(this, "Groups ",
70 } catch (PartInitException e
) {
71 throw new SlcException("Cannot add distribution editor pages", e
);
76 public void doSave(IProgressMonitor arg0
) {
80 public void dispose() {
81 JcrUtils
.logoutQuietly(businessSession
);
82 JcrUtils
.logoutQuietly(localSession
);
87 public void doSaveAs() {
91 public boolean isSaveAsAllowed() {
95 protected Node
getRepoNode() {
99 protected Session
getSession() {
100 return businessSession
;
103 /* DEPENDENCY INJECTION */
104 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
105 this.repositoryFactory
= repositoryFactory
;
108 public void setKeyring(Keyring keyring
) {
109 this.keyring
= keyring
;
112 public void setLocalRepository(Repository localRepository
) {
113 this.localRepository
= localRepository
;