Project

General

Profile

Download (3.88 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2014 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.molecular.editor;
11

    
12

    
13
import java.util.Arrays;
14
import java.util.List;
15
import java.util.UUID;
16

    
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.ui.IEditorInput;
19
import org.eclipse.ui.IPersistableElement;
20

    
21
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
22
import eu.etaxonomy.cdm.model.molecular.Sequence;
23
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26

    
27

    
28
/**
29
 * @author pplitzner
30
 * @author Ben Stöver
31
 * @date 04.08.2014
32
 */
33
public class AlignmentEditorInput extends CdmEntitySessionInput implements IEditorInput {
34
    private static final String name = "AlignmentEditor";
35

    
36

    
37
    private final UUID sequenceNodeUuid;
38
    private Sequence sequenceNode;
39

    
40
    public AlignmentEditorInput(UUID sequenceNodeUuid) {
41
        super(false);
42
		this.sequenceNodeUuid = sequenceNodeUuid;
43
		initSession();
44
	}
45

    
46

    
47
	/* (non-Javadoc)
48
     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
49
     */
50
    @Override
51
    public Object getAdapter(Class adapter) {
52
        // TODO Auto-generated method stub
53
        return null;
54
    }
55

    
56

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

    
66

    
67
    /* (non-Javadoc)
68
     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
69
     */
70
    @Override
71
    public ImageDescriptor getImageDescriptor() {
72
        // TODO Auto-generated method stub
73
        return null;
74
    }
75

    
76

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

    
85

    
86
    /* (non-Javadoc)
87
     * @see org.eclipse.ui.IEditorInput#getPersistable()
88
     */
89
    @Override
90
    public IPersistableElement getPersistable() {
91
        return null;
92
    }
93

    
94

    
95
    /* (non-Javadoc)
96
     * @see org.eclipse.ui.IEditorInput#getToolTipText()
97
     */
98
    @Override
99
    public String getToolTipText() {
100
        return name;
101
    }
102

    
103

    
104
	/**
105
	 * Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
106
	 * is used with.
107
	 *
108
	 * @return the uuid of the CDM node to work on
109
	 */
110
	public UUID getSequenceNodeUuid() {
111
		return sequenceNodeUuid;
112
	}
113

    
114

    
115
	@Override
116
	public int hashCode() {
117
		final int prime = 31;
118
		int result = 1;
119
		result = prime * result
120
				+ ((sequenceNodeUuid == null) ? 0 : sequenceNodeUuid.hashCode());
121
		return result;
122
	}
123

    
124

    
125
	@Override
126
	public boolean equals(Object obj) {
127
		if (this == obj) {
128
            return true;
129
        }
130
		if (obj == null) {
131
            return false;
132
        }
133
		if (getClass() != obj.getClass()) {
134
            return false;
135
        }
136
		AlignmentEditorInput other = (AlignmentEditorInput) obj;
137
		if (sequenceNodeUuid == null) {
138
			if (other.sequenceNodeUuid != null) {
139
                return false;
140
            }
141
		} else if (!sequenceNodeUuid.equals(other.sequenceNodeUuid)) {
142
            return false;
143
        }
144
		return true;
145
	}
146

    
147

    
148
	public void setSequenceNode(Sequence sequenceNode) {
149
	    this.sequenceNode = sequenceNode;
150
	}
151

    
152
    /* (non-Javadoc)
153
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
154
     */
155
    @Override
156
    public List<Sequence> getRootEntities() {
157
        return Arrays.asList(sequenceNode);
158
    }
159

    
160

    
161
    /* (non-Javadoc)
162
     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
163
     */
164
    @Override
165
    public void merge() {
166
        if(CdmStore.getCurrentSessionManager().isRemoting()) {
167
            CdmStore.getService(ISequenceService.class).merge(sequenceNode, true);
168
        }
169
    }
170
}
(2-2/4)