]> 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/StringNodeEditorInput.java
Imporve JCR keyring and remote repository exploring
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / editors / StringNodeEditorInput.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
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.jcr.ui.explorer.editors;
17
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.ui.IEditorInput;
20 import org.eclipse.ui.IPersistableElement;
21
22 /**
23 * An editor input based on three strings define a node :
24 * <ul>
25 * <li>complete path to the node</li>
26 * <li>the workspace name</li>
27 * <li>the repository alias</li>
28 * </ul>
29 * In a single workspace and/or repository environment, name and alias can be
30 * null.
31 *
32 * Note : unused for the time being.
33 */
34
35 public class StringNodeEditorInput implements IEditorInput {
36 private final String path;
37 private final String repositoryAlias;
38 private final String workspaceName;
39
40 /**
41 * In order to implement a generic explorer that supports remote and multi
42 * workspaces repositories, node path can be detailed by these strings.
43 *
44 * @param repositoryAlias
45 * : can be null
46 * @param workspaceName
47 * : can be null
48 * @param path
49 */
50 public StringNodeEditorInput(String repositoryAlias, String workspaceName,
51 String path) {
52 this.path = path;
53 this.repositoryAlias = repositoryAlias;
54 this.workspaceName = workspaceName;
55 }
56
57 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
58 return null;
59 }
60
61 public boolean exists() {
62 return true;
63 }
64
65 public ImageDescriptor getImageDescriptor() {
66 return null;
67 }
68
69 public String getName() {
70 return path;
71 }
72
73 public String getRepositoryAlias() {
74 return repositoryAlias;
75 }
76
77 public String getWorkspaceName() {
78 return workspaceName;
79 }
80
81 public IPersistableElement getPersistable() {
82 return null;
83 }
84
85 public String getToolTipText() {
86 return path;
87 }
88
89 public String getPath() {
90 return path;
91 }
92
93 public boolean equals(Object obj) {
94 if (this == obj)
95 return true;
96 if (obj == null)
97 return false;
98 if (getClass() != obj.getClass())
99 return false;
100
101 StringNodeEditorInput other = (StringNodeEditorInput) obj;
102
103 if (!path.equals(other.getPath()))
104 return false;
105
106 String own = other.getWorkspaceName();
107 if ((workspaceName == null && own != null)
108 || (workspaceName != null && (own == null || !workspaceName
109 .equals(own))))
110 return false;
111
112 String ora = other.getRepositoryAlias();
113 if ((repositoryAlias == null && ora != null)
114 || (repositoryAlias != null && (ora == null || !repositoryAlias
115 .equals(ora))))
116 return false;
117
118 return true;
119 }
120 }