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.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
;
12 import org
.eclipse
.jface
.action
.IStatusLineManager
;
13 import org
.eclipse
.swt
.graphics
.Font
;
14 import org
.eclipse
.swt
.graphics
.Image
;
15 import org
.eclipse
.swt
.widgets
.Display
;
17 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
21 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.EntityListener
;
22 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.ILineDisplayStrategy
;
25 * <p>BulkEditorLineDisplay class.</p>
30 public class BulkEditorLineDisplay
implements ILineDisplayStrategy
{
32 private BulkEditor editor
;
35 * <p>Constructor for BulkEditorLineDisplay.</p>
37 * @param editor a {@link org.eclipse.ui.IEditorPart} object.
39 public BulkEditorLineDisplay(BulkEditor editor
) {
45 public Image
getIcon(Object entity
) {
51 public int getIndent(Object entity
) {
57 public String
getText(Object entity
) {
58 return "";//editor.getEditorInput().getText((CdmBase) entity);
63 public String
getSupplementalText(Object entity
) {
65 String supplementalText
= "";
67 // AbstractBulkEditorInput input = editor.getEditorInput();
68 // String typeText = input.getTypeText(entity);
70 // supplementalText += StringUtils.isBlank(typeText) ? "" : String.format(" [%s]", typeText);
72 // if (entity instanceof IAnnotatableEntity) {
73 // IAnnotatableEntity annotatableEntity = (IAnnotatableEntity) HibernateProxyHelper.deproxy(entity);
75 // String markerText = "";
76 // List<String> markers = new ArrayList<String>();
77 // for (Marker marker : annotatableEntity.getMarkers()) {
78 // String markerLabel = marker.getMarkerType() == null? " unknown marker " : marker.getMarkerType().getLabel();
79 // markers.add(String.format("%1s = %2s", markerLabel, marker.getFlag() ? "yes" : "no"));
81 // if (! markers.isEmpty()) {
82 // markerText = StringUtils.join(markers, ", ");
85 // supplementalText += StringUtils.isBlank(markerText) ? "" : String.format(" [%s]", markerText);
88 return supplementalText
;
93 public void setText(String text
, Object entity
) {
94 if (entity
instanceof Reference
) {
95 ((Reference
) entity
).setTitleCache(text
);
101 public String
getHoverText(Object entity
) {
106 * @see eu.etaxonomy.taxeditor.bulkeditor.ILineDisplayStrategy#setStatusMessage(java.lang.String, java.lang.Object)
110 public void setStatusMessage(final String text
, Object entity
) {
112 // Calling from the synchronized method ListEditorReconcilingStrategy#doReconcile
113 // without its own thread causes an invalid thread access exception
114 // see http://wiki.eclipse.org/FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F
115 new Thread(new Runnable() {
118 Display
.getDefault().asyncExec(new Runnable() {
121 IStatusLineManager statusLineManager
= editor
.getEditorSite().getActionBars().getStatusLineManager();
122 statusLineManager
.setMessage(text
);
131 public String
getEmptyCacheMessage(Object entity
) {
132 return entity
.toString();
137 public boolean isEntityCacheEmpty(Object entity
) {
138 if (entity
instanceof Reference
) {
139 String text
= ((Reference
) entity
).getTitleCache();
140 return (text
== null || text
.equals(""));
142 if (entity
instanceof TaxonName
) {
143 String text
= ((TaxonName
) entity
).getTitleCache();
144 return (text
== null || text
.equals(""));
146 if (entity
instanceof AgentBase
) {
147 String text
= ((AgentBase
) entity
).getTitleCache();
148 return (text
== null || text
.equals(""));
155 public void addDisplayListener(Object entity
, EntityListener listener
) {
156 /* Note: all non-field specific listeners require that corresponding property sheets
157 * contain the following:
160 * public void setPropertyValue(Object id, Object value) {
162 * reference.firePropertyChange(new PropertyChangeEvent(reference, "", null, null));
166 if (entity
instanceof CdmBase
) {
167 ((CdmBase
) entity
).addPropertyChangeListener(listener
);
172 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy#getFont(java.lang.Object)
176 public Font
getFont(Object entity
) {