Project

General

Profile

Download (5.05 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2013 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.taxeditor.editor.view.checklist;
11

    
12
import java.util.UUID;
13

    
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;
19

    
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;
24

    
25
/**
26
 *
27
 * @author a.oppermann
28
 * @date 25.04.2014
29
 *
30
 */
31
public class ChecklistEditorInput implements IEditorInput, IPersistable {
32

    
33
    /**
34
     * The selected classification
35
     */
36
    private TaxonNode taxonNode = null;
37

    
38
    private Classification classification = null;
39

    
40
    private final ConversationHolder conversationHolder;
41

    
42

    
43
    /**
44
     * Creates an editor input for the {@link ChecklistView} with the currently selected TaxonNode
45
     * and its childNodes.
46
     * @param taxonNode
47
     */
48
    public ChecklistEditorInput(TaxonNode taxonNode){
49
        super();
50
        this.conversationHolder = CdmStore.createConversation();
51
        this.taxonNode = CdmStore.getCurrentApplicationConfiguration().getTaxonNodeService().load(taxonNode.getUuid());
52
        classification = taxonNode.getClassification();
53
    }
54

    
55
    /**
56
     * Creates an editor input for the {@link ChecklistView} with the currently selected classification.
57
     * @param classificationUuid
58
     */
59
    public ChecklistEditorInput(Classification classification) {
60
        super();
61
        this.conversationHolder = CdmStore.createConversation();
62
        this.classification = CdmStore.getCurrentApplicationConfiguration().getClassificationService().load(classification.getUuid());
63

    
64
    }
65

    
66

    
67

    
68
    /* (non-Javadoc)
69
     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
70
     */
71
    @Override
72
    public Object getAdapter(Class adapter) {
73
        // TODO Auto-generated method stub
74
        return null;
75
    }
76

    
77
    /* (non-Javadoc)
78
     * @see org.eclipse.ui.IEditorInput#exists()
79
     */
80
    @Override
81
    public boolean exists() {
82
        return false;
83
    }
84

    
85
    /* (non-Javadoc)
86
     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
87
     */
88
    @Override
89
    public ImageDescriptor getImageDescriptor() {
90
        // TODO Auto-generated method stub
91
        return null;
92
    }
93

    
94
    /* (non-Javadoc)
95
     * @see org.eclipse.ui.IEditorInput#getName()
96
     */
97
    @Override
98
    public String getName() {
99
        if(taxonNode != null){
100
            return taxonNode.getTaxon().getName().getTitleCache();
101
        }else{
102
            return classification.getTitleCache();
103
        }
104
    }
105

    
106
    /* (non-Javadoc)
107
     * @see org.eclipse.ui.IEditorInput#getPersistable()
108
     */
109
    @Override
110
    public IPersistableElement getPersistable() {
111
        return null;
112
    }
113

    
114
    /* (non-Javadoc)
115
     * @see org.eclipse.ui.IEditorInput#getToolTipText()
116
     */
117
    @Override
118
    public String getToolTipText() {
119
        return classification.getTitleCache();
120
    }
121

    
122
    /**
123
     * @return the taxonNode
124
     */
125
    public TaxonNode getTaxonNode() {
126
        return taxonNode;
127
    }
128

    
129
    /**
130
     * @return classification
131
     */
132
    public Classification getClassification(){
133
    	return classification;
134
    }
135

    
136
    /**
137
     * @return the conversationHolder
138
     */
139
    public ConversationHolder getConversationHolder() {
140
        return conversationHolder;
141
    }
142

    
143

    
144

    
145
    /* (non-Javadoc)
146
     * @see java.lang.Object#hashCode()
147
     */
148
    @Override
149
    public int hashCode() {
150
        final int prime = 31;
151
        int result = 1;
152
        result = prime * result + ((classification == null) ? 0 : classification.hashCode());
153
        result = prime * result + ((taxonNode == null) ? 0 : taxonNode.hashCode());
154
        return result;
155
    }
156

    
157
    /* (non-Javadoc)
158
     * @see java.lang.Object#equals(java.lang.Object)
159
     */
160
    @Override
161
    public boolean equals(Object obj) {
162
        if (this == obj) {
163
            return true;
164
        }
165
        if (obj == null) {
166
            return false;
167
        }
168
        if (getClass() != obj.getClass()) {
169
            return false;
170
        }
171
        ChecklistEditorInput other = (ChecklistEditorInput) obj;
172
        if (classification == null) {
173
            if (other.classification != null) {
174
                return false;
175
            }
176
        } else if (!classification.equals(other.classification)) {
177
            return false;
178
        }
179
        if (taxonNode == null) {
180
            if (other.taxonNode != null) {
181
                return false;
182
            }
183
        } else if (!taxonNode.equals(other.taxonNode)) {
184
            return false;
185
        }
186
        return true;
187
    }
188

    
189
    /* (non-Javadoc)
190
     * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
191
     */
192
    @Override
193
    public void saveState(IMemento memento) {
194
        UUID uuid = classification.getUuid();
195
    }
196

    
197
}
(4-4/5)