]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.slc
.client
.ui
.dist
.editors
;
18 import org
.argeo
.jcr
.JcrUtils
;
19 import org
.argeo
.slc
.SlcException
;
20 import org
.argeo
.slc
.SlcNames
;
21 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
22 import org
.eclipse
.ui
.IEditorInput
;
23 import org
.eclipse
.ui
.IPersistableElement
;
25 /** Editor input for a JCR node object in a multi-repository environment */
26 public class ModuleEditorInput
implements IEditorInput
, SlcNames
{
28 // Define relevant workspace on a given repository
29 private String repoNodePath
;
31 private String workspaceName
;
32 private String modulePath
;
34 public ModuleEditorInput(String repoNodePath
, String uri
,
35 String workspaceName
, String artifactPath
) {
36 if (workspaceName
== null)
37 throw new SlcException("Workspace name cannot be null");
38 if (uri
== null && repoNodePath
== null)
39 throw new SlcException("Define at least one of the 2 "
40 + "parameters URI or Repo Node Path");
41 if (artifactPath
== null)
42 throw new SlcException("Module path cannot be null");
43 this.repoNodePath
= repoNodePath
;
45 this.workspaceName
= workspaceName
;
46 this.modulePath
= artifactPath
;
49 public String
getModulePath() {
53 public String
getWorkspaceName() {
57 public String
getRepoNodePath() {
61 public String
getUri() {
65 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
69 public boolean exists() {
73 public ImageDescriptor
getImageDescriptor() {
77 // Dummy compulsory methods
78 public String
getToolTipText() {
79 return getModulePath();
82 public String
getName() {
83 return JcrUtils
.lastPathElement(modulePath
);
86 public IPersistableElement
getPersistable() {
91 * equals method based on coordinates
93 public boolean equals(Object obj
) {
98 if (getClass() != obj
.getClass())
101 ModuleEditorInput other
= (ModuleEditorInput
) obj
;
103 if (!modulePath
.equals(other
.getModulePath()))
105 if (!workspaceName
.equals(other
.getWorkspaceName()))
108 if (uri
== null && other
.getUri() != null
109 || !uri
.equals(other
.getUri()))
112 if (repoNodePath
== null && other
.getRepoNodePath() != null
113 || !repoNodePath
.equals(other
.getRepoNodePath()))