3 * Copyright (C) 2014 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
.molecular
.editor
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
18 import org
.eclipse
.ui
.IEditorInput
;
19 import org
.eclipse
.ui
.IPersistableElement
;
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
;
33 public class AlignmentEditorInput
extends CdmEntitySessionInput
implements IEditorInput
{
34 private static final String name
= "AlignmentEditor";
37 private final UUID sequenceNodeUuid
;
38 private Sequence sequenceNode
;
40 public AlignmentEditorInput(UUID sequenceNodeUuid
) {
42 this.sequenceNodeUuid
= sequenceNodeUuid
;
48 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
51 public Object
getAdapter(Class adapter
) {
52 // TODO Auto-generated method stub
58 * @see org.eclipse.ui.IEditorInput#exists()
61 public boolean exists() {
62 // TODO Auto-generated method stub
68 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
71 public ImageDescriptor
getImageDescriptor() {
72 // TODO Auto-generated method stub
78 * @see org.eclipse.ui.IEditorInput#getName()
81 public String
getName() {
87 * @see org.eclipse.ui.IEditorInput#getPersistable()
90 public IPersistableElement
getPersistable() {
96 * @see org.eclipse.ui.IEditorInput#getToolTipText()
99 public String
getToolTipText() {
105 * Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
108 * @return the uuid of the CDM node to work on
110 public UUID
getSequenceNodeUuid() {
111 return sequenceNodeUuid
;
116 public int hashCode() {
117 final int prime
= 31;
119 result
= prime
* result
120 + ((sequenceNodeUuid
== null) ?
0 : sequenceNodeUuid
.hashCode());
126 public boolean equals(Object obj
) {
133 if (getClass() != obj
.getClass()) {
136 AlignmentEditorInput other
= (AlignmentEditorInput
) obj
;
137 if (sequenceNodeUuid
== null) {
138 if (other
.sequenceNodeUuid
!= null) {
141 } else if (!sequenceNodeUuid
.equals(other
.sequenceNodeUuid
)) {
148 public void setSequenceNode(Sequence sequenceNode
) {
149 this.sequenceNode
= sequenceNode
;
153 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
156 public List
<Sequence
> getRootEntities() {
157 return Arrays
.asList(sequenceNode
);
162 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
165 public void merge() {
166 CdmStore
.getService(ISequenceService
.class).merge(sequenceNode
, true);