3 * Copyright (C) 2007 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
.annotatedlineeditor
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.text
.source
.Annotation
;
17 import eu
.etaxonomy
.cdm
.api
.service
.config
.DeleteConfiguratorBase
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.NameDeletionConfigurator
;
21 * An <code>Annotation</code> which spans an entire line and holds an object associated
22 * with the line in an <code>IEntityContainer</code>.
28 public class LineAnnotation
<T
> extends Annotation
implements IEntityContainer
<T
> {
29 @SuppressWarnings("unused")
30 private static final Logger logger
= Logger
31 .getLogger(LineAnnotationModel
.class);
33 /** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */
34 public static final String TYPE_GENERIC
= Annotation
.TYPE_UNKNOWN
;
37 private ILineDisplayStrategy lineDisplayStrategy
;
39 private boolean dirty
= false;
40 private boolean markedAsMerged
;
41 private boolean markedAsNew
;
42 private T mergeTarget
;
43 private DeleteConfiguratorBase configurator
= null;
47 * <p>Constructor for LineAnnotation.</p>
49 * @param entity a T object.
50 * @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object.
51 * @param <T> a T object.
53 public LineAnnotation(T entity
, ILineDisplayStrategy lineDisplayStrategy
) {
55 this.lineDisplayStrategy
= lineDisplayStrategy
;
56 setType(TYPE_GENERIC
);
60 * @see org.eclipse.jface.text.source.Annotation#getText()
64 public String
getText() {
65 return getEditableText();
69 * @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String)
73 public void setText(String text
) {
74 lineDisplayStrategy
.setText(text
, entity
);
81 public String
toString() {
87 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities()
90 * <p>getAttachedEntities</p>
92 * @return a {@link java.util.Set} object.
95 public Set
getAttachedEntities() {
96 // TODO Auto-generated method stub
101 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEntity()
104 * <p>Getter for the field <code>entity</code>.</p>
106 * @return a T object.
109 public T
getEntity() {
114 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEditableText()
117 * <p>getEditableText</p>
119 * @return a {@link java.lang.String} object.
122 public String
getEditableText() {
123 return lineDisplayStrategy
.getText(entity
);
127 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getMergeTarget()
130 * <p>Getter for the field <code>mergeTarget</code>.</p>
132 * @return a T object.
135 public T
getMergeTarget() {
140 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsDeleted()
143 * <p>isMarkedAsDeleted</p>
148 public boolean isMarkedAsDeleted() {
149 return super.isMarkedDeleted();
153 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsMerged()
156 * <p>isMarkedAsMerged</p>
161 public boolean isMarkedAsMerged() {
162 return markedAsMerged
;
166 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isMarkedAsNew()
169 * <p>isMarkedAsNew</p>
174 public boolean isMarkedAsNew() {
179 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsDeleted()
182 * <p>markAsDeleted</p>
185 public void markAsDeleted() {
186 super.markDeleted(true);
187 if (!isMarkedAsMerged()) {
188 lineDisplayStrategy
.setStatusMessage(entity
+ " deleted.", entity
);
191 public void markAsDeleted(DeleteConfiguratorBase config
) {
192 super.markDeleted(true);
193 this.configurator
= config
;
194 if (!isMarkedAsMerged()) {
195 lineDisplayStrategy
.setStatusMessage(entity
+ " deleted.", entity
);
199 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsMerged(eu.etaxonomy.cdm.model.common.CdmBase)
202 * <p>markAsMerged</p>
204 * @param mergeTarget a T object.
207 public void markAsMerged(T mergeTarget
) {
208 this.mergeTarget
= mergeTarget
;
209 markedAsMerged
= true;
210 lineDisplayStrategy
.setStatusMessage("'" + entity
+ "' merged into '" + mergeTarget
+ "'.", entity
);
214 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsNew()
218 public void markAsNew(boolean isNew
) {
220 lineDisplayStrategy
.setStatusMessage("New entity created.", entity
);
224 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#setDirty(boolean)
228 public void setDirty(boolean dirty
) {
233 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#isDirty()
241 public boolean isDirty() {
246 * <p>getHoverText</p>
248 * @return a {@link java.lang.String} object.
250 public String
getHoverText() {
251 return lineDisplayStrategy
.getHoverText(entity
);
255 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer#setEntity(java.lang.Object)
258 public void setEntity(Object entity
) {
259 this.entity
= (T
) entity
;
262 public DeleteConfiguratorBase
getDeleteConfigurator() {
263 return this.configurator
;
266 public void setDeleteConfigurator(DeleteConfiguratorBase config
) {
267 this.configurator
= config
;