taxeditor-bulkeditor/icons/merge_target.gif -text
taxeditor-bulkeditor/plugin.xml -text
taxeditor-bulkeditor/pom.xml -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/AnnotatedLineEditor.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/AnnotatedLineEditorDocumentProvider.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/AnnotatedLineEditorReconcilingStrategy.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/AnnotatedLineEditorSourceViewerConfiguration.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorInput.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLineDisplay.java -text
--- /dev/null
+// $Id$\r
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+import org.eclipse.jface.text.source.IVerticalRuler;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorSite;\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.editors.text.TextEditor;\r
+\r
+/**\r
+ * A list-based editor, where each line in the editor's document is associated with a domain object.\r
+ * <p>\r
+ * Extending classes must set:\r
+ * <ul>\r
+ * <li>an <code>IEntityCreator</code> to create a new domain object when the user creates a new line;\r
+ * <li>an <code>IEntityPersistenceService</code> for interacting with the persistence layer; and\r
+ * <li>an <code>ILineDisplayStrategy</code> for various visual manifestations of the domain object. \r
+ * </ul>\r
+ * \r
+ * @author p.ciardelli\r
+ * @created 25.06.2009\r
+ * @version 1.0\r
+ */\r
+public class AnnotatedLineEditor extends TextEditor {\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger\r
+ .getLogger(AnnotatedLineEditor.class);\r
+ \r
+ private IEntityCreator<?> entityCreator;\r
+ private IEntityPersistenceService persistenceService;\r
+ private ILineDisplayStrategy lineDisplayStrategy;\r
+ \r
+ @Override\r
+ public void init(IEditorSite site, IEditorInput input)\r
+ throws PartInitException {\r
+ \r
+ AnnotatedLineEditorDocumentProvider provider = new AnnotatedLineEditorDocumentProvider();\r
+ provider.setEntityCreator(entityCreator, input);\r
+ provider.setPersistenceService(persistenceService, input);\r
+ provider.setLineDisplayStrategy(lineDisplayStrategy, input);\r
+ setDocumentProvider(provider);\r
+ \r
+ super.init(site, input);\r
+ }\r
+ \r
+ /**\r
+ * @param referenceCreator\r
+ */\r
+ protected void setEntityCreator(IEntityCreator<?> entityCreator) {\r
+ this.entityCreator = entityCreator;\r
+ }\r
+ \r
+ /**\r
+ * @param bulkEditorPersistenceService\r
+ */\r
+ protected void setPersistenceService(\r
+ IEntityPersistenceService persistenceService) {\r
+ this.persistenceService = persistenceService; \r
+ }\r
+\r
+ /**\r
+ * @param bulkEditorLineDisplay\r
+ */\r
+ protected void setLineDisplayStrategy(\r
+ ILineDisplayStrategy lineDisplayStrategy) {\r
+ this.lineDisplayStrategy = lineDisplayStrategy; \r
+ }\r
+ \r
+ @Override\r
+ protected ISourceViewer createSourceViewer(Composite parent,\r
+ IVerticalRuler ruler, int styles) {\r
+ \r
+ fAnnotationAccess= getAnnotationAccess();\r
+ fOverviewRuler= createOverviewRuler(getSharedColors()); \r
+ LineSelectionViewer viewer = new LineSelectionViewer(parent, ruler, getOverviewRuler(), \r
+ isOverviewRulerVisible(), styles | SWT.WRAP);\r
+ getSourceViewerDecorationSupport(viewer);\r
+ \r
+// viewer.getTextWidget().setI\r
+ \r
+ return viewer;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+// $Id$\r
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.core.runtime.Assert;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.jface.operation.IRunnableContext;\r
+import org.eclipse.jface.text.Document;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.Position;\r
+import org.eclipse.jface.text.source.Annotation;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.texteditor.AbstractDocumentProvider;\r
+\r
+/**\r
+ * Using an <code>IEditorPart</code>, creates a document where each line is associated\r
+ * with an entity. Mapping between document positions and entities is stored in\r
+ * <code>LineAnnotation</code>s in a <code>LineAnnotationModdel</code>. \r
+ * <p>\r
+ * Requires:\r
+ * <ul>\r
+ * <li>an <code>IEntityCreator</code> to create entities for new lines;\r
+ * <li>an <code>IEntityPersistenceService</code> for interacting with the persistence layer; and\r
+ * <li>an <code>ILineDisplayStrategy</code> for various visual manifestations of the domain object. \r
+ * </ul> \r
+ * \r
+ * @author p.ciardelli\r
+ * @created 25.06.2009\r
+ * @version 1.0\r
+ */\r
+public class AnnotatedLineEditorDocumentProvider extends AbstractDocumentProvider {\r
+\r
+ private static final Logger logger = Logger\r
+ .getLogger(AnnotatedLineEditorDocumentProvider.class);\r
+ \r
+ private Map<IEditorInput, IDocument> documents = \r
+ new HashMap<IEditorInput, IDocument>();\r
+\r
+ private Map<IEditorInput, IAnnotationModel> annotationModels = \r
+ new HashMap<IEditorInput, IAnnotationModel>();\r
+\r
+ private Map<IEditorInput, IEntityCreator<?>> entityCreators = \r
+ new HashMap<IEditorInput, IEntityCreator<?>>();\r
+\r
+ private Map<IEditorInput, IEntityPersistenceService> persistenceServices = \r
+ new HashMap<IEditorInput, IEntityPersistenceService>();\r
+\r
+ private Map<IEditorInput, ILineDisplayStrategy> lineDisplayStrategies = \r
+ new HashMap<IEditorInput, ILineDisplayStrategy>();\r
+ \r
+ \r
+ @Override\r
+ public IAnnotationModel getAnnotationModel(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ \r
+ IEditorInput input = (IEditorInput) element;\r
+ IAnnotationModel model = annotationModels.get((IEditorInput) element);\r
+ \r
+ // Create model as necessary\r
+ if (model == null) {\r
+ model = new LineAnnotationModel(getLineDisplayStrategy(element));\r
+ ((LineAnnotationModel) model).setEntityCreator(getEntityCreator(element));\r
+ annotationModels.put(input, model);\r
+ } \r
+ return model;\r
+ }\r
+ \r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ protected IAnnotationModel createAnnotationModel(Object element)\r
+ throws CoreException {\r
+ return getAnnotationModel(element);\r
+ }\r
+\r
+ @Override\r
+ public IDocument getDocument(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ return documents.get((IEditorInput) element);\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ protected IDocument createDocument(Object element) throws CoreException {\r
+ \r
+ if (element instanceof IEditorInput) {\r
+ IEditorInput input = (IEditorInput) element;\r
+ Document document = new Document("");\r
+ IAnnotationModel model = getAnnotationModel(element);\r
+ \r
+ String text = "";\r
+ String line;\r
+ for (Object entity : getEntityList(element)) {\r
+ \r
+ Annotation annotation = new LineAnnotation(entity, getLineDisplayStrategy(element));\r
+ \r
+ line = annotation.getText() + document.getDefaultLineDelimiter();\r
+ Position position = new Position(text.length(), line.length());\r
+ model.addAnnotation(annotation, position);\r
+ logger.info("Adding annotation " + entity);\r
+ document.set(document.get() + line);\r
+ \r
+ \r
+ \r
+ text += line;\r
+ }\r
+ documents.put(input, document);\r
+ if (model instanceof LineAnnotationModel) {\r
+ ((LineAnnotationModel) model).printAnnotations();\r
+ }\r
+ return document;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * @param element \r
+ * @return\r
+ */\r
+ private List<?> getEntityList(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ return getPersistenceService(element).getEntityList(element);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected void doSaveDocument(IProgressMonitor monitor, Object element,\r
+ IDocument document, boolean overwrite) throws CoreException {\r
+ if (element instanceof IEditorInput) {\r
+ \r
+ IEntityPersistenceService persistenceService = getPersistenceService(element);\r
+ \r
+ // Get new containers from annotation model\r
+ LineAnnotationModel model = (LineAnnotationModel) getAnnotationModel(element);\r
+ Iterator iterator = model.getAnnotationIterator();\r
+ while (iterator.hasNext()) {\r
+ Annotation annotation = (Annotation) iterator.next();\r
+ if (annotation instanceof IEntityContainer<?>) {\r
+ IEntityContainer<?> container = (IEntityContainer<?>) annotation;\r
+ if (container.isMarkedAsNew() || container.isDirty()) {\r
+ persistenceService.save(container.getEntity(), element);\r
+ container.setDirty(false);\r
+ container.markAsNew(false);\r
+ }\r
+ }\r
+ }\r
+ for (LineAnnotation annotation : model.getDeletedAnnotations()) {\r
+ if (annotation.isMarkedAsNew()) {\r
+ continue;\r
+ }\r
+ if (annotation.isMarkedAsMerged()) {\r
+ persistenceService.merge(annotation.getEntity(), annotation.getMergeTarget(), element); \r
+ }\r
+ persistenceService.delete(annotation.getEntity(), element);\r
+ }\r
+ model.clearDeletedAnnotations();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public boolean isModifiable(Object element) {\r
+ return true;\r
+ }\r
+ \r
+ @Override\r
+ public boolean isReadOnly(Object element) {\r
+ // enables copy & paste\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * @param entityCreator\r
+ * @param element\r
+ */\r
+ public void setEntityCreator(IEntityCreator<?> entityCreator, Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ entityCreators.put((IEditorInput) element, entityCreator);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * @param element\r
+ * @return\r
+ */\r
+ public IEntityCreator<?> getEntityCreator(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ IEntityCreator<?> entityCreator = entityCreators.get(element);\r
+ Assert.isNotNull(entityCreator, "No IEntityCreator set for this element.");\r
+ return entityCreator;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * @param persistenceService\r
+ * @param input\r
+ */\r
+ public void setPersistenceService(\r
+ IEntityPersistenceService persistenceService, Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ persistenceServices.put((IEditorInput) element, persistenceService);\r
+ }\r
+ }\r
+ \r
+ public IEntityPersistenceService getPersistenceService(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ IEntityPersistenceService persistenceService = persistenceServices.get((IEditorInput) element);\r
+ Assert.isNotNull(persistenceService, "No IEntityPersistenceService set for this element.");\r
+ return persistenceService;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * @param lineDisplayStrategy\r
+ * @param input\r
+ */\r
+ public void setLineDisplayStrategy(\r
+ ILineDisplayStrategy lineDisplayStrategy, Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ lineDisplayStrategies.put((IEditorInput) element, lineDisplayStrategy);\r
+ } \r
+ }\r
+ \r
+ /**\r
+ * @param element\r
+ * @return\r
+ */\r
+ private ILineDisplayStrategy getLineDisplayStrategy(Object element) {\r
+ if (element instanceof IEditorInput) {\r
+ ILineDisplayStrategy lineDisplayStrategy = lineDisplayStrategies.get((IEditorInput) element);\r
+ Assert.isNotNull(lineDisplayStrategy, "No ILineDisplayStrategy set for this element.");\r
+ return lineDisplayStrategy;\r
+ }\r
+ return null;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+// $Id$\r
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import java.util.List;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.IRegion;\r
+import org.eclipse.jface.text.Position;\r
+import org.eclipse.jface.text.reconciler.DirtyRegion;\r
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;\r
+import org.eclipse.jface.text.source.Annotation;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 25.06.2009\r
+ * @version 1.0\r
+ */\r
+public class AnnotatedLineEditorReconcilingStrategy implements IReconcilingStrategy {\r
+ private static final Logger logger = Logger\r
+ .getLogger(AnnotatedLineEditorReconcilingStrategy.class);\r
+\r
+ private IDocument document;\r
+ private ISourceViewer viewer;\r
+\r
+ public AnnotatedLineEditorReconcilingStrategy(ISourceViewer sourceViewer) {\r
+ this.viewer = sourceViewer;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)\r
+ */\r
+ public void reconcile(IRegion partition) {\r
+ // not used\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)\r
+ */\r
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {\r
+ try {\r
+ doReconcile(dirtyRegion);\r
+ } catch (BadLocationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ synchronized private void doReconcile(DirtyRegion dirtyRegion) throws BadLocationException {\r
+ // Get all affected lines\r
+ int dirtyOffset = dirtyRegion.getOffset();\r
+ int dirtyLength = dirtyRegion.getLength();\r
+ \r
+ int lineChangeStart = document.getLineOfOffset(dirtyOffset);\r
+ int lineChangeEnd;\r
+ if (DirtyRegion.INSERT.equals(dirtyRegion.getType())) {\r
+ lineChangeEnd = document.getLineOfOffset(dirtyOffset + dirtyLength);\r
+ } else {\r
+ lineChangeEnd = lineChangeStart;\r
+ }\r
+ \r
+ for (int i = lineChangeStart; i <= lineChangeEnd; i++) {\r
+ int lineOffset = document.getLineOffset(i);\r
+ int lineLength = document.getLineLength(i);\r
+ IRegion lineRegion = document.getLineInformation(i);\r
+ String lineText = document.get(lineRegion.getOffset(), lineRegion.getLength());\r
+ \r
+ List<LineAnnotation> annotationsCurrentLine = \r
+ ((LineAnnotationModel) getAnnotationModel()).getUndeletedAnnotations(lineOffset, lineLength);\r
+ \r
+ if (annotationsCurrentLine.size() == 0) {\r
+ logger.debug("Adding new annotation " + lineText);\r
+ addAnnotation(lineText, lineRegion);\r
+ } else {\r
+ LineAnnotation currentAnnotation = annotationsCurrentLine.get(0);\r
+ int length = lineLength;\r
+ getAnnotationModel().getPosition(currentAnnotation).setLength(length);\r
+ currentAnnotation.setText(lineText);\r
+ \r
+ for (int j = 1; j < annotationsCurrentLine.size(); j++) {\r
+ annotationsCurrentLine.get(j).markAsMerged(currentAnnotation.getEntity());\r
+ getAnnotationModel().removeAnnotation(annotationsCurrentLine.get(j));\r
+ }\r
+ }\r
+ }\r
+ \r
+ // Deletes have already taken place\r
+ \r
+ ((LineAnnotationModel) getAnnotationModel()).printAnnotations();\r
+ }\r
+ \r
+ private void addAnnotation(String text, IRegion region) {\r
+ Position position = new Position(region.getOffset(), region.getLength());\r
+ Annotation annotation = ((LineAnnotationModel) getAnnotationModel()).createAnnotation(text);\r
+ getAnnotationModel().addAnnotation(annotation, position);\r
+ \r
+// Position position2 = new Position(region.getOffset() + 1, region.getLength() - 2);\r
+// Annotation annotation2 = new Annotation("org.eclipse.ui.workbench.texteditor.error",true,"asdf");\r
+// getAnnotationModel().addAnnotation(annotation2, position2);\r
+ }\r
+\r
+ private IAnnotationModel getAnnotationModel() {\r
+ return viewer.getAnnotationModel();\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)\r
+ */\r
+ public void setDocument(IDocument document) {\r
+ this.document = document; \r
+ }\r
+}\r
--- /dev/null
+// $Id$\r
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import java.util.Iterator;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.text.DefaultInformationControl;\r
+import org.eclipse.jface.text.DefaultTextHover;\r
+import org.eclipse.jface.text.IInformationControl;\r
+import org.eclipse.jface.text.IInformationControlCreator;\r
+import org.eclipse.jface.text.IRegion;\r
+import org.eclipse.jface.text.ITextHover;\r
+import org.eclipse.jface.text.ITextHoverExtension;\r
+import org.eclipse.jface.text.ITextViewer;\r
+import org.eclipse.jface.text.Position;\r
+import org.eclipse.jface.text.reconciler.IReconciler;\r
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;\r
+import org.eclipse.jface.text.reconciler.MonoReconciler;\r
+import org.eclipse.jface.text.source.Annotation;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+import org.eclipse.jface.text.source.SourceViewerConfiguration;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.editors.text.EditorsUI;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 25.06.2009\r
+ * @version 1.0\r
+ */\r
+public class AnnotatedLineEditorSourceViewerConfiguration extends\r
+ SourceViewerConfiguration {\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger.getLogger(AnnotatedLineEditorSourceViewerConfiguration.class);\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)\r
+ */\r
+ public IReconciler getReconciler(ISourceViewer sourceViewer) {\r
+ \r
+ IReconcilingStrategy strategy = new AnnotatedLineEditorReconcilingStrategy(sourceViewer);\r
+ IReconciler reconciler = new MonoReconciler(strategy, true);\r
+\r
+ return reconciler;\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String, int)\r
+ */\r
+ @Override\r
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {\r
+ /**\r
+ * http://dev.eclipse.org/newslists/news.eclipse.platform/msg76821.html\r
+ * \r
+ * The Javadoc hover is shown in a Browser widget\r
+ */\r
+ return new TextHover(sourceViewer);\r
+ }\r
+ \r
+ private final class TextHover extends DefaultTextHover implements ITextHoverExtension {\r
+\r
+ private ISourceViewer sourceViewer;\r
+\r
+ public TextHover(ISourceViewer sourceViewer) {\r
+ super(sourceViewer);\r
+ \r
+ this.sourceViewer = sourceViewer;\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.DefaultTextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)\r
+ */\r
+ @Override\r
+ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {\r
+ \r
+ IAnnotationModel model= sourceViewer.getAnnotationModel();\r
+ Iterator e= model.getAnnotationIterator();\r
+ while (e.hasNext()) {\r
+ Annotation annotation= (Annotation) e.next();\r
+ if (isIncluded(annotation)) {\r
+ Position p= model.getPosition(annotation);\r
+ if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {\r
+ return ((LineAnnotation) annotation).getHoverText();\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()\r
+ */\r
+ public IInformationControlCreator getHoverControlCreator() {\r
+ return new IInformationControlCreator() {\r
+ public IInformationControl createInformationControl(Shell parent) {\r
+ return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());\r
+ }\r
+ };\r
+ }\r
+ }\r
+}
\ No newline at end of file
* @created 07.07.2009\r
* @version 1.0\r
*/\r
-public class BulkEditor extends ListEditor {\r
+public class BulkEditor extends AnnotatedLineEditor {\r
private static final Logger logger = Logger.getLogger(BulkEditor.class);\r
\r
public static final String ID = "bulkeditor.editor";\r
protected ISourceViewer createSourceViewer(Composite parent,\r
IVerticalRuler ruler, int styles) {\r
ISourceViewer viewer = super.createSourceViewer(parent, ruler, styles);\r
- setSourceViewerConfiguration(new ListEditorSourceViewerConfiguration());\r
+ setSourceViewerConfiguration(new AnnotatedLineEditorSourceViewerConfiguration());\r
addToggleMergeCandidateListener(ruler.getControl());\r
\r
return viewer;\r
import org.eclipse.ui.handlers.HandlerUtil;\r
import org.eclipse.ui.texteditor.IDocumentProvider;\r
\r
-import eu.etaxonomy.taxeditor.bulkeditor.ListEditor;\r
+import eu.etaxonomy.taxeditor.bulkeditor.AnnotatedLineEditor;\r
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorInput;\r
import eu.etaxonomy.taxeditor.bulkeditor.LineAnnotationModel;\r
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;\r
IEditorPart editor = HandlerUtil.getActiveEditor(event);\r
IEditorInput input = editor.getEditorInput();\r
\r
- if (editor instanceof ListEditor && input instanceof BulkEditorInput) {\r
+ if (editor instanceof AnnotatedLineEditor && input instanceof BulkEditorInput) {\r
\r
- IDocumentProvider provider = ((ListEditor) editor).getDocumentProvider();\r
+ IDocumentProvider provider = ((AnnotatedLineEditor) editor).getDocumentProvider();\r
LineAnnotationModel model = \r
(LineAnnotationModel) provider.getAnnotationModel(input);\r
IDocument document = provider.getDocument(input);\r