3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
;
12 import java
.util
.UUID
;
14 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
15 import org
.eclipse
.ui
.IEditorInput
;
16 import org
.eclipse
.ui
.IMemento
;
17 import org
.eclipse
.ui
.IPersistable
;
18 import org
.eclipse
.ui
.IPersistableElement
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 public class ChecklistEditorInput
implements IEditorInput
, IPersistable
{
34 * The selected classification
36 private TaxonNode taxonNode
= null;
38 private Classification classification
= null;
40 private final ConversationHolder conversationHolder
;
44 * Creates an editor input for the {@link ChecklistView} with the currently selected TaxonNode
48 public ChecklistEditorInput(TaxonNode taxonNode
){
50 this.conversationHolder
= CdmStore
.createConversation();
51 this.taxonNode
= CdmStore
.getCurrentApplicationConfiguration().getTaxonNodeService().load(taxonNode
.getUuid());
52 classification
= taxonNode
.getClassification();
56 * Creates an editor input for the {@link ChecklistView} with the currently selected classification.
57 * @param classificationUuid
59 public ChecklistEditorInput(Classification classification
) {
61 this.conversationHolder
= CdmStore
.createConversation();
62 this.classification
= CdmStore
.getCurrentApplicationConfiguration().getClassificationService().load(classification
.getUuid());
69 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
72 public Object
getAdapter(Class adapter
) {
73 // TODO Auto-generated method stub
78 * @see org.eclipse.ui.IEditorInput#exists()
81 public boolean exists() {
86 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
89 public ImageDescriptor
getImageDescriptor() {
90 // TODO Auto-generated method stub
95 * @see org.eclipse.ui.IEditorInput#getName()
98 public String
getName() {
99 if(taxonNode
!= null){
100 return taxonNode
.getTaxon().getName().getTitleCache();
102 return classification
.getTitleCache();
107 * @see org.eclipse.ui.IEditorInput#getPersistable()
110 public IPersistableElement
getPersistable() {
115 * @see org.eclipse.ui.IEditorInput#getToolTipText()
118 public String
getToolTipText() {
119 return classification
.getTitleCache();
123 * @return the taxonNode
125 public TaxonNode
getTaxonNode() {
130 * @return classification
132 public Classification
getClassification(){
133 return classification
;
137 * @return the conversationHolder
139 public ConversationHolder
getConversationHolder() {
140 return conversationHolder
;
146 * @see java.lang.Object#hashCode()
149 public int hashCode() {
150 final int prime
= 31;
152 result
= prime
* result
+ ((classification
== null) ?
0 : classification
.hashCode());
153 result
= prime
* result
+ ((taxonNode
== null) ?
0 : taxonNode
.hashCode());
158 * @see java.lang.Object#equals(java.lang.Object)
161 public boolean equals(Object obj
) {
168 if (getClass() != obj
.getClass()) {
171 ChecklistEditorInput other
= (ChecklistEditorInput
) obj
;
172 if (classification
== null) {
173 if (other
.classification
!= null) {
176 } else if (!classification
.equals(other
.classification
)) {
179 if (taxonNode
== null) {
180 if (other
.taxonNode
!= null) {
183 } else if (!taxonNode
.equals(other
.taxonNode
)) {
190 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
193 public void saveState(IMemento memento
) {
194 UUID uuid
= classification
.getUuid();