]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java
Remove unused.
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / DistWorkspaceEditor.java
1 package org.argeo.slc.client.ui.dist.editors;
2
3 import javax.jcr.Node;
4 import javax.jcr.Repository;
5 import javax.jcr.RepositoryException;
6 import javax.jcr.RepositoryFactory;
7 import javax.jcr.Session;
8
9 import org.argeo.api.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;
20
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;
24
25 // private final static Log log =
26 // LogFactory.getLog(DistributionEditor.class);
27 public final static String ID = DistPlugin.PLUGIN_ID + ".distWorkspaceEditor";
28
29 /* DEPENDENCY INJECTION */
30 private RepositoryFactory repositoryFactory;
31 private Repository localRepository;
32 private Keyring keyring;
33
34 // Business objects
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;
41
42 @Override
43 public void init(IEditorSite site, IEditorInput input)
44 throws PartInitException {
45 editorInput = (DistWkspEditorInput) input;
46 try {
47 localSession = localRepository.login();
48 if (editorInput.getRepoNodePath() != null
49 && localSession.nodeExists(editorInput.getRepoNodePath()))
50 repoNode = localSession.getNode(editorInput.getRepoNodePath());
51
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);
58 }
59 setPartName(editorInput.getWorkspaceName());
60 super.init(site, input);
61 }
62
63 @Override
64 protected void addPages() {
65 try {
66 addPage(new DistWkspSearchPage(this, "Details ", businessSession));
67 addPage(new DistWkspBrowserPage(this, "Maven ", businessSession));
68 addPage(new WkspCategoryBaseListPage(this, "Groups ",
69 businessSession));
70 } catch (PartInitException e) {
71 throw new SlcException("Cannot add distribution editor pages", e);
72 }
73 }
74
75 @Override
76 public void doSave(IProgressMonitor arg0) {
77 }
78
79 @Override
80 public void dispose() {
81 JcrUtils.logoutQuietly(businessSession);
82 JcrUtils.logoutQuietly(localSession);
83 super.dispose();
84 }
85
86 @Override
87 public void doSaveAs() {
88 }
89
90 @Override
91 public boolean isSaveAsAllowed() {
92 return false;
93 }
94
95 protected Node getRepoNode() {
96 return repoNode;
97 }
98
99 protected Session getSession() {
100 return businessSession;
101 }
102
103 /* DEPENDENCY INJECTION */
104 public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
105 this.repositoryFactory = repositoryFactory;
106 }
107
108 public void setKeyring(Keyring keyring) {
109 this.keyring = keyring;
110 }
111
112 public void setLocalRepository(Repository localRepository) {
113 this.localRepository = localRepository;
114 }
115 }