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 javax
.jcr
.Node
;
19 import javax
.jcr
.RepositoryException
;
21 import org
.argeo
.ArgeoException
;
22 import org
.argeo
.slc
.jcr
.SlcNames
;
23 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
24 import org
.eclipse
.ui
.IEditorInput
;
25 import org
.eclipse
.ui
.IPersistableElement
;
28 * An editor input based the JCR node object.
30 public class GenericBundleEditorInput
implements IEditorInput
, SlcNames
{
32 private final Node artifactNode
;
33 // cache key properties at creation time to avoid Exception at recovering
34 // time when the session has been closed
35 private String artifactId
;
36 private String groupId
;
37 private String version
;
39 public GenericBundleEditorInput(Node artifactNode
) {
40 this.artifactNode
= artifactNode
;
42 artifactId
= artifactNode
.getProperty(SLC_ARTIFACT_ID
).getString();
43 groupId
= artifactNode
.getProperty(SLC_GROUP_ID
).getString();
44 version
= artifactNode
.getProperty(SLC_ARTIFACT_VERSION
)
46 } catch (RepositoryException re
) {
47 throw new ArgeoException(
48 "unexpected error while getting node key values at creation time",
53 public Node
getArtifactNode() {
57 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
61 public boolean exists() {
65 public ImageDescriptor
getImageDescriptor() {
69 public String
getArtifactId() {
73 public String
getGroupId() {
77 public String
getVersion() {
81 // Dummy compulsory methods
82 public String
getToolTipText() {
83 return artifactId
+ ":" + groupId
+ ":" + version
;
86 public String
getName() {
87 // return artifactId + ":" + groupId + ":" + version;
91 public IPersistableElement
getPersistable() {
96 * equals method based on coordinates
98 public boolean equals(Object obj
) {
103 if (getClass() != obj
.getClass())
106 GenericBundleEditorInput other
= (GenericBundleEditorInput
) obj
;
107 if (!getGroupId().equals(other
.getGroupId()))
109 if (!getArtifactId().equals(other
.getArtifactId()))
111 if (!getVersion().equals(other
.getVersion()))