2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.molecular
.editor
;
12 import java
.util
.Arrays
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
17 import org
.eclipse
.ui
.IEditorInput
;
18 import org
.eclipse
.ui
.IPersistableElement
;
20 import eu
.etaxonomy
.cdm
.api
.service
.molecular
.ISequenceService
;
21 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
22 import eu
.etaxonomy
.taxeditor
.editor
.CdmEntitySessionInput
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 public class AlignmentEditorInput
extends CdmEntitySessionInput
implements IEditorInput
{
33 private static final String name
= "AlignmentEditor";
36 private final UUID sequenceNodeUuid
;
37 private Sequence sequenceNode
;
39 public AlignmentEditorInput(UUID sequenceNodeUuid
) {
41 this.sequenceNodeUuid
= sequenceNodeUuid
;
47 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
50 public Object
getAdapter(Class adapter
) {
51 // TODO Auto-generated method stub
57 * @see org.eclipse.ui.IEditorInput#exists()
60 public boolean exists() {
61 // TODO Auto-generated method stub
67 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
70 public ImageDescriptor
getImageDescriptor() {
71 // TODO Auto-generated method stub
77 * @see org.eclipse.ui.IEditorInput#getName()
80 public String
getName() {
86 * @see org.eclipse.ui.IEditorInput#getPersistable()
89 public IPersistableElement
getPersistable() {
95 * @see org.eclipse.ui.IEditorInput#getToolTipText()
98 public String
getToolTipText() {
104 * Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
107 * @return the uuid of the CDM node to work on
109 public UUID
getSequenceNodeUuid() {
110 return sequenceNodeUuid
;
115 public int hashCode() {
116 final int prime
= 31;
118 result
= prime
* result
119 + ((sequenceNodeUuid
== null) ?
0 : sequenceNodeUuid
.hashCode());
125 public boolean equals(Object obj
) {
132 if (getClass() != obj
.getClass()) {
135 AlignmentEditorInput other
= (AlignmentEditorInput
) obj
;
136 if (sequenceNodeUuid
== null) {
137 if (other
.sequenceNodeUuid
!= null) {
140 } else if (!sequenceNodeUuid
.equals(other
.sequenceNodeUuid
)) {
147 public void setSequenceNode(Sequence sequenceNode
) {
148 this.sequenceNode
= sequenceNode
;
152 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
155 public List
<Sequence
> getRootEntities() {
156 return Arrays
.asList(sequenceNode
);
161 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
164 public void merge() {
165 CdmStore
.getService(ISequenceService
.class).merge(sequenceNode
, true);