1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.ui.dist.editors;
17
18 import org.argeo.jcr.JcrUtils;
19 import org.argeo.slc.SlcException;
20 import org.argeo.slc.SlcNames;
21 import org.eclipse.jface.resource.ImageDescriptor;
22 import org.eclipse.ui.IEditorInput;
23 import org.eclipse.ui.IPersistableElement;
24
25
26 public class ModuleEditorInput implements IEditorInput, SlcNames {
27
28
29 private String repoNodePath;
30 private String uri;
31 private String workspaceName;
32 private String modulePath;
33
34 public ModuleEditorInput(String repoNodePath, String uri,
35 String workspaceName, String artifactPath) {
36 if (workspaceName == null)
37 throw new SlcException("Workspace name cannot be null");
38 if (uri == null && repoNodePath == null)
39 throw new SlcException("Define at least one of the 2 "
40 + "parameters URI or Repo Node Path");
41 if (artifactPath == null)
42 throw new SlcException("Module path cannot be null");
43 this.repoNodePath = repoNodePath;
44 this.uri = uri;
45 this.workspaceName = workspaceName;
46 this.modulePath = artifactPath;
47 }
48
49 public String getModulePath() {
50 return modulePath;
51 }
52
53 public String getWorkspaceName() {
54 return workspaceName;
55 }
56
57 public String getRepoNodePath() {
58 return repoNodePath;
59 }
60
61 public String getUri() {
62 return uri;
63 }
64
65 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
66 return null;
67 }
68
69 public boolean exists() {
70 return true;
71 }
72
73 public ImageDescriptor getImageDescriptor() {
74 return null;
75 }
76
77
78 public String getToolTipText() {
79 return getModulePath();
80 }
81
82 public String getName() {
83 return JcrUtils.lastPathElement(modulePath);
84 }
85
86 public IPersistableElement getPersistable() {
87 return null;
88 }
89
90
91
92
93 public boolean equals(Object obj) {
94 if (this == obj)
95 return true;
96 if (obj == null)
97 return false;
98 if (getClass() != obj.getClass())
99 return false;
100
101 ModuleEditorInput other = (ModuleEditorInput) obj;
102
103 if (!modulePath.equals(other.getModulePath()))
104 return false;
105 if (!workspaceName.equals(other.getWorkspaceName()))
106 return false;
107
108 if (uri == null && other.getUri() != null
109 || !uri.equals(other.getUri()))
110 return false;
111
112 if (repoNodePath == null && other.getRepoNodePath() != null
113 || !repoNodePath.equals(other.getRepoNodePath()))
114 return false;
115
116 return true;
117 }
118 }