]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/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
.jcr
.SlcNames
;
21 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
22 import org
.eclipse
.ui
.IEditorInput
;
23 import org
.eclipse
.ui
.IPersistableElement
;
26 * An editor input for a JCR node object in a multi-repository environment.
28 public class ModuleEditorInput
implements IEditorInput
, SlcNames
{
30 // Define relevant workspace on a given repository
31 private String repoNodePath
;
33 private String workspaceName
;
34 private String modulePath
;
36 public ModuleEditorInput(String repoNodePath
, String uri
,
37 String workspaceName
, String artifactPath
) {
38 if (workspaceName
== null)
39 throw new SlcException("Workspace name cannot be null");
40 if (uri
== null && repoNodePath
== null)
41 throw new SlcException("Define at least one of the 2 "
42 + "parameters URI or Repo Node Path");
43 if (artifactPath
== null)
44 throw new SlcException("Module path cannot be null");
45 this.repoNodePath
= repoNodePath
;
47 this.workspaceName
= workspaceName
;
48 this.modulePath
= artifactPath
;
51 public String
getModulePath() {
55 public String
getWorkspaceName() {
59 public String
getRepoNodePath() {
63 public String
getUri() {
67 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
71 public boolean exists() {
75 public ImageDescriptor
getImageDescriptor() {
79 // Dummy compulsory methods
80 public String
getToolTipText() {
81 return getModulePath();
84 public String
getName() {
85 return JcrUtils
.lastPathElement(modulePath
);
88 public IPersistableElement
getPersistable() {
93 * equals method based on coordinates
95 public boolean equals(Object obj
) {
100 if (getClass() != obj
.getClass())
103 ModuleEditorInput other
= (ModuleEditorInput
) obj
;
105 if (!modulePath
.equals(other
.getModulePath()))
107 if (!workspaceName
.equals(other
.getWorkspaceName()))
110 if (uri
== null && other
.getUri() != null
111 || !uri
.equals(other
.getUri()))
114 if (repoNodePath
== null && other
.getRepoNodePath() != null
115 || !repoNodePath
.equals(other
.getRepoNodePath()))