]> git.argeo.org Git - gpl/argeo-slc.git/blob - parts/StringNodeEditorInput.java
Prepare next development cycle
[gpl/argeo-slc.git] / parts / StringNodeEditorInput.java
1 package org.argeo.cms.ui.workbench.internal.jcr.parts;
2
3 import org.eclipse.jface.resource.ImageDescriptor;
4 import org.eclipse.ui.IEditorInput;
5 import org.eclipse.ui.IPersistableElement;
6
7 /**
8 * An editor input based on three strings define a node :
9 * <ul>
10 * <li>complete path to the node</li>
11 * <li>the workspace name</li>
12 * <li>the repository alias</li>
13 * </ul>
14 * In a single workspace and/or repository environment, name and alias can be
15 * null.
16 *
17 * Note : unused for the time being.
18 */
19
20 public class StringNodeEditorInput implements IEditorInput {
21 private final String path;
22 private final String repositoryAlias;
23 private final String workspaceName;
24
25 /**
26 * In order to implement a generic explorer that supports remote and multi
27 * workspaces repositories, node path can be detailed by these strings.
28 *
29 * @param repositoryAlias
30 * : can be null
31 * @param workspaceName
32 * : can be null
33 * @param path
34 */
35 public StringNodeEditorInput(String repositoryAlias, String workspaceName,
36 String path) {
37 this.path = path;
38 this.repositoryAlias = repositoryAlias;
39 this.workspaceName = workspaceName;
40 }
41
42 @SuppressWarnings("unchecked")
43 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
44 return null;
45 }
46
47 public boolean exists() {
48 return true;
49 }
50
51 public ImageDescriptor getImageDescriptor() {
52 return null;
53 }
54
55 public String getName() {
56 return path;
57 }
58
59 public String getRepositoryAlias() {
60 return repositoryAlias;
61 }
62
63 public String getWorkspaceName() {
64 return workspaceName;
65 }
66
67 public IPersistableElement getPersistable() {
68 return null;
69 }
70
71 public String getToolTipText() {
72 return path;
73 }
74
75 public String getPath() {
76 return path;
77 }
78
79 public boolean equals(Object obj) {
80 if (this == obj)
81 return true;
82 if (obj == null)
83 return false;
84 if (getClass() != obj.getClass())
85 return false;
86
87 StringNodeEditorInput other = (StringNodeEditorInput) obj;
88
89 if (!path.equals(other.getPath()))
90 return false;
91
92 String own = other.getWorkspaceName();
93 if ((workspaceName == null && own != null)
94 || (workspaceName != null && (own == null || !workspaceName
95 .equals(own))))
96 return false;
97
98 String ora = other.getRepositoryAlias();
99 if ((repositoryAlias == null && ora != null)
100 || (repositoryAlias != null && (ora == null || !repositoryAlias
101 .equals(ora))))
102 return false;
103
104 return true;
105 }
106 }