]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
52d7a200a55c233ef785361c85bd41228949f6eb
[gpl/argeo-slc.git] / cms / org.argeo.slc.client.ui.dist / src / org / argeo / slc / client / ui / dist / editors / ModuleEditorInput.java
1 package org.argeo.slc.client.ui.dist.editors;
2
3 import org.argeo.jcr.JcrUtils;
4 import org.argeo.slc.SlcException;
5 import org.argeo.slc.SlcNames;
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.eclipse.ui.IEditorInput;
8 import org.eclipse.ui.IPersistableElement;
9
10 /** Editor input for a JCR node object in a multi-repository environment */
11 public class ModuleEditorInput implements IEditorInput, SlcNames {
12
13 // Define relevant workspace on a given repository
14 private String repoNodePath;
15 private String uri;
16 private String workspaceName;
17 private String modulePath;
18
19 public ModuleEditorInput(String repoNodePath, String uri,
20 String workspaceName, String artifactPath) {
21 if (workspaceName == null)
22 throw new SlcException("Workspace name cannot be null");
23 if (uri == null && repoNodePath == null)
24 throw new SlcException("Define at least one of the 2 "
25 + "parameters URI or Repo Node Path");
26 if (artifactPath == null)
27 throw new SlcException("Module path cannot be null");
28 this.repoNodePath = repoNodePath;
29 this.uri = uri;
30 this.workspaceName = workspaceName;
31 this.modulePath = artifactPath;
32 }
33
34 public String getModulePath() {
35 return modulePath;
36 }
37
38 public String getWorkspaceName() {
39 return workspaceName;
40 }
41
42 public String getRepoNodePath() {
43 return repoNodePath;
44 }
45
46 public String getUri() {
47 return uri;
48 }
49
50 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
51 return null;
52 }
53
54 public boolean exists() {
55 return true;
56 }
57
58 public ImageDescriptor getImageDescriptor() {
59 return null;
60 }
61
62 // Dummy compulsory methods
63 public String getToolTipText() {
64 return getModulePath();
65 }
66
67 public String getName() {
68 return JcrUtils.lastPathElement(modulePath);
69 }
70
71 public IPersistableElement getPersistable() {
72 return null;
73 }
74
75 /**
76 * equals method based on coordinates
77 */
78 public boolean equals(Object obj) {
79 if (this == obj)
80 return true;
81 if (obj == null)
82 return false;
83 if (getClass() != obj.getClass())
84 return false;
85
86 ModuleEditorInput other = (ModuleEditorInput) obj;
87
88 if (!modulePath.equals(other.getModulePath()))
89 return false;
90 if (!workspaceName.equals(other.getWorkspaceName()))
91 return false;
92
93 if (uri == null && other.getUri() != null
94 || !uri.equals(other.getUri()))
95 return false;
96
97 if (repoNodePath == null && other.getRepoNodePath() != null
98 || !repoNodePath.equals(other.getRepoNodePath()))
99 return false;
100
101 return true;
102 }
103 }