2 * Copyright (C) 2007 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
.annotatedlineeditor
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.text
.source
.Annotation
;
16 import eu
.etaxonomy
.cdm
.api
.service
.config
.DeleteConfiguratorBase
;
19 * An <code>Annotation</code> which spans an entire line and holds an object associated
20 * with the line in an <code>IEntityContainer</code>.
26 public class LineAnnotation
<T
> extends Annotation
implements IEntityContainer
<T
> {
27 @SuppressWarnings("unused")
28 private static final Logger logger
= Logger
29 .getLogger(LineAnnotationModel
.class);
31 /** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */
32 public static final String TYPE_GENERIC
= Annotation
.TYPE_UNKNOWN
;
35 private ILineDisplayStrategy lineDisplayStrategy
;
37 private boolean dirty
= false;
38 private boolean markedAsMerged
;
39 private boolean markedAsNew
;
40 private T mergeTarget
;
41 private DeleteConfiguratorBase configurator
= null;
42 private boolean markAsDelete
;
46 * <p>Constructor for LineAnnotation.</p>
48 * @param entity a T object.
49 * @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object.
50 * @param <T> a T object.
52 public LineAnnotation(T entity
, ILineDisplayStrategy lineDisplayStrategy
) {
54 this.lineDisplayStrategy
= lineDisplayStrategy
;
55 setType(TYPE_GENERIC
);
59 * @see org.eclipse.jface.text.source.Annotation#getText()
63 public String
getText() {
64 return getEditableText();
68 * @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String)
72 public void setText(String text
) {
73 lineDisplayStrategy
.setText(text
, entity
);
80 public String
toString() {
86 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities()
89 * <p>getAttachedEntities</p>
91 * @return a {@link java.util.Set} object.
94 public Set
getAttachedEntities() {
95 // TODO Auto-generated method stub
100 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEntity()
103 * <p>Getter for the field <code>entity</code>.</p>
105 * @return a T object.
108 public T
getEntity() {
113 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEditableText()
116 * <p>getEditableText</p>
118 * @return a {@link java.lang.String} object.
121 public String
getEditableText() {
122 return lineDisplayStrategy
.getText(entity
);
126 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getMergeTarget()
129 * <p>Getter for the field <code>mergeTarget</code>.</p>
131 * @return a T object.
134 public T
getMergeTarget() {
139 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsDeleted()
142 * <p>isMarkedAsDeleted</p>
147 public boolean isMarkedAsDeleted() {
148 return super.isMarkedDeleted();
152 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsMerged()
155 * <p>isMarkedAsMerged</p>
160 public boolean isMarkedAsMerged() {
161 return markedAsMerged
;
165 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsNew()
168 * <p>isMarkedAsNew</p>
173 public boolean isMarkedAsNew() {
178 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsDeleted()
181 * <p>markAsDeleted</p>
184 public void markAsDeleted() {
185 super.markDeleted(true);
186 if (!isMarkedAsMerged()) {
187 lineDisplayStrategy
.setStatusMessage(entity
+ " deleted.", entity
);
190 public void markAsDeleted(DeleteConfiguratorBase config
) {
191 super.markDeleted(true);
192 this.configurator
= config
;
193 if (!isMarkedAsMerged()) {
194 lineDisplayStrategy
.setStatusMessage(entity
+ " deleted.", entity
);
198 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsMerged(eu.etaxonomy.cdm.model.common.CdmBase)
201 * <p>markAsMerged</p>
203 * @param mergeTarget a T object.
206 public void markAsMerged(T mergeTarget
) {
207 this.mergeTarget
= mergeTarget
;
208 markedAsMerged
= true;
209 lineDisplayStrategy
.setStatusMessage("'" + entity
+ "' merged into '" + mergeTarget
+ "'.", entity
);
213 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsNew()
217 public void markAsNew(boolean isNew
) {
219 lineDisplayStrategy
.setStatusMessage("New entity created.", entity
);
223 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#setDirty(boolean)
227 public void setDirty(boolean dirty
) {
232 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isDirty()
240 public boolean isDirty() {
245 * <p>getHoverText</p>
247 * @return a {@link java.lang.String} object.
249 public String
getHoverText() {
250 return lineDisplayStrategy
.getHoverText(entity
);
254 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer#setEntity(java.lang.Object)
257 public void setEntity(Object entity
) {
258 this.entity
= (T
) entity
;
261 public DeleteConfiguratorBase
getDeleteConfigurator() {
262 return this.configurator
;
265 public void setDeleteConfigurator(DeleteConfiguratorBase config
) {
266 this.configurator
= config
;