2 * Copyright (C) 2007-2012 Mathieu Baudier
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.
31 public class GenericArtifactEditorInput
implements IEditorInput
, SlcNames
{
33 private final Node artifactNode
;
34 // cache key properties at creation time to avoid Exception at recoring time
35 // when the session has been closed
36 private String artifactId
;
37 private String groupId
;
38 private String version
;
40 public GenericArtifactEditorInput(Node artifactNode
) {
41 this.artifactNode
= artifactNode
;
43 artifactId
= artifactNode
.getProperty(SLC_ARTIFACT_ID
).getString();
44 groupId
= artifactNode
.getProperty(SLC_GROUP_ID
).getString();
45 version
= artifactNode
.getProperty(SLC_ARTIFACT_VERSION
)
47 } catch (RepositoryException re
) {
48 throw new ArgeoException(
49 "unexpected error while getting node key values at creation time",
54 public Node
getArtifactNode() {
58 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
62 public boolean exists() {
66 public ImageDescriptor
getImageDescriptor() {
70 public String
getArtifactId() {
74 public String
getGroupId() {
78 public String
getVersion() {
82 // Dummy compulsory methods
83 public String
getToolTipText() {
84 return artifactId
+ ":" + groupId
+ ":" + version
;
87 public String
getName() {
88 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 GenericArtifactEditorInput other
= (GenericArtifactEditorInput
) obj
;
107 if (!getGroupId().equals(other
.getGroupId()))
109 if (!getArtifactId().equals(other
.getArtifactId()))
111 if (!getVersion().equals(other
.getVersion()))