950533d113f7481f3717cbf08b95eb872a1055ab
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / derivate / DerivateViewEditorInput.java
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.Set;
13 import java.util.UUID;
14
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.IEditorInput;
17 import org.eclipse.ui.IPersistableElement;
18
19 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
20 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
21
22 /**
23 * Editor input for the {@link DerivateView} which holds the currently selected derivate for which
24 * the derivate hierarchy should be shown in the DerivateView.<br>
25 * It also holds a {@link SpecimenOrObservationBase} which is the root of the hierarchy. (both may be the same object)
26 * @author pplitzner
27 * @date 25.11.2013
28 *
29 */
30 public class DerivateViewEditorInput implements IEditorInput {
31
32 /**
33 * The {@link UUID}s of the derivative entities
34 */
35 private Set<UUID> derivativeUUIDs;
36
37 /**
38 * Creates an editor input for the {@link DerivateView} with the currently selected derivates and the
39 * corresponding {@link FieldUnit}s (both may be the same object).
40 * @param derivateUuids the {@link UUID}s of the derivates for which the derivate hierarchy should be shown
41 * @param derivativeUUIDs the root of the hierarchy
42 */
43 public DerivateViewEditorInput(Set<UUID> derivateUuids) {
44 this.derivativeUUIDs = derivateUuids;
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 /* (non-Javadoc)
57 * @see org.eclipse.ui.IEditorInput#exists()
58 */
59 @Override
60 public boolean exists() {
61 return false;
62 }
63
64 /* (non-Javadoc)
65 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
66 */
67 @Override
68 public ImageDescriptor getImageDescriptor() {
69 // TODO Auto-generated method stub
70 return null;
71 }
72
73 /* (non-Javadoc)
74 * @see org.eclipse.ui.IEditorInput#getName()
75 */
76 @Override
77 public String getName() {
78 return getEditorName();
79 }
80
81 /* (non-Javadoc)
82 * @see org.eclipse.ui.IEditorInput#getPersistable()
83 */
84 @Override
85 public IPersistableElement getPersistable() {
86 return null;
87 }
88
89 /* (non-Javadoc)
90 * @see org.eclipse.ui.IEditorInput#getToolTipText()
91 */
92 @Override
93 public String getToolTipText() {
94 return getEditorName();
95 }
96
97 private String getEditorName() {
98 return "Derivative Editor";
99 }
100
101 /**
102 * @return the derivativeUUIDs
103 */
104 public Set<UUID> getDerivativeUUIDs() {
105 return derivativeUUIDs;
106 }
107
108 @Override
109 public int hashCode() {
110 final int prime = 31;
111 int result = 1;
112 result = prime * result + ((derivativeUUIDs == null) ? 0 : derivativeUUIDs.hashCode());
113 return result;
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (this == obj) {
119 return true;
120 }
121 if (obj == null) {
122 return false;
123 }
124 if (getClass() != obj.getClass()) {
125 return false;
126 }
127 DerivateViewEditorInput other = (DerivateViewEditorInput) obj;
128 if (derivativeUUIDs == null) {
129 if (other.derivativeUUIDs != null) {
130 return false;
131 }
132 } else if (!derivativeUUIDs.equals(other.derivativeUUIDs)) {
133 return false;
134 }
135 return true;
136 }
137
138 }