Revision a9f5cf7d
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/META-INF/MANIFEST.MF | ||
---|---|---|
6 | 6 |
Bundle-Activator: eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin |
7 | 7 |
Bundle-Vendor: EDIT |
8 | 8 |
Export-Package: eu.etaxonomy.taxeditor.annotatedlineeditor, |
9 |
eu.etaxonomy.taxeditor.annotatedlineeditor.handler, |
|
10 | 9 |
eu.etaxonomy.taxeditor.bulkeditor, |
11 | 10 |
eu.etaxonomy.taxeditor.bulkeditor.command, |
12 | 11 |
eu.etaxonomy.taxeditor.bulkeditor.e4, |
13 |
eu.etaxonomy.taxeditor.bulkeditor.handler, |
|
14 | 12 |
eu.etaxonomy.taxeditor.bulkeditor.input, |
15 | 13 |
eu.etaxonomy.taxeditor.bulkeditor.internal, |
16 | 14 |
eu.etaxonomy.taxeditor.bulkeditor.referencingobjects |
eu.etaxonomy.taxeditor.bulkeditor/fragment.e4xmi | ||
---|---|---|
71 | 71 |
<handlers xmi:id="_We1N8JcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeCandidateHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeCandidateHandlerE4" command="_Kkf_YJcNEeeM745tzuPNCQ"/> |
72 | 72 |
<handlers xmi:id="_a-U4EJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMergeTargetHandlerE4" command="_GAm9cJcNEeeM745tzuPNCQ"/> |
73 | 73 |
<handlers xmi:id="_qPOPQJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.NewObjectHandlerE4" command="_jWkVYJcOEeeM745tzuPNCQ"/> |
74 |
<handlers xmi:id="_vskBsJcOEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.annotatedlineeditor.e4.handler.DeleteObjectHandlerE4" command="_tLGKgJcOEeeM745tzuPNCQ"/> |
|
75 | 74 |
<handlers xmi:id="_c9ppwKK6EeeZb4PEjoRsuw" elementId="eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.bulkeditor/eu.etaxonomy.taxeditor.bulkeditor.e4.handler.SetMarkerFlagHandlerE4" command="_Svo9oKK6EeeZb4PEjoRsuw"/> |
76 | 75 |
<menus xsi:type="menu:PopupMenu" xmi:id="_B6IFsJcMEeeM745tzuPNCQ" elementId="eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"> |
77 | 76 |
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_H83EMJcMEeeM745tzuPNCQ" coreExpressionId="isCdmStoreConnected"/> |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
10 |
|
|
11 |
import java.util.Iterator; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.eclipse.core.runtime.Assert; |
|
15 |
import org.eclipse.core.runtime.CoreException; |
|
16 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
17 |
import org.eclipse.jface.operation.IRunnableContext; |
|
18 |
import org.eclipse.jface.text.BadLocationException; |
|
19 |
import org.eclipse.jface.text.Document; |
|
20 |
import org.eclipse.jface.text.IDocument; |
|
21 |
import org.eclipse.jface.text.Position; |
|
22 |
import org.eclipse.jface.text.source.Annotation; |
|
23 |
import org.eclipse.jface.text.source.IAnnotationModel; |
|
24 |
import org.eclipse.ui.IEditorInput; |
|
25 |
import org.eclipse.ui.texteditor.AbstractDocumentProvider; |
|
26 |
|
|
27 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
28 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
|
29 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* Using an <code>IEditorPart</code>, creates a document where each line is associated |
|
36 |
* with an entity. Mapping between document positions and entities is stored in |
|
37 |
* <code>LineAnnotation</code>s in a <code>LineAnnotationModel</code>. |
|
38 |
* <p> |
|
39 |
* Requires: |
|
40 |
* <ul> |
|
41 |
* <li>an <code>IEntityCreator</code> to create entities for new lines; |
|
42 |
* <li>an <code>IEntityPersistenceService</code> for interacting with the persistence layer; and |
|
43 |
* <li>an <code>ILineDisplayStrategy</code> for various visual manifestations of the domain object. |
|
44 |
* </ul> |
|
45 |
* |
|
46 |
* @author p.ciardelli |
|
47 |
* @author n.hoffmann |
|
48 |
* @created 25.06.2009 |
|
49 |
* @version 1.0 |
|
50 |
*/ |
|
51 |
public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider { |
|
52 |
|
|
53 |
private IDocument document; |
|
54 |
|
|
55 |
private LineAnnotationModel annotationModel; |
|
56 |
|
|
57 |
private IEntityCreator<?> entityCreator; |
|
58 |
|
|
59 |
private ILineDisplayStrategy lineDisplayStrategy; |
|
60 |
|
|
61 |
private final IEditorInput input; |
|
62 |
private ConversationHolder conversation; |
|
63 |
|
|
64 |
/** |
|
65 |
* @return the conversation |
|
66 |
*/ |
|
67 |
public ConversationHolder getConversation() { |
|
68 |
return conversation; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* @param conversation the conversation to set |
|
73 |
*/ |
|
74 |
public void setConversation(ConversationHolder conversation) { |
|
75 |
this.conversation = conversation; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* <p>Constructor for AnnotatedLineDocumentProvider.</p> |
|
80 |
* |
|
81 |
* @param input a {@link org.eclipse.ui.IEditorInput} object. |
|
82 |
*/ |
|
83 |
public AnnotatedLineDocumentProvider(IEditorInput input){ |
|
84 |
this.input = input; |
|
85 |
this.conversation = ((AbstractBulkEditorInput)input).getConversation(); |
|
86 |
} |
|
87 |
|
|
88 |
/** {@inheritDoc} */ |
|
89 |
@Override |
|
90 |
public IAnnotationModel getAnnotationModel(Object element) { |
|
91 |
if (element == input) { |
|
92 |
|
|
93 |
// Create model as necessary |
|
94 |
if (annotationModel == null) { |
|
95 |
annotationModel = new LineAnnotationModel(getLineDisplayStrategy(element)); |
|
96 |
annotationModel.setEntityCreator(getEntityCreator(input)); |
|
97 |
} |
|
98 |
return annotationModel; |
|
99 |
} |
|
100 |
|
|
101 |
return null; |
|
102 |
} |
|
103 |
|
|
104 |
/** {@inheritDoc} */ |
|
105 |
@Override |
|
106 |
protected IAnnotationModel createAnnotationModel(Object element) |
|
107 |
throws CoreException { |
|
108 |
return getAnnotationModel(element); |
|
109 |
} |
|
110 |
|
|
111 |
/** {@inheritDoc} */ |
|
112 |
@Override |
|
113 |
public IDocument getDocument(Object element) { |
|
114 |
return document; |
|
115 |
} |
|
116 |
|
|
117 |
/** {@inheritDoc} */ |
|
118 |
@Override |
|
119 |
protected IDocument createDocument(Object element) throws CoreException { |
|
120 |
|
|
121 |
if (element instanceof IEditorInput) { |
|
122 |
IEditorInput input = (IEditorInput) element; |
|
123 |
document = new Document(""); |
|
124 |
// IAnnotationModel model = getAnnotationModel(element); |
|
125 |
|
|
126 |
List<?> entityList = getEntityList(element); |
|
127 |
|
|
128 |
if(entityList != null){ |
|
129 |
for (Object entity : entityList) { |
|
130 |
try { |
|
131 |
createAnnotatedLine(input, entity); |
|
132 |
} catch (BadLocationException e) { |
|
133 |
MessagingUtils.error(getClass(), "Problems creating annotated line: ", e); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
return document; |
|
139 |
} |
|
140 |
return null; |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Creates an annotated line at the end of the document associated with the element |
|
145 |
* |
|
146 |
* @throws org.eclipse.jface.text.BadLocationException if any. |
|
147 |
* @param element a {@link java.lang.Object} object. |
|
148 |
* @param entity a {@link java.lang.Object} object. |
|
149 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
150 |
*/ |
|
151 |
public LineAnnotation createAnnotatedLine(Object element, Object entity) throws BadLocationException { |
|
152 |
|
|
153 |
Document document = (Document) getDocument(element); |
|
154 |
ILineDisplayStrategy lineDisplayStrategy = getLineDisplayStrategy(element); |
|
155 |
|
|
156 |
LineAnnotation annotation = new LineAnnotation(entity, lineDisplayStrategy); |
|
157 |
|
|
158 |
// Is document zero length, or is last char in document line delimiter? |
|
159 |
int docLength = document.getLength(); |
|
160 |
boolean useDelimiter = false; |
|
161 |
if (docLength > 0) { |
|
162 |
if (docLength > 1 && !document.get(docLength - 2, 2).equals(document.getDefaultLineDelimiter())) { |
|
163 |
useDelimiter = true; |
|
164 |
} |
|
165 |
} |
|
166 |
if (useDelimiter) { |
|
167 |
document.replace(docLength, 0, document.getDefaultLineDelimiter()); |
|
168 |
} |
|
169 |
|
|
170 |
String text; |
|
171 |
if (lineDisplayStrategy.isEntityCacheEmpty(entity)) { |
|
172 |
text = lineDisplayStrategy.getEmptyCacheMessage(entity); |
|
173 |
} else { |
|
174 |
text = lineDisplayStrategy.getText(entity); |
|
175 |
} |
|
176 |
text += lineDisplayStrategy.getSupplementalText(entity); |
|
177 |
docLength = document.getLength(); |
|
178 |
document.replace(docLength, 0, text); |
|
179 |
|
|
180 |
Position position = new Position(docLength, text.length()); |
|
181 |
|
|
182 |
IAnnotationModel model = getAnnotationModel(element); |
|
183 |
if(model != null){ |
|
184 |
model.addAnnotation(annotation, position); |
|
185 |
} |
|
186 |
|
|
187 |
// lineDisplayStrategy.addDisplayListener(entity, |
|
188 |
// new EntityListenerImpl((LineAnnotation) annotation, element)); |
|
189 |
// |
|
190 |
return annotation; |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
/** |
|
195 |
* <p>updateLineFromAnnotation</p> |
|
196 |
* |
|
197 |
* @param annotation a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
198 |
*/ |
|
199 |
public void updateLineFromAnnotation(LineAnnotation annotation) { |
|
200 |
|
|
201 |
IAnnotationModel model = getAnnotationModel(input); |
|
202 |
IDocument document = getDocument(input); |
|
203 |
ILineDisplayStrategy lineDisplay = getLineDisplayStrategy(input); |
|
204 |
|
|
205 |
Object entity = annotation.getEntity(); |
|
206 |
String text = ""; |
|
207 |
if (getLineDisplayStrategy(input).isEntityCacheEmpty(entity)) { |
|
208 |
text = lineDisplay.getEmptyCacheMessage(entity); |
|
209 |
} else { |
|
210 |
text = lineDisplay.getText(entity); |
|
211 |
} |
|
212 |
text += lineDisplay.getSupplementalText(entity); |
|
213 |
|
|
214 |
try { |
|
215 |
if (model.getPosition(annotation) == null) { |
|
216 |
return; |
|
217 |
} |
|
218 |
int offset = model.getPosition(annotation).getOffset(); |
|
219 |
int line = document.getLineOfOffset(offset); |
|
220 |
int lineLength = document.getLineLength(document.getLineOfOffset(offset)); |
|
221 |
if (document.getLineDelimiter(line) != null) { |
|
222 |
lineLength -= document.getLineDelimiter(line).length(); |
|
223 |
} |
|
224 |
document.replace(offset, lineLength, text); |
|
225 |
} catch (BadLocationException e) { |
|
226 |
MessagingUtils.error(getClass(), "Problem updating annotated line: " ,e); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* @param element |
|
232 |
* @return |
|
233 |
*/ |
|
234 |
private List<?> getEntityList(Object element) { |
|
235 |
if (element instanceof AbstractBulkEditorInput) { |
|
236 |
return ((AbstractBulkEditorInput)element).getModel(); |
|
237 |
} |
|
238 |
return null; |
|
239 |
} |
|
240 |
|
|
241 |
/** {@inheritDoc} */ |
|
242 |
@Override |
|
243 |
protected void doSaveDocument(IProgressMonitor monitor, Object element, |
|
244 |
IDocument document, boolean overwrite) throws CoreException { |
|
245 |
if (element instanceof AbstractBulkEditorInput) { |
|
246 |
|
|
247 |
IEntityPersistenceService persistenceService = (AbstractBulkEditorInput) element; |
|
248 |
|
|
249 |
// Get new containers from annotation model |
|
250 |
LineAnnotationModel model = (LineAnnotationModel) getAnnotationModel(element); |
|
251 |
Iterator iterator = model.getAnnotationIterator(); |
|
252 |
if (!this.conversation.isBound()){ |
|
253 |
this.conversation.bind(); |
|
254 |
} |
|
255 |
|
|
256 |
while (iterator.hasNext()) { |
|
257 |
Annotation annotation = (Annotation) iterator.next(); |
|
258 |
if (annotation instanceof IEntityContainer<?>) { |
|
259 |
IEntityContainer<?> container = (IEntityContainer<?>) annotation; |
|
260 |
|
|
261 |
if (container.isMarkedAsNew() || container.isDirty()) { |
|
262 |
|
|
263 |
Object entity = persistenceService.save(container.getEntity()); // save |
|
264 |
container.setEntity(entity); |
|
265 |
container.setDirty(false); |
|
266 |
container.markAsNew(false); |
|
267 |
} |
|
268 |
} |
|
269 |
} |
|
270 |
this.conversation.commit(true); |
|
271 |
for (LineAnnotation<?> annotation : model.getDeletedAnnotations()) { |
|
272 |
if (annotation.isMarkedAsNew()) { |
|
273 |
continue; |
|
274 |
} |
|
275 |
if (annotation.isMarkedAsMerged()) { |
|
276 |
persistenceService.merge(annotation.getEntity(), annotation.getMergeTarget()); // merge |
|
277 |
} |
|
278 |
if (annotation.isMarkedAsDeleted()) { |
|
279 |
try { |
|
280 |
persistenceService.delete(annotation.getEntity(), annotation.getDeleteConfigurator()); |
|
281 |
} catch (ReferencedObjectUndeletableException e) { |
|
282 |
// TODO Auto-generated catch block |
|
283 |
e.printStackTrace(); |
|
284 |
} // merge |
|
285 |
} |
|
286 |
|
|
287 |
else { |
|
288 |
// TODO clarify w AM whether this needs to be executed on merged objects |
|
289 |
//persistenceService.delete(annotation.getEntity()); // delete |
|
290 |
} |
|
291 |
} |
|
292 |
model.clearDeletedAnnotations(); |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
/** {@inheritDoc} */ |
|
297 |
@Override |
|
298 |
protected IRunnableContext getOperationRunner(IProgressMonitor monitor) { |
|
299 |
return null; |
|
300 |
} |
|
301 |
|
|
302 |
/** {@inheritDoc} */ |
|
303 |
@Override |
|
304 |
public boolean isModifiable(Object element) { |
|
305 |
return true; |
|
306 |
} |
|
307 |
|
|
308 |
/** {@inheritDoc} */ |
|
309 |
@Override |
|
310 |
public boolean isReadOnly(Object element) { |
|
311 |
// enables copy & paste |
|
312 |
return false; |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* <p>Getter for the field <code>entityCreator</code>.</p> |
|
317 |
* |
|
318 |
* @param element a {@link java.lang.Object} object. |
|
319 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator} object. |
|
320 |
*/ |
|
321 |
public IEntityCreator<?> getEntityCreator(IEditorInput input) { |
|
322 |
if (input instanceof AbstractBulkEditorInput) { |
|
323 |
entityCreator = ((AbstractBulkEditorInput) input).getEntityCreator(); |
|
324 |
} |
|
325 |
return entityCreator; |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* <p>Setter for the field <code>lineDisplayStrategy</code>.</p> |
|
330 |
* |
|
331 |
* @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object. |
|
332 |
* @param element a {@link java.lang.Object} object. |
|
333 |
*/ |
|
334 |
public void setLineDisplayStrategy( |
|
335 |
ILineDisplayStrategy lineDisplayStrategy, Object element) { |
|
336 |
if (element instanceof IEditorInput) { |
|
337 |
this.lineDisplayStrategy = lineDisplayStrategy; |
|
338 |
} |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* <p>Getter for the field <code>lineDisplayStrategy</code>.</p> |
|
343 |
* |
|
344 |
* @param element a {@link java.lang.Object} object. |
|
345 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object. |
|
346 |
*/ |
|
347 |
protected ILineDisplayStrategy getLineDisplayStrategy(Object element) { |
|
348 |
if (element instanceof IEditorInput) { |
|
349 |
Assert.isNotNull(lineDisplayStrategy, "No ILineDisplayStrategy set for this element."); |
|
350 |
return lineDisplayStrategy; |
|
351 |
} |
|
352 |
return null; |
|
353 |
} |
|
354 |
|
|
355 |
/** |
|
356 |
* <p>removeAnnotatedLine</p> |
|
357 |
* |
|
358 |
* @param entity a {@link java.lang.Object} object. |
|
359 |
*/ |
|
360 |
public void removeAnnotatedLine(Object entity){ |
|
361 |
LineAnnotation annotation = (LineAnnotation) annotationModel.getAnnotation(entity); |
|
362 |
removeAnnotatedLine(annotation); |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* <p>removeAnnotatedLine</p> |
|
367 |
* |
|
368 |
* @param lineno a int. |
|
369 |
* @param element a {@link java.lang.Object} object. |
|
370 |
*/ |
|
371 |
public void removeAnnotatedLine(Object element, int lineno) { |
|
372 |
LineAnnotation annotation = (LineAnnotation) annotationModel.getAnnotationAtLine(lineno, document); |
|
373 |
removeAnnotatedLine(annotation); |
|
374 |
} |
|
375 |
|
|
376 |
/** |
|
377 |
* <p>removeAnnotatedLine</p> |
|
378 |
* |
|
379 |
* @param annotation a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
380 |
*/ |
|
381 |
public void removeAnnotatedLine(LineAnnotation annotation) { |
|
382 |
if (annotation != null) { |
|
383 |
Document document = (Document) getDocument(input); |
|
384 |
LineAnnotationModel model = (LineAnnotationModel) getAnnotationModel(input); |
|
385 |
|
|
386 |
Position position = model.getPosition(annotation); |
|
387 |
int offset = position.getOffset(); |
|
388 |
int length = position.getLength(); |
|
389 |
|
|
390 |
Object entity = annotation.getEntity(); |
|
391 |
//annotation.markAsDeleted(configurator); |
|
392 |
model.removeAnnotation(annotation); |
|
393 |
|
|
394 |
// Immediately followed by a delimiter? |
|
395 |
int annotationEnd = offset + length; |
|
396 |
try { |
|
397 |
if (document.getLength() > annotationEnd + 1 && document.get(annotationEnd, 2).equals(document.getDefaultLineDelimiter())) { |
|
398 |
length += 2; |
|
399 |
} |
|
400 |
} catch (BadLocationException e1) { |
|
401 |
MessagingUtils.error(getClass(), "Problems removing annotated line", e1); |
|
402 |
} |
|
403 |
|
|
404 |
try { |
|
405 |
|
|
406 |
document.replace(offset, length, ""); |
|
407 |
|
|
408 |
} catch (BadLocationException e) { |
|
409 |
MessagingUtils.error(getClass(), "Problems removing annotated line", e); |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
|
|
414 |
/* (non-Javadoc) |
|
415 |
* @see org.eclipse.ui.texteditor.AbstractDocumentProvider#changed(java.lang.Object) |
|
416 |
*/ |
|
417 |
/** {@inheritDoc} */ |
|
418 |
@Override |
|
419 |
public void changed(Object entity) { |
|
420 |
LineAnnotation annotation = (LineAnnotation) annotationModel.getAnnotation(entity); |
|
421 |
if(annotation != null){ |
|
422 |
annotation.setDirty(true); |
|
423 |
updateLineFromAnnotation(annotation); |
|
424 |
} |
|
425 |
} |
|
426 |
|
|
427 |
|
|
428 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
10 |
|
|
11 |
import java.util.Iterator; |
|
12 |
|
|
13 |
import org.eclipse.core.runtime.CoreException; |
|
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
15 |
import org.eclipse.jface.text.BadLocationException; |
|
16 |
import org.eclipse.jface.text.source.IAnnotationModel; |
|
17 |
import org.eclipse.jface.text.source.ISourceViewer; |
|
18 |
import org.eclipse.jface.text.source.IVerticalRuler; |
|
19 |
import org.eclipse.swt.widgets.Composite; |
|
20 |
import org.eclipse.ui.IEditorInput; |
|
21 |
import org.eclipse.ui.PlatformUI; |
|
22 |
import org.eclipse.ui.editors.text.TextEditor; |
|
23 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
|
24 |
|
|
25 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
26 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
|
27 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
28 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
30 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
|
31 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
32 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
33 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
34 |
|
|
35 |
/** |
|
36 |
* A list-based editor, where each line in the editor's document is associated with a domain object. |
|
37 |
* <p> |
|
38 |
* Extending classes must set: |
|
39 |
* <ul> |
|
40 |
* <li>an {@link IEntityPersistenceService} for interacting with the persistence layer; and |
|
41 |
* <li>an {@link ILineDisplayStrategy} for various visual manifestations of the domain object. |
|
42 |
* </ul> |
|
43 |
* |
|
44 |
* @author p.ciardelli |
|
45 |
* @created 25.06.2009 |
|
46 |
* @version 1.0 |
|
47 |
*/ |
|
48 |
public class AnnotatedLineEditor extends TextEditor implements IConversationEnabled, IPostOperationEnabled { |
|
49 |
|
|
50 |
protected ConversationHolder conversation; |
|
51 |
|
|
52 |
private IEntityPersistenceService persistenceService; |
|
53 |
protected ILineDisplayStrategy lineDisplayStrategy; |
|
54 |
|
|
55 |
|
|
56 |
/** |
|
57 |
* <p>Constructor for AnnotatedLineEditor.</p> |
|
58 |
* |
|
59 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. |
|
60 |
*/ |
|
61 |
public AnnotatedLineEditor(ConversationHolder conversation) { |
|
62 |
this.conversation = conversation; |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput) |
|
67 |
*/ |
|
68 |
/** {@inheritDoc} */ |
|
69 |
@Override |
|
70 |
protected void doSetInput(IEditorInput input) throws CoreException { |
|
71 |
|
|
72 |
AnnotatedLineDocumentProvider provider = new AnnotatedLineDocumentProvider(input); |
|
73 |
|
|
74 |
provider.setLineDisplayStrategy(lineDisplayStrategy, input); |
|
75 |
setDocumentProvider(provider); |
|
76 |
|
|
77 |
super.doSetInput(input); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* <p>Setter for the field <code>persistenceService</code>.</p> |
|
82 |
* |
|
83 |
* @param persistenceService a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService} object. |
|
84 |
*/ |
|
85 |
protected void setPersistenceService( |
|
86 |
IEntityPersistenceService persistenceService) { |
|
87 |
this.persistenceService = persistenceService; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* <p>Getter for the field <code>persistenceService</code>.</p> |
|
92 |
* |
|
93 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService} object. |
|
94 |
*/ |
|
95 |
protected IEntityPersistenceService getPersistenceService() { |
|
96 |
return persistenceService; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* <p>Setter for the field <code>lineDisplayStrategy</code>.</p> |
|
101 |
* |
|
102 |
* @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object. |
|
103 |
*/ |
|
104 |
protected void setLineDisplayStrategy( |
|
105 |
ILineDisplayStrategy lineDisplayStrategy) { |
|
106 |
this.lineDisplayStrategy = lineDisplayStrategy; |
|
107 |
} |
|
108 |
|
|
109 |
/** {@inheritDoc} */ |
|
110 |
@Override |
|
111 |
protected ISourceViewer createSourceViewer(Composite parent, |
|
112 |
IVerticalRuler ruler, int styles) { |
|
113 |
|
|
114 |
fAnnotationAccess= getAnnotationAccess(); |
|
115 |
fOverviewRuler= createOverviewRuler(getSharedColors()); |
|
116 |
LineSelectionViewer viewer = new LineSelectionViewer(parent, ruler, getOverviewRuler(), |
|
117 |
isOverviewRulerVisible(), styles); |
|
118 |
// isOverviewRulerVisible(), styles | SWT.WRAP); |
|
119 |
getSourceViewerDecorationSupport(viewer); |
|
120 |
|
|
121 |
return viewer; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Create an annotated line with an "empty" entity, i.e. using the editor |
|
126 |
* input's default entity type and a zero-length title cache. |
|
127 |
* |
|
128 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
129 |
*/ |
|
130 |
public LineAnnotation createAnnotatedLineNewObject() { |
|
131 |
|
|
132 |
// Create new object |
|
133 |
|
|
134 |
AnnotatedLineDocumentProvider documentProvider = (AnnotatedLineDocumentProvider) getDocumentProvider(); |
|
135 |
IEntityCreator entityCreator = documentProvider.getEntityCreator(getEditorInput()); |
|
136 |
Object entity = entityCreator.createEntity(null); |
|
137 |
|
|
138 |
LineAnnotation annotation = createAnnotatedLine(entity); |
|
139 |
if (annotation != null) { |
|
140 |
annotation.markAsNew(true); |
|
141 |
} |
|
142 |
return annotation; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Create an annotated line, first creating an entity of type "key" - this key |
|
147 |
* must be recognized by the editor's entity creator. |
|
148 |
* |
|
149 |
* @param key a {@link java.lang.Object} object. |
|
150 |
* @param titleCache a {@link java.lang.String} object. |
|
151 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
152 |
*/ |
|
153 |
public LineAnnotation createAnnotatedLineNewObject(Object key, String titleCache) { |
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
// Create new object |
|
158 |
Object entity = ((AnnotatedLineDocumentProvider) getDocumentProvider()). |
|
159 |
getEntityCreator(getEditorInput()).createEntity(key, titleCache); |
|
160 |
// checks if the creator also saves the entity (in a different conversation), in which case |
|
161 |
// we need to bind back this editors conversation |
|
162 |
// we also need to reload the entity because the conversation used to |
|
163 |
// to create / save the entity may have been closed |
|
164 |
if(entity != null && ((AnnotatedLineDocumentProvider) getDocumentProvider()).getEntityCreator(getEditorInput()).savesEntity()) { |
|
165 |
getConversationHolder().bind(); |
|
166 |
//FIXME: why do we use IOccurrenceService here? is this generic? |
|
167 |
//because this method is only invoked by the handler which is used in the |
|
168 |
//specimen bulk editor. This is unsafe and should be refactored! |
|
169 |
Object object = CdmStore.getService(IOccurrenceService.class).load(((CdmBase)entity).getUuid()); |
|
170 |
entity = HibernateProxyHelper.deproxy(object); |
|
171 |
} |
|
172 |
|
|
173 |
if(entity == null) { |
|
174 |
return null; |
|
175 |
} |
|
176 |
LineAnnotation annotation = createAnnotatedLine(entity); |
|
177 |
if (annotation != null) { |
|
178 |
annotation.markAsNew(true); |
|
179 |
} |
|
180 |
|
|
181 |
return annotation; |
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public boolean isDirty() { |
|
187 |
return super.isDirty(); |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Creates an annotated line at the end of the document. The annotation contains the entity. |
|
192 |
* |
|
193 |
* @param entity a {@link java.lang.Object} object. |
|
194 |
* @return a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
195 |
*/ |
|
196 |
public LineAnnotation createAnnotatedLine(Object entity) { |
|
197 |
|
|
198 |
IEditorInput input = getEditorInput(); |
|
199 |
this.conversation.close(); |
|
200 |
this.conversation = ((AbstractBulkEditorInput)input).getConversation(); |
|
201 |
AnnotatedLineDocumentProvider provider = (AnnotatedLineDocumentProvider) getDocumentProvider(); |
|
202 |
|
|
203 |
LineAnnotation annotation = null; |
|
204 |
try { |
|
205 |
annotation = provider.createAnnotatedLine(input, entity); |
|
206 |
|
|
207 |
// Jump to new line |
|
208 |
IAnnotationModel model = provider.getAnnotationModel(input); |
|
209 |
if(model != null){ |
|
210 |
int start= model.getPosition(annotation).getOffset(); |
|
211 |
selectAndReveal(start, 0); |
|
212 |
} |
|
213 |
|
|
214 |
} catch (BadLocationException e) { |
|
215 |
// TODO Auto-generated catch block |
|
216 |
e.printStackTrace(); |
|
217 |
} |
|
218 |
return annotation; |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* <p>removeAnnotatedLine</p> |
|
223 |
* |
|
224 |
* @param lineno a int. |
|
225 |
*/ |
|
226 |
public void removeAnnotatedLine(int lineno) { |
|
227 |
((AnnotatedLineDocumentProvider) getDocumentProvider()).removeAnnotatedLine(lineno); |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* <p>removeAnnotatedLine</p> |
|
232 |
* |
|
233 |
* @param annotation a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation} object. |
|
234 |
*/ |
|
235 |
public void removeAnnotatedLine(LineAnnotation annotation) { |
|
236 |
((AnnotatedLineDocumentProvider) getDocumentProvider()).removeAnnotatedLine(annotation); |
|
237 |
|
|
238 |
} |
|
239 |
|
|
240 |
/* (non-Javadoc) |
|
241 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
242 |
*/ |
|
243 |
/** {@inheritDoc} */ |
|
244 |
@Override |
|
245 |
public void doSave(IProgressMonitor progressMonitor) { |
|
246 |
if (getConversationHolder() != null) { |
|
247 |
if( ! getConversationHolder().isBound()){ |
|
248 |
getConversationHolder().bind(); |
|
249 |
} |
|
250 |
super.doSave(progressMonitor); |
|
251 |
getConversationHolder().commit(true); |
|
252 |
} else { |
|
253 |
super.doSave(progressMonitor); |
|
254 |
} |
|
255 |
firePropertyChange(PROP_DIRTY); |
|
256 |
} |
|
257 |
|
|
258 |
/* (non-Javadoc) |
|
259 |
* @see org.eclipse.ui.texteditor.AbstractTextEditor#setFocus() |
|
260 |
*/ |
|
261 |
/** {@inheritDoc} */ |
|
262 |
@Override |
|
263 |
public void setFocus() { |
|
264 |
super.setFocus(); |
|
265 |
if (getConversationHolder() != null) { |
|
266 |
getConversationHolder().bind(); |
|
267 |
} |
|
268 |
((AbstractBulkEditorInput)getEditorInput()).bind(); |
|
269 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus(); |
|
270 |
// TODO pass focus to underlying widgets |
|
271 |
} |
|
272 |
|
|
273 |
/* (non-Javadoc) |
|
274 |
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder() |
|
275 |
*/ |
|
276 |
/** |
|
277 |
* <p>getConversationHolder</p> |
|
278 |
* |
|
279 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. |
|
280 |
*/ |
|
281 |
@Override |
|
282 |
public ConversationHolder getConversationHolder() { |
|
283 |
return conversation; |
|
284 |
} |
|
285 |
|
|
286 |
/* (non-Javadoc) |
|
287 |
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap) |
|
288 |
*/ |
|
289 |
/** {@inheritDoc} */ |
|
290 |
@Override |
|
291 |
public void update(CdmDataChangeMap changeEvents) {} |
|
292 |
|
|
293 |
/** |
|
294 |
* Refreshes text in all lines. |
|
295 |
*/ |
|
296 |
protected void refreshLineDisplay() { |
|
297 |
IDocumentProvider provider = getDocumentProvider(); |
|
298 |
IEditorInput input = getEditorInput(); |
|
299 |
IAnnotationModel model = provider.getAnnotationModel(input); |
|
300 |
Iterator iter = getDocumentProvider().getAnnotationModel(getEditorInput()).getAnnotationIterator(); |
|
301 |
while (iter.hasNext()) { |
|
302 |
Object next = iter.next(); |
|
303 |
if (next instanceof LineAnnotation) { |
|
304 |
LineAnnotation annotation = (LineAnnotation) next; |
|
305 |
((AnnotatedLineDocumentProvider) getDocumentProvider()). |
|
306 |
updateLineFromAnnotation(annotation); |
|
307 |
} |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
/* (non-Javadoc) |
|
312 |
* @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase) |
|
313 |
*/ |
|
314 |
/** {@inheritDoc} */ |
|
315 |
@Override |
|
316 |
public boolean postOperation(CdmBase objectAffectedByOperation) { |
|
317 |
refreshLineDisplay(); |
|
318 |
|
|
319 |
return true; |
|
320 |
} |
|
321 |
|
|
322 |
/* (non-Javadoc) |
|
323 |
* @see org.eclipse.ui.editors.text.TextEditor#dispose() |
|
324 |
*/ |
|
325 |
/** {@inheritDoc} */ |
|
326 |
@Override |
|
327 |
public void dispose() { |
|
328 |
super.dispose(); |
|
329 |
conversation.close(); |
|
330 |
((AbstractBulkEditorInput)getEditorInput()).dispose(); |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* <p>onComplete</p> |
|
335 |
* |
|
336 |
* @return a boolean. |
|
337 |
*/ |
|
338 |
@Override |
|
339 |
public boolean onComplete() { |
|
340 |
// TODO Auto-generated method stub |
|
341 |
return false; |
|
342 |
} |
|
343 |
|
|
344 |
|
|
345 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorPartitioner.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.eclipse.jface.text.BadLocationException; |
|
17 |
import org.eclipse.jface.text.Document; |
|
18 |
import org.eclipse.jface.text.DocumentEvent; |
|
19 |
import org.eclipse.jface.text.IDocument; |
|
20 |
import org.eclipse.jface.text.IRegion; |
|
21 |
import org.eclipse.jface.text.ITypedRegion; |
|
22 |
import org.eclipse.jface.text.Region; |
|
23 |
import org.eclipse.jface.text.TypedRegion; |
|
24 |
import org.eclipse.jface.text.rules.FastPartitioner; |
|
25 |
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; |
|
26 |
|
|
27 |
/** |
|
28 |
* Separates each line into partitions for the main text - usually the |
|
29 |
* object's title cache - and supplemental text. The supplemental text |
|
30 |
* partition can then be given a different color and / or font style by |
|
31 |
* the editor's presentation reconciler. |
|
32 |
* |
|
33 |
* @author p.ciardelli |
|
34 |
* @created 28.10.2009 |
|
35 |
* @version 1.0 |
|
36 |
*/ |
|
37 |
public class AnnotatedLineEditorPartitioner extends FastPartitioner { |
|
38 |
private static final Logger logger = Logger |
|
39 |
.getLogger(AnnotatedLineEditorPartitioner.class); |
|
40 |
|
|
41 |
private Document document; |
|
42 |
private LineAnnotationModel model; |
|
43 |
private ILineDisplayStrategy lineDisplayStrategy; |
|
44 |
|
|
45 |
/** |
|
46 |
* <p>Constructor for AnnotatedLineEditorPartitioner.</p> |
|
47 |
* |
|
48 |
* @param document a {@link org.eclipse.jface.text.Document} object. |
|
49 |
* @param model a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel} object. |
|
50 |
* @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object. |
|
51 |
*/ |
|
52 |
public AnnotatedLineEditorPartitioner(Document document, LineAnnotationModel model, ILineDisplayStrategy lineDisplayStrategy) { |
|
53 |
super(new RuleBasedPartitionScanner(), |
|
54 |
new String[] {ILineDisplayStrategy.SUPPLEMENTAL_TEXT}); |
|
55 |
|
|
56 |
this.document = document; |
|
57 |
this.model = model; |
|
58 |
this.lineDisplayStrategy = lineDisplayStrategy; |
|
59 |
} |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see org.eclipse.jface.text.rules.FastPartitioner#computePartitioning(int, int, boolean) |
|
63 |
*/ |
|
64 |
/** {@inheritDoc} */ |
|
65 |
@Override |
|
66 |
public ITypedRegion[] computePartitioning(int offset, |
|
67 |
int length, boolean includeZeroLengthPartitions) { |
|
68 |
List<ITypedRegion> regions = new ArrayList<ITypedRegion>(); |
|
69 |
try { |
|
70 |
int lines = document.getNumberOfLines(offset, length); |
|
71 |
int startLine = document.getLineOfOffset(offset); |
|
72 |
|
|
73 |
// Iterate through all affected lines, separating into regions of DEFAULT_CONTENT_TYPE and SUPPLEMENTAL_TEXT |
|
74 |
for (int i = startLine; i < startLine + lines; i++) { |
|
75 |
LineAnnotation annotation = (LineAnnotation) ((LineAnnotationModel) model).getAnnotationAtLine(i, document); |
|
76 |
if (annotation != null) { |
|
77 |
IRegion lineInfo = document.getLineInformation(i); |
|
78 |
String lineText = document.get(lineInfo.getOffset(), lineInfo.getLength()); |
|
79 |
|
|
80 |
String supplementalText = lineDisplayStrategy.getSupplementalText(annotation.getEntity()); |
|
81 |
if (supplementalText == null || supplementalText.equals("")) { |
|
82 |
continue; |
|
83 |
} |
|
84 |
if (lineText.contains(supplementalText)) { |
|
85 |
int startSupplementalText = lineText.indexOf(supplementalText) + lineInfo.getOffset(); |
|
86 |
|
|
87 |
if (startSupplementalText > lineInfo.getOffset()) { |
|
88 |
regions.add(new TypedRegion(lineInfo.getOffset(), startSupplementalText - lineInfo.getOffset(), |
|
89 |
IDocument.DEFAULT_CONTENT_TYPE)); |
|
90 |
logger.warn("Non supp at " + lineInfo.getOffset() + ", length " + (startSupplementalText - lineInfo.getOffset())); |
|
91 |
} |
|
92 |
regions.add(new TypedRegion(startSupplementalText, supplementalText.length(), |
|
93 |
ILineDisplayStrategy.SUPPLEMENTAL_TEXT)); |
|
94 |
logger.warn("Supp at " + startSupplementalText + ", length " + supplementalText.length()); |
|
95 |
if (startSupplementalText + supplementalText.length() < lineInfo.getOffset() + lineInfo.getLength()) { |
|
96 |
regions.add(new TypedRegion(startSupplementalText + supplementalText.length(), |
|
97 |
lineInfo.getLength() - startSupplementalText - supplementalText.length(), |
|
98 |
IDocument.DEFAULT_CONTENT_TYPE)); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
103 |
} |
|
104 |
} catch (BadLocationException e) { |
|
105 |
return super.computePartitioning(offset, length, includeZeroLengthPartitions); |
|
106 |
} |
|
107 |
return (ITypedRegion[]) regions.toArray(new ITypedRegion[regions.size()]); |
|
108 |
} |
|
109 |
|
|
110 |
/* (non-Javadoc) |
|
111 |
* @see org.eclipse.jface.text.rules.FastPartitioner#documentChanged2(org.eclipse.jface.text.DocumentEvent) |
|
112 |
*/ |
|
113 |
/** {@inheritDoc} */ |
|
114 |
@Override |
|
115 |
public IRegion documentChanged2(DocumentEvent e) { |
|
116 |
computePartitioning(e.getOffset(), e.getLength()); |
|
117 |
return new Region(e.getOffset(), e.getLength()); |
|
118 |
// return super.documentChanged2(e); |
|
119 |
} |
|
120 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorReconcilingStrategy.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.eclipse.jface.text.BadLocationException; |
|
15 |
import org.eclipse.jface.text.IDocument; |
|
16 |
import org.eclipse.jface.text.IRegion; |
|
17 |
import org.eclipse.jface.text.Position; |
|
18 |
import org.eclipse.jface.text.reconciler.DirtyRegion; |
|
19 |
import org.eclipse.jface.text.reconciler.IReconcilingStrategy; |
|
20 |
import org.eclipse.jface.text.source.Annotation; |
|
21 |
import org.eclipse.jface.text.source.IAnnotationModel; |
|
22 |
import org.eclipse.jface.text.source.ISourceViewer; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* Doesn't work! |
|
27 |
* |
|
28 |
* @author p.ciardelli |
|
29 |
* @created 25.06.2009 |
|
30 |
* @version 1.0 |
|
31 |
*/ |
|
32 |
public class AnnotatedLineEditorReconcilingStrategy implements IReconcilingStrategy { |
|
33 |
private static final Logger logger = Logger |
|
34 |
.getLogger(AnnotatedLineEditorReconcilingStrategy.class); |
|
35 |
|
|
36 |
private IDocument document; |
|
37 |
private ISourceViewer viewer; |
|
38 |
|
|
39 |
/** |
|
40 |
* <p>Constructor for AnnotatedLineEditorReconcilingStrategy.</p> |
|
41 |
* |
|
42 |
* @param sourceViewer a {@link org.eclipse.jface.text.source.ISourceViewer} object. |
|
43 |
*/ |
|
44 |
public AnnotatedLineEditorReconcilingStrategy(ISourceViewer sourceViewer) { |
|
45 |
this.viewer = sourceViewer; |
|
46 |
} |
|
47 |
|
|
48 |
/* (non-Javadoc) |
|
49 |
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion) |
|
50 |
*/ |
|
51 |
/** {@inheritDoc} */ |
|
52 |
public void reconcile(IRegion partition) { |
|
53 |
// not used |
|
54 |
} |
|
55 |
|
|
56 |
/* (non-Javadoc) |
|
57 |
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion) |
|
58 |
*/ |
|
59 |
/** {@inheritDoc} */ |
|
60 |
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { |
|
61 |
try { |
|
62 |
doReconcile(dirtyRegion); |
|
63 |
} catch (BadLocationException e) { |
|
64 |
// TODO Auto-generated catch block |
|
65 |
e.printStackTrace(); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
synchronized private void doReconcile(DirtyRegion dirtyRegion) throws BadLocationException { |
|
70 |
// Get all affected lines |
|
71 |
int dirtyOffset = dirtyRegion.getOffset(); |
|
72 |
int dirtyLength = dirtyRegion.getLength(); |
|
73 |
|
|
74 |
int lineChangeStart = document.getLineOfOffset(dirtyOffset); |
|
75 |
int lineChangeEnd; |
|
76 |
if (DirtyRegion.INSERT.equals(dirtyRegion.getType())) { |
|
77 |
lineChangeEnd = document.getLineOfOffset(dirtyOffset + dirtyLength); |
|
78 |
} else { |
|
79 |
lineChangeEnd = lineChangeStart; |
|
80 |
} |
|
81 |
|
|
82 |
for (int i = lineChangeStart; i <= lineChangeEnd; i++) { |
|
83 |
int lineOffset = document.getLineOffset(i); |
|
84 |
int lineLength = document.getLineLength(i); |
|
85 |
IRegion lineRegion = document.getLineInformation(i); |
|
86 |
String lineText = document.get(lineRegion.getOffset(), lineRegion.getLength()); |
|
87 |
|
|
88 |
List<LineAnnotation> annotationsCurrentLine = |
|
89 |
((LineAnnotationModel) getAnnotationModel()).getUndeletedAnnotations(lineOffset, lineLength); |
|
90 |
|
|
91 |
if (annotationsCurrentLine.size() == 0) { |
|
92 |
logger.debug("Adding new annotation " + lineText); |
|
93 |
addAnnotation(lineText, lineRegion); |
|
94 |
} else { |
|
95 |
LineAnnotation currentAnnotation = annotationsCurrentLine.get(0); |
|
96 |
int length = lineLength; |
|
97 |
getAnnotationModel().getPosition(currentAnnotation).setLength(length); |
|
98 |
currentAnnotation.setText(lineText); |
|
99 |
|
|
100 |
for (int j = 1; j < annotationsCurrentLine.size(); j++) { |
|
101 |
annotationsCurrentLine.get(j).markAsMerged(currentAnnotation.getEntity()); |
|
102 |
getAnnotationModel().removeAnnotation(annotationsCurrentLine.get(j)); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
// Deletes have already taken place |
|
108 |
|
|
109 |
((LineAnnotationModel) getAnnotationModel()).printAnnotations(); |
|
110 |
} |
|
111 |
|
|
112 |
private void addAnnotation(String text, IRegion region) { |
|
113 |
Position position = new Position(region.getOffset(), region.getLength()); |
|
114 |
Annotation annotation = ((LineAnnotationModel) getAnnotationModel()).createAnnotation(text); |
|
115 |
getAnnotationModel().addAnnotation(annotation, position); |
|
116 |
|
|
117 |
// Position position2 = new Position(region.getOffset() + 1, region.getLength() - 2); |
|
118 |
// Annotation annotation2 = new Annotation("org.eclipse.ui.workbench.texteditor.error",true,"asdf"); |
|
119 |
// getAnnotationModel().addAnnotation(annotation2, position2); |
|
120 |
} |
|
121 |
|
|
122 |
private IAnnotationModel getAnnotationModel() { |
|
123 |
return viewer.getAnnotationModel(); |
|
124 |
} |
|
125 |
|
|
126 |
/* (non-Javadoc) |
|
127 |
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) |
|
128 |
*/ |
|
129 |
/** {@inheritDoc} */ |
|
130 |
public void setDocument(IDocument document) { |
|
131 |
this.document = document; |
|
132 |
} |
|
133 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorSourceViewerConfiguration.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
10 |
|
|
11 |
import java.util.Iterator; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.eclipse.jface.text.DefaultInformationControl; |
|
15 |
import org.eclipse.jface.text.DefaultTextHover; |
|
16 |
import org.eclipse.jface.text.IInformationControl; |
|
17 |
import org.eclipse.jface.text.IInformationControlCreator; |
|
18 |
import org.eclipse.jface.text.IRegion; |
|
19 |
import org.eclipse.jface.text.ITextHover; |
|
20 |
import org.eclipse.jface.text.ITextHoverExtension; |
|
21 |
import org.eclipse.jface.text.ITextViewer; |
|
22 |
import org.eclipse.jface.text.Position; |
|
23 |
import org.eclipse.jface.text.reconciler.IReconciler; |
|
24 |
import org.eclipse.jface.text.reconciler.IReconcilingStrategy; |
|
25 |
import org.eclipse.jface.text.reconciler.MonoReconciler; |
|
26 |
import org.eclipse.jface.text.source.Annotation; |
|
27 |
import org.eclipse.jface.text.source.IAnnotationModel; |
|
28 |
import org.eclipse.jface.text.source.ISourceViewer; |
|
29 |
import org.eclipse.jface.text.source.SourceViewerConfiguration; |
|
30 |
import org.eclipse.swt.widgets.Shell; |
|
31 |
import org.eclipse.ui.editors.text.EditorsUI; |
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* <p>AnnotatedLineEditorSourceViewerConfiguration class.</p> |
|
36 |
* |
|
37 |
* @author p.ciardelli |
|
38 |
* @created 25.06.2009 |
|
39 |
* @version 1.0 |
|
40 |
*/ |
|
41 |
public class AnnotatedLineEditorSourceViewerConfiguration extends |
|
42 |
SourceViewerConfiguration { |
|
43 |
@SuppressWarnings("unused") |
|
44 |
private static final Logger logger = Logger.getLogger(AnnotatedLineEditorSourceViewerConfiguration.class); |
|
45 |
|
|
46 |
/* (non-Javadoc) |
|
47 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer) |
|
48 |
*/ |
|
49 |
/** {@inheritDoc} */ |
|
50 |
public IReconciler getReconciler(ISourceViewer sourceViewer) { |
|
51 |
|
|
52 |
IReconcilingStrategy strategy = new AnnotatedLineEditorReconcilingStrategy(sourceViewer); |
|
53 |
IReconciler reconciler = new MonoReconciler(strategy, true); |
|
54 |
|
|
55 |
return reconciler; |
|
56 |
} |
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String, int) |
|
60 |
*/ |
|
61 |
/** {@inheritDoc} */ |
|
62 |
@Override |
|
63 |
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { |
|
64 |
/** |
|
65 |
* http://dev.eclipse.org/newslists/news.eclipse.platform/msg76821.html |
|
66 |
* |
|
67 |
* The Javadoc hover is shown in a Browser widget |
|
68 |
*/ |
|
69 |
return new TextHover(sourceViewer); |
|
70 |
} |
|
71 |
|
|
72 |
private final class TextHover extends DefaultTextHover implements ITextHoverExtension { |
|
73 |
|
|
74 |
private ISourceViewer sourceViewer; |
|
75 |
|
|
76 |
public TextHover(ISourceViewer sourceViewer) { |
|
77 |
super(sourceViewer); |
|
78 |
|
|
79 |
this.sourceViewer = sourceViewer; |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see org.eclipse.jface.text.DefaultTextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { |
|
87 |
|
|
88 |
IAnnotationModel model= sourceViewer.getAnnotationModel(); |
|
89 |
Iterator e= model.getAnnotationIterator(); |
|
90 |
while (e.hasNext()) { |
|
91 |
Annotation annotation= (Annotation) e.next(); |
|
92 |
if (isIncluded(annotation)) { |
|
93 |
Position p= model.getPosition(annotation); |
|
94 |
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) { |
|
95 |
return ((LineAnnotation) annotation).getHoverText(); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
return null; |
|
100 |
} |
|
101 |
|
|
102 |
/* (non-Javadoc) |
|
103 |
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator() |
|
104 |
*/ |
|
105 |
public IInformationControlCreator getHoverControlCreator() { |
|
106 |
return new IInformationControlCreator() { |
|
107 |
public IInformationControl createInformationControl(Shell parent) { |
|
108 |
return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString()); |
|
109 |
} |
|
110 |
}; |
|
111 |
} |
|
112 |
} |
|
113 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineDisplayStrategy.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
11 |
|
|
12 |
import org.eclipse.swt.graphics.Font; |
|
13 |
import org.eclipse.swt.graphics.Image; |
|
14 |
|
|
15 |
/** |
|
16 |
* Methods for translating between the object in a line and |
|
17 |
* its display in the editor. |
|
18 |
* |
|
19 |
* @author p.ciardelli |
|
20 |
* @created 07.07.2009 |
|
21 |
* @version 1.0 |
|
22 |
*/ |
|
23 |
public interface ILineDisplayStrategy { |
|
24 |
|
|
25 |
/** Constant <code>SUPPLEMENTAL_TEXT="supplemental_text"</code> */ |
|
26 |
public static final String SUPPLEMENTAL_TEXT = "supplemental_text"; |
|
27 |
|
|
28 |
/** |
|
29 |
* <p>getIndent</p> |
|
30 |
* |
|
31 |
* @param entity a {@link java.lang.Object} object. |
|
32 |
* @return a int. |
|
33 |
*/ |
|
34 |
int getIndent(Object entity); |
|
35 |
|
|
36 |
/** |
|
37 |
* <p>getIcon</p> |
|
38 |
* |
|
39 |
* @param entity a {@link java.lang.Object} object. |
|
40 |
* @return a {@link org.eclipse.swt.graphics.Image} object. |
|
41 |
*/ |
|
42 |
Image getIcon(Object entity); |
|
43 |
|
|
44 |
/** |
|
45 |
* <p>getFont</p> |
|
46 |
* |
|
47 |
* @param entity a {@link java.lang.Object} object. |
|
48 |
* @return a {@link org.eclipse.swt.graphics.Font} object. |
|
49 |
*/ |
|
50 |
Font getFont(Object entity); |
|
51 |
|
|
52 |
/** |
|
53 |
* For object's title cache output, mainly |
|
54 |
* |
|
55 |
* Note: if object's cache is empty, return "", not null |
|
56 |
* |
|
57 |
* @param entity a {@link java.lang.Object} object. |
|
58 |
* @return a {@link java.lang.String} object. |
|
59 |
*/ |
|
60 |
String getText(Object entity); |
|
61 |
|
|
62 |
/** |
|
63 |
* For object's supplemental information such as type, markers, etc., |
|
64 |
* usually stored in " [...]". |
|
65 |
* |
|
66 |
* @param entity a {@link java.lang.Object} object. |
|
67 |
* @return a {@link java.lang.String} object. |
|
68 |
*/ |
|
69 |
String getSupplementalText(Object entity); |
|
70 |
|
|
71 |
/** |
|
72 |
* <p>getEmptyCacheMessage</p> |
|
73 |
* |
|
74 |
* @param entity a {@link java.lang.Object} object. |
|
75 |
* @return a {@link java.lang.String} object. |
|
76 |
*/ |
|
77 |
String getEmptyCacheMessage(Object entity); |
|
78 |
|
|
79 |
/** |
|
80 |
* <p>setText</p> |
|
81 |
* |
|
82 |
* @param text a {@link java.lang.String} object. |
|
83 |
* @param entity a {@link java.lang.Object} object. |
|
84 |
*/ |
|
85 |
void setText(String text, Object entity); |
|
86 |
|
|
87 |
/** |
|
88 |
* <p>getHoverText</p> |
|
89 |
* |
|
90 |
* @param entity a {@link java.lang.Object} object. |
|
91 |
* @return a {@link java.lang.String} object. |
|
92 |
*/ |
|
93 |
String getHoverText(Object entity); |
|
94 |
|
|
95 |
/** |
|
96 |
* <p>setStatusMessage</p> |
|
97 |
* |
|
98 |
* @param text a {@link java.lang.String} object. |
|
99 |
* @param entity a {@link java.lang.Object} object. |
|
100 |
*/ |
|
101 |
void setStatusMessage(String text, Object entity); |
|
102 |
|
|
103 |
/** |
|
104 |
* <p>isEntityCacheEmpty</p> |
|
105 |
* |
|
106 |
* @param entity a {@link java.lang.Object} object. |
|
107 |
* @return a boolean. |
|
108 |
*/ |
|
109 |
boolean isEntityCacheEmpty(Object entity); |
|
110 |
|
|
111 |
/** |
|
112 |
* <p>addDisplayListener</p> |
|
113 |
* |
|
114 |
* @param entity a {@link java.lang.Object} object. |
|
115 |
* @param listener a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.EntityListener} object. |
|
116 |
*/ |
|
117 |
void addDisplayListener(Object entity, EntityListener listener); |
|
118 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineSelectionSource.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* Every line in a <code>LineSelectionViewer</code> has an object associated with it. Classes |
|
15 |
* implementing this interface retrieve a line's object. |
|
16 |
* |
|
17 |
* @author p.ciardelli |
|
18 |
* @created 03.07.2009 |
|
19 |
* @version 1.0 |
|
20 |
*/ |
|
21 |
public interface ILineSelectionSource { |
|
22 |
|
|
23 |
/** |
|
24 |
* <p>getSelectedObjectAtLine</p> |
|
25 |
* |
|
26 |
* @param line a int. |
|
27 |
* @return a {@link java.lang.Object} object. |
|
28 |
*/ |
|
29 |
Object getSelectedObjectAtLine(int line); |
|
30 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/LineAnnotation.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.annotatedlineeditor; |
|
10 |
|
|
11 |
import java.util.Set; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.eclipse.jface.text.source.Annotation; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; |
|
17 |
|
|
18 |
/** |
|
19 |
* An <code>Annotation</code> which spans an entire line and holds an object associated |
|
20 |
* with the line in an <code>IEntityContainer</code>. |
|
21 |
* |
|
22 |
* @author p.ciardelli |
|
23 |
* @created 25.06.2009 |
|
24 |
* @version 1.0 |
|
25 |
*/ |
|
26 |
public class LineAnnotation<T> extends Annotation implements IEntityContainer<T> { |
|
27 |
@SuppressWarnings("unused") |
|
28 |
private static final Logger logger = Logger |
|
29 |
.getLogger(LineAnnotationModel.class); |
|
30 |
|
|
31 |
/** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */ |
|
32 |
public static final String TYPE_GENERIC = Annotation.TYPE_UNKNOWN; |
|
33 |
|
|
34 |
private T entity; |
|
35 |
private ILineDisplayStrategy lineDisplayStrategy; |
|
36 |
|
|
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; |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* <p>Constructor for LineAnnotation.</p> |
|
47 |
* |
|
48 |
* @param entity a T object. |
|
49 |
* @param lineDisplayStrategy a {@link eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy} object. |
|
50 |
* @param <T> a T object. |
|
51 |
*/ |
|
52 |
public LineAnnotation(T entity, ILineDisplayStrategy lineDisplayStrategy) { |
|
53 |
this.entity = entity; |
|
54 |
this.lineDisplayStrategy = lineDisplayStrategy; |
|
55 |
setType(TYPE_GENERIC); |
|
56 |
} |
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see org.eclipse.jface.text.source.Annotation#getText() |
|
60 |
*/ |
|
61 |
/** {@inheritDoc} */ |
|
62 |
@Override |
|
63 |
public String getText() { |
|
64 |
return getEditableText(); |
|
65 |
} |
|
66 |
|
|
67 |
/* (non-Javadoc) |
|
68 |
* @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String) |
|
69 |
*/ |
|
70 |
/** {@inheritDoc} */ |
|
71 |
@Override |
|
72 |
public void setText(String text) { |
|
73 |
lineDisplayStrategy.setText(text, entity); |
|
74 |
dirty = true; |
|
75 |
super.setText(text); |
|
76 |
} |
|
77 |
|
|
78 |
/** {@inheritDoc} */ |
|
79 |
@Override |
|
80 |
public String toString() { |
|
81 |
// For debugging |
|
82 |
return getText(); |
|
83 |
} |
|
84 |
|
|
85 |
/* (non-Javadoc) |
|
86 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities() |
|
87 |
*/ |
|
88 |
/** |
|
89 |
* <p>getAttachedEntities</p> |
|
90 |
* |
|
91 |
* @return a {@link java.util.Set} object. |
|
92 |
*/ |
|
93 |
@Override |
|
94 |
public Set getAttachedEntities() { |
|
95 |
// TODO Auto-generated method stub |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
/* (non-Javadoc) |
|
100 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEntity() |
|
101 |
*/ |
|
102 |
/** |
|
103 |
* <p>Getter for the field <code>entity</code>.</p> |
|
104 |
* |
|
105 |
* @return a T object. |
|
106 |
*/ |
|
107 |
@Override |
|
108 |
public T getEntity() { |
|
109 |
return entity; |
|
110 |
} |
|
111 |
|
|
112 |
/* (non-Javadoc) |
|
113 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getEditableText() |
|
114 |
*/ |
|
115 |
/** |
|
116 |
* <p>getEditableText</p> |
|
117 |
* |
|
118 |
* @return a {@link java.lang.String} object. |
|
119 |
*/ |
|
120 |
@Override |
|
121 |
public String getEditableText() { |
|
122 |
return lineDisplayStrategy.getText(entity); |
|
123 |
} |
|
124 |
|
|
125 |
/* (non-Javadoc) |
|
126 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getMergeTarget() |
|
127 |
*/ |
|
128 |
/** |
|
129 |
* <p>Getter for the field <code>mergeTarget</code>.</p> |
|
130 |
* |
|
131 |
* @return a T object. |
|
132 |
*/ |
Also available in: Unified diff
ref #6913 Remove bulk editor