]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
Fix distribution editor after further testing with maven produced releases
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / ModuleEditorInput.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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.jcr.SlcNames;
21 import org.eclipse.jface.resource.ImageDescriptor;
22 import org.eclipse.ui.IEditorInput;
23 import org.eclipse.ui.IPersistableElement;
24
25 /**
26 * An editor input for a JCR node object in a multi-repository environment.
27 */
28 public class ModuleEditorInput implements IEditorInput, SlcNames {
29
30 // Define relevant workspace on a given repository
31 private String repoNodePath;
32 private String uri;
33 private String workspaceName;
34 private String modulePath;
35
36 public ModuleEditorInput(String repoNodePath, String uri,
37 String workspaceName, String artifactPath) {
38 if (workspaceName == null)
39 throw new SlcException("Workspace name cannot be null");
40 if (uri == null && repoNodePath == null)
41 throw new SlcException("Define at least one of the 2 "
42 + "parameters URI or Repo Node Path");
43 if (artifactPath == null)
44 throw new SlcException("Module path cannot be null");
45 this.repoNodePath = repoNodePath;
46 this.uri = uri;
47 this.workspaceName = workspaceName;
48 this.modulePath = artifactPath;
49 }
50
51 public String getModulePath() {
52 return modulePath;
53 }
54
55 public String getWorkspaceName() {
56 return workspaceName;
57 }
58
59 public String getRepoNodePath() {
60 return repoNodePath;
61 }
62
63 public String getUri() {
64 return uri;
65 }
66
67 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
68 return null;
69 }
70
71 public boolean exists() {
72 return true;
73 }
74
75 public ImageDescriptor getImageDescriptor() {
76 return null;
77 }
78
79 // Dummy compulsory methods
80 public String getToolTipText() {
81 return getModulePath();
82 }
83
84 public String getName() {
85 return JcrUtils.lastPathElement(modulePath);
86 }
87
88 public IPersistableElement getPersistable() {
89 return null;
90 }
91
92 /**
93 * equals method based on coordinates
94 */
95 public boolean equals(Object obj) {
96 if (this == obj)
97 return true;
98 if (obj == null)
99 return false;
100 if (getClass() != obj.getClass())
101 return false;
102
103 ModuleEditorInput other = (ModuleEditorInput) obj;
104
105 if (!modulePath.equals(other.getModulePath()))
106 return false;
107 if (!workspaceName.equals(other.getWorkspaceName()))
108 return false;
109
110 if (uri == null && other.getUri() != null
111 || !uri.equals(other.getUri()))
112 return false;
113
114 if (repoNodePath == null && other.getRepoNodePath() != null
115 || !repoNodePath.equals(other.getRepoNodePath()))
116 return false;
117
118 return true;
119 }
120 }