]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/StringNodeEditorInput.java
Fix char array comparison
[lgpl/argeo-commons.git] / org.argeo.cms.ui.workbench / src / org / argeo / cms / ui / workbench / internal / jcr / parts / StringNodeEditorInput.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.cms.ui.workbench.internal.jcr.parts;
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 @SuppressWarnings("unchecked")
58 public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
59 return null;
60 }
61
62 public boolean exists() {
63 return true;
64 }
65
66 public ImageDescriptor getImageDescriptor() {
67 return null;
68 }
69
70 public String getName() {
71 return path;
72 }
73
74 public String getRepositoryAlias() {
75 return repositoryAlias;
76 }
77
78 public String getWorkspaceName() {
79 return workspaceName;
80 }
81
82 public IPersistableElement getPersistable() {
83 return null;
84 }
85
86 public String getToolTipText() {
87 return path;
88 }
89
90 public String getPath() {
91 return path;
92 }
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 StringNodeEditorInput other = (StringNodeEditorInput) obj;
103
104 if (!path.equals(other.getPath()))
105 return false;
106
107 String own = other.getWorkspaceName();
108 if ((workspaceName == null && own != null)
109 || (workspaceName != null && (own == null || !workspaceName
110 .equals(own))))
111 return false;
112
113 String ora = other.getRepositoryAlias();
114 if ((repositoryAlias == null && ora != null)
115 || (repositoryAlias != null && (ora == null || !repositoryAlias
116 .equals(ora))))
117 return false;
118
119 return true;
120 }
121 }