Project

General

Profile

Download (3.16 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.derivate;
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.IPersistableElement;
17

    
18
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
19
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
20
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
21
import eu.etaxonomy.taxeditor.store.CdmStore;
22

    
23
/**
24
 * @author pplitzner
25
 * @date 25.11.2013
26
 *
27
 */
28
public class DerivateViewEditorInput implements IEditorInput {
29

    
30
    private final UUID uuid;
31

    
32
    /**
33
     * @param uuid
34
     */
35
    public DerivateViewEditorInput(UUID uuid) {
36
        super();
37
        this.uuid = uuid;
38
    }
39

    
40
    /* (non-Javadoc)
41
     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
42
     */
43
    @Override
44
    public Object getAdapter(Class adapter) {
45
        // TODO Auto-generated method stub
46
        return null;
47
    }
48

    
49
    /* (non-Javadoc)
50
     * @see org.eclipse.ui.IEditorInput#exists()
51
     */
52
    @Override
53
    public boolean exists() {
54
        return false;
55
    }
56

    
57
    /* (non-Javadoc)
58
     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
59
     */
60
    @Override
61
    public ImageDescriptor getImageDescriptor() {
62
        // TODO Auto-generated method stub
63
        return null;
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see org.eclipse.ui.IEditorInput#getName()
68
     */
69
    @Override
70
    public String getName() {
71
        return uuid.toString();
72
    }
73

    
74
    /* (non-Javadoc)
75
     * @see org.eclipse.ui.IEditorInput#getPersistable()
76
     */
77
    @Override
78
    public IPersistableElement getPersistable() {
79
        return null;
80
    }
81

    
82
    /* (non-Javadoc)
83
     * @see org.eclipse.ui.IEditorInput#getToolTipText()
84
     */
85
    @Override
86
    public String getToolTipText() {
87
        return uuid.toString();
88
    }
89

    
90
    public SpecimenOrObservationBase<DerivedUnitFacadeCacheStrategy> getDerivate(){
91
        IOccurrenceService service = CdmStore.getService(IOccurrenceService.class);
92
        return service.find(uuid);
93
    }
94

    
95

    
96
    /* (non-Javadoc)
97
     * @see java.lang.Object#hashCode()
98
     */
99
    @Override
100
    public int hashCode() {
101
        final int prime = 31;
102
        int result = 1;
103
        result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
104
        return result;
105
    }
106

    
107
    /* (non-Javadoc)
108
     * @see java.lang.Object#equals(java.lang.Object)
109
     */
110
    @Override
111
    public boolean equals(Object obj) {
112
        if (this == obj) {
113
            return true;
114
        }
115
        if (obj == null) {
116
            return false;
117
        }
118
        if (getClass() != obj.getClass()) {
119
            return false;
120
        }
121
        DerivateViewEditorInput other = (DerivateViewEditorInput) obj;
122
        if (uuid == null) {
123
            if (other.uuid != null) {
124
                return false;
125
            }
126
        } else if (!uuid.equals(other.uuid)) {
127
            return false;
128
        }
129
        return true;
130
    }
131

    
132
}
(5-5/5)