]> git.argeo.org Git - lgpl/argeo-commons.git/blob - StringNodeEditorInput.java
c277e024f8cbcdb6f5708bd0869d15461c6f1a13
[lgpl/argeo-commons.git] / StringNodeEditorInput.java
1 package org.argeo.jcr.ui.explorer.editors;
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 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
43 return null;
44 }
45
46 public boolean exists() {
47 return true;
48 }
49
50 public ImageDescriptor getImageDescriptor() {
51 return null;
52 }
53
54 public String getName() {
55 return path;
56 }
57
58 public String getRepositoryAlias() {
59 return repositoryAlias;
60 }
61
62 public String getWorkspaceName() {
63 return workspaceName;
64 }
65
66 public IPersistableElement getPersistable() {
67 return null;
68 }
69
70 public String getToolTipText() {
71 return path;
72 }
73
74 public String getPath() {
75 return path;
76 }
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 StringNodeEditorInput other = (StringNodeEditorInput) obj;
87
88 if (!path.equals(other.getPath()))
89 return false;
90
91 String own = other.getWorkspaceName();
92 if ((workspaceName == null && own != null)
93 || (workspaceName != null && (own == null || !workspaceName
94 .equals(own))))
95 return false;
96
97 String ora = other.getRepositoryAlias();
98 if ((repositoryAlias == null && ora != null)
99 || (repositoryAlias != null && (ora == null || !repositoryAlias
100 .equals(ora))))
101 return false;
102
103 return true;
104 }
105 }