Revert "Updated version in pom / project files to taxeditor version : 3.9.0-SNAPSHOT...
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / annotatedlineeditor / LineAnnotation.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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.annotatedlineeditor;
11
12 import java.util.Set;
13
14 import org.apache.log4j.Logger;
15 import org.eclipse.jface.text.source.Annotation;
16
17 /**
18 * An <code>Annotation</code> which spans an entire line and holds an object associated
19 * with the line in an <code>IEntityContainer</code>.
20 *
21 * @author p.ciardelli
22 * @created 25.06.2009
23 * @version 1.0
24 */
25 public class LineAnnotation<T> extends Annotation implements IEntityContainer<T> {
26 @SuppressWarnings("unused")
27 private static final Logger logger = Logger
28 .getLogger(LineAnnotationModel.class);
29
30 /** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */
31 public static final String TYPE_GENERIC = Annotation.TYPE_UNKNOWN;
32
33 private T entity;
34 private ILineDisplayStrategy lineDisplayStrategy;
35
36 private boolean dirty = false;
37 private boolean markedAsMerged;
38 private boolean markedAsNew;
39 private T mergeTarget;
40
41
42 /**
43 * <p>Constructor for LineAnnotation.</p>
44 *
45 * @param entity a T object.
46 * @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object.
47 * @param <T> a T object.
48 */
49 public LineAnnotation(T entity, ILineDisplayStrategy lineDisplayStrategy) {
50 this.entity = entity;
51 this.lineDisplayStrategy = lineDisplayStrategy;
52 setType(TYPE_GENERIC);
53 }
54
55 /* (non-Javadoc)
56 * @see org.eclipse.jface.text.source.Annotation#getText()
57 */
58 /** {@inheritDoc} */
59 @Override
60 public String getText() {
61 return getEditableText();
62 }
63
64 /* (non-Javadoc)
65 * @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String)
66 */
67 /** {@inheritDoc} */
68 @Override
69 public void setText(String text) {
70 lineDisplayStrategy.setText(text, entity);
71 dirty = true;
72 super.setText(text);
73 }
74
75 /** {@inheritDoc} */
76 @Override
77 public String toString() {
78 // For debugging
79 return getText();
80 }
81
82 /* (non-Javadoc)
83 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities()
84 */
85 /**
86 * <p>getAttachedEntities</p>
87 *
88 * @return a {@link java.util.Set} object.
89 */
90 public Set getAttachedEntities() {
91 // TODO Auto-generated method stub
92 return null;
93 }
94
95 /* (non-Javadoc)
96 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEntity()
97 */
98 /**
99 * <p>Getter for the field <code>entity</code>.</p>
100 *
101 * @return a T object.
102 */
103 public T getEntity() {
104 return entity;
105 }
106
107 /* (non-Javadoc)
108 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEditableText()
109 */
110 /**
111 * <p>getEditableText</p>
112 *
113 * @return a {@link java.lang.String} object.
114 */
115 public String getEditableText() {
116 return lineDisplayStrategy.getText(entity);
117 }
118
119 /* (non-Javadoc)
120 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getMergeTarget()
121 */
122 /**
123 * <p>Getter for the field <code>mergeTarget</code>.</p>
124 *
125 * @return a T object.
126 */
127 public T getMergeTarget() {
128 return mergeTarget;
129 }
130
131 /* (non-Javadoc)
132 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsDeleted()
133 */
134 /**
135 * <p>isMarkedAsDeleted</p>
136 *
137 * @return a boolean.
138 */
139 public boolean isMarkedAsDeleted() {
140 return super.isMarkedDeleted();
141 }
142
143 /* (non-Javadoc)
144 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsMerged()
145 */
146 /**
147 * <p>isMarkedAsMerged</p>
148 *
149 * @return a boolean.
150 */
151 public boolean isMarkedAsMerged() {
152 return markedAsMerged;
153 }
154
155 /* (non-Javadoc)
156 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsNew()
157 */
158 /**
159 * <p>isMarkedAsNew</p>
160 *
161 * @return a boolean.
162 */
163 public boolean isMarkedAsNew() {
164 return markedAsNew;
165 }
166
167 /* (non-Javadoc)
168 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsDeleted()
169 */
170 /**
171 * <p>markAsDeleted</p>
172 */
173 public void markAsDeleted() {
174 super.markDeleted(true);
175 if (!isMarkedAsMerged()) {
176 lineDisplayStrategy.setStatusMessage(entity + " deleted.", entity);
177 }
178 }
179
180 /* (non-Javadoc)
181 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsMerged(eu.etaxonomy.cdm.model.common.CdmBase)
182 */
183 /**
184 * <p>markAsMerged</p>
185 *
186 * @param mergeTarget a T object.
187 */
188 public void markAsMerged(T mergeTarget) {
189 this.mergeTarget = mergeTarget;
190 markedAsMerged = true;
191 lineDisplayStrategy.setStatusMessage("'" + entity + "' merged into '" + mergeTarget + "'.", entity);
192 }
193
194 /* (non-Javadoc)
195 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsNew()
196 */
197 /** {@inheritDoc} */
198 public void markAsNew(boolean isNew) {
199 markedAsNew = isNew;
200 lineDisplayStrategy.setStatusMessage("New entity created.", entity);
201 }
202
203 /* (non-Javadoc)
204 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#setDirty(boolean)
205 */
206 /** {@inheritDoc} */
207 public void setDirty(boolean dirty) {
208 this.dirty = dirty;
209 }
210
211 /* (non-Javadoc)
212 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isDirty()
213 */
214 /**
215 * <p>isDirty</p>
216 *
217 * @return a boolean.
218 */
219 public boolean isDirty() {
220 return dirty;
221 }
222
223 /**
224 * <p>getHoverText</p>
225 *
226 * @return a {@link java.lang.String} object.
227 */
228 public String getHoverText() {
229 return lineDisplayStrategy.getHoverText(entity);
230 }
231 }