]> 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
Clean session management.
[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)
41 throw new SlcException("URI for repository cannot be null");
42 if (artifactPath == null)
43 throw new SlcException("Module path cannot be null");
44 this.repoNodePath = repoNodePath;
45 this.uri = uri;
46 this.workspaceName = workspaceName;
47 this.modulePath = artifactPath;
48 }
49
50 public String getModulePath() {
51 return modulePath;
52 }
53
54 public String getWorkspaceName() {
55 return workspaceName;
56 }
57
58 public String getRepoNodePath() {
59 return repoNodePath;
60 }
61
62 public String getUri() {
63 return uri;
64 }
65
66 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
67 return null;
68 }
69
70 public boolean exists() {
71 return true;
72 }
73
74 public ImageDescriptor getImageDescriptor() {
75 return null;
76 }
77
78 // Dummy compulsory methods
79 public String getToolTipText() {
80 return getModulePath();
81 }
82
83 public String getName() {
84 return JcrUtils.lastPathElement(modulePath);
85 }
86
87 public IPersistableElement getPersistable() {
88 return null;
89 }
90
91 /**
92 * equals method based on coordinates
93 */
94 public boolean equals(Object obj) {
95 if (this == obj)
96 return true;
97 if (obj == null)
98 return false;
99 if (getClass() != obj.getClass())
100 return false;
101
102 ModuleEditorInput other = (ModuleEditorInput) obj;
103
104 if (!modulePath.equals(other.getModulePath()))
105 return false;
106 if (!workspaceName.equals(other.getWorkspaceName()))
107 return false;
108 if (!uri.equals(other.getUri()))
109 return false;
110
111 if (repoNodePath == null)
112 return other.getRepoNodePath() == null;
113 else
114 return repoNodePath.equals(other.getRepoNodePath());
115 }
116 }