]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/editors/GenericNodeEditorInput.java
Jcr Explorer refactoring and packaging
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / editors / GenericNodeEditorInput.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 a path to a node plus workspace name and repository
9 * alias. In a multirepository environment, path can be enriched with Repository
10 * Alias and workspace
11 */
12
13 public class GenericNodeEditorInput implements IEditorInput {
14 private final String path;
15 private final String repositoryAlias;
16 private final String workspaceName;
17
18 /**
19 * In order to implement a generic explorer that supports remote and multi
20 * workspaces repositories, node path can be detailed by these strings.
21 *
22 * @param repositoryAlias
23 * : can be null
24 * @param workspaceName
25 * : can be null
26 * @param path
27 */
28 public GenericNodeEditorInput(String repositoryAlias, String workspaceName,
29 String path) {
30 this.path = path;
31 this.repositoryAlias = repositoryAlias;
32 this.workspaceName = workspaceName;
33 }
34
35 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
36 return null;
37 }
38
39 public boolean exists() {
40 return true;
41 }
42
43 public ImageDescriptor getImageDescriptor() {
44 return null;
45 }
46
47 public String getName() {
48 return path;
49 }
50
51 public String getRepositoryAlias() {
52 return repositoryAlias;
53 }
54
55 public String getWorkspaceName() {
56 return workspaceName;
57 }
58
59 public IPersistableElement getPersistable() {
60 return null;
61 }
62
63 public String getToolTipText() {
64 return path;
65 }
66
67 public String getPath() {
68 return path;
69 }
70
71 public boolean equals(Object obj) {
72 if (this == obj)
73 return true;
74 if (obj == null)
75 return false;
76 if (getClass() != obj.getClass())
77 return false;
78
79 GenericNodeEditorInput other = (GenericNodeEditorInput) obj;
80
81 if (!path.equals(other.getPath()))
82 return false;
83
84 String own = other.getWorkspaceName();
85 if ((workspaceName == null && own != null)
86 || (workspaceName != null && (own == null || !workspaceName
87 .equals(own))))
88 return false;
89
90 String ora = other.getRepositoryAlias();
91 if ((repositoryAlias == null && ora != null)
92 || (repositoryAlias != null && (ora == null || !repositoryAlias
93 .equals(ora))))
94 return false;
95
96 return true;
97 }
98 }