1 package org
.argeo
.jcr
.ui
.explorer
.editors
;
4 import javax
.jcr
.RepositoryException
;
6 import org
.argeo
.ArgeoException
;
7 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
8 import org
.eclipse
.ui
.IEditorInput
;
9 import org
.eclipse
.ui
.IPersistableElement
;
12 * An editor input based the JCR node object.
15 public class GenericNodeEditorInput
implements IEditorInput
{
16 private final Node currentNode
;
18 public GenericNodeEditorInput(Node currentNode
) {
19 this.currentNode
= currentNode
;
22 public Node
getCurrentNode() {
26 public Object
getAdapter(@SuppressWarnings("rawtypes") Class adapter
) {
30 public boolean exists() {
34 public ImageDescriptor
getImageDescriptor() {
38 public String
getName() {
40 return currentNode
.getName();
41 } catch (RepositoryException re
) {
42 throw new ArgeoException(
43 "unexpected error while getting node name", re
);
47 public String
getUid() {
49 return currentNode
.getIdentifier();
50 } catch (RepositoryException re
) {
51 throw new ArgeoException("unexpected error while getting node uid",
56 public String
getToolTipText() {
58 return currentNode
.getPath();
59 } catch (RepositoryException re
) {
60 throw new ArgeoException(
61 "unexpected error while getting node path", re
);
65 public String
getPath() {
67 return currentNode
.getPath();
68 } catch (RepositoryException re
) {
69 throw new ArgeoException(
70 "unexpected error while getting node path", re
);
74 public IPersistableElement
getPersistable() {
79 * equals method based on UID that is unique within a workspace and path of
80 * the node, thus 2 shared node that have same UID as defined in the spec
81 * but 2 different pathes will open two distinct editors.
83 * TODO enhance this method to support multirepository and multiworkspace
86 public boolean equals(Object obj
) {
91 if (getClass() != obj
.getClass())
94 GenericNodeEditorInput other
= (GenericNodeEditorInput
) obj
;
95 if (!getUid().equals(other
.getUid()))
97 if (!getPath().equals(other
.getPath()))