taxeditor-bulkeditor/plugin.xml -text
taxeditor-bulkeditor/pom.xml -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java -text
-taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorAnnotation.java -text
-taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorAnnotationModel.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorDocumentProvider.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorInput.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorInputFactory.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorReconcilingStrategy.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorSourceViewerConfiguration.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/CdmEntityAnnotation.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/CdmEntityAnnotationModel.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/IBulkEditorConstants.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/IEntityContainer.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/IEntityContainerCreator.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/ILineSelectionSource.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/LineSelection.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/LineSelectionSource.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/LineSelectionViewer.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/ReferenceContainer.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/ReferenceEditorInput.java -text
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/MergeGroupHandler.java -text
Bundle-ClassPath: .
Bundle-Activator: eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.eclipse.jface.text;bundle-version="3.4.2",org.eclipse.ui.editors,org.eclipse.ui.ide,org.eclipse.core.resources;bundle-version="3.4.2",eu.etaxonomy.cdmLibrary;bundle-version="2.1.0"
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text;bundle-version="3.4.2",
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide,
+ org.eclipse.core.resources;bundle-version="3.4.2",
+ eu.etaxonomy.cdmLibrary;bundle-version="2.1.0",
+ eu.etaxonomy.taxeditor.editor;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: eu.etaxonomy.taxeditor.bulkeditor,
</extension>\r
<extension\r
point="org.eclipse.ui.menus">\r
- <!--menuContribution\r
+ <menuContribution\r
locationURI="menu:org.eclipse.ui.main.menu">\r
<menu\r
id="bulkeditor.menus.openmenu"\r
value="referenceInputType">\r
</parameter>\r
</command>\r
- </menuContribution-->\r
+ </menuContribution >\r
<menuContribution\r
locationURI="popup:#BulkEditorContext">\r
<!--menuContribution\r
@Override\r
protected ISourceViewer createSourceViewer(Composite parent,\r
IVerticalRuler ruler, int styles) {\r
- viewer = super.createSourceViewer(parent, ruler, styles | SWT.WRAP);\r
+ fAnnotationAccess= getAnnotationAccess();\r
+ fOverviewRuler= createOverviewRuler(getSharedColors()); \r
+ viewer= new LineSelectionViewer(parent, ruler, getOverviewRuler(), \r
+ isOverviewRulerVisible(), styles | SWT.WRAP);\r
+ \r
+ ((LineSelectionViewer) viewer).setLineSelectionSource(new LineSelectionSource(viewer));\r
+ \r
+ getSourceViewerDecorationSupport(viewer);\r
setSourceViewerConfiguration(new BulkEditorSourceViewerConfiguration());\r
\r
addToggleMergeCandidateListener(ruler.getControl());\r
\r
private void toggleMergeCandidateAnnotation(int line) {\r
IDocument document = viewer.getDocument();\r
- BulkEditorAnnotationModel model = \r
- (BulkEditorAnnotationModel) viewer.getAnnotationModel();\r
+ CdmEntityAnnotationModel model = \r
+ (CdmEntityAnnotationModel) viewer.getAnnotationModel();\r
\r
Annotation annotation = model.getAnnotationAtLine(line, document);\r
\r
if (annotation != null) {\r
- if (annotation.getType().equals(BulkEditorAnnotation.TYPE_MERGE_CANDIDATE)) {\r
+ if (annotation.getType().equals(IBulkEditorConstants.TYPE_MERGE_CANDIDATE)) {\r
model.changeAnnotationType(\r
- annotation, BulkEditorAnnotation.TYPE_GENERIC);\r
+ annotation, CdmEntityAnnotation.TYPE_GENERIC);\r
} else {\r
model.changeAnnotationType(\r
- annotation, BulkEditorAnnotation.TYPE_MERGE_CANDIDATE);\r
+ annotation, IBulkEditorConstants.TYPE_MERGE_CANDIDATE);\r
}\r
}\r
}\r
\r
// Create model as necessary\r
if (model == null) {\r
- model = new BulkEditorAnnotationModel();\r
+ model = new CdmEntityAnnotationModel();\r
+ ((CdmEntityAnnotationModel) model).setCdmEntityCreator(input);\r
models.put(input, model);\r
} \r
return model;\r
Document document = new Document("");\r
IAnnotationModel model = getAnnotationModel(element);\r
\r
- List<IEntityContainer> list = ((BulkEditorInput) element).getList();\r
+ List<IEntityContainer<?>> list = ((BulkEditorInput) element).getList();\r
String text = "";\r
String line;\r
- for (IEntityContainer container : list) {\r
+ for (IEntityContainer<?> container : list) {\r
if (!container.isMarkedAsDeleted() && !container.isMarkedAsMerged()) {\r
line = container.getEditableText() \r
+ document.getDefaultLineDelimiter();\r
\r
Position position = new Position(text.length(), line.length());\r
- Annotation annotation = new BulkEditorAnnotation(container);\r
+ Annotation annotation = new CdmEntityAnnotation(container);\r
model.addAnnotation(annotation, position);\r
document.set(document.get() + line);\r
\r
}\r
}\r
documents.put(input, document);\r
- if (model instanceof BulkEditorAnnotationModel) {\r
- ((BulkEditorAnnotationModel) model).printAnnotations();\r
+ if (model instanceof CdmEntityAnnotationModel) {\r
+ ((CdmEntityAnnotationModel) model).printAnnotations();\r
}\r
return document;\r
}\r
import org.eclipse.ui.IMemento;\r
import org.eclipse.ui.IPersistableElement;\r
\r
-import eu.etaxonomy.cdm.model.common.CdmBase;\r
-\r
/**\r
* @author p.ciardelli\r
* @created 25.06.2009\r
* @version 1.0\r
* @param <T>\r
*/\r
-public class BulkEditorInput<T extends CdmBase> implements IEditorInput, IPersistableElement {\r
+abstract public class BulkEditorInput implements IEditorInput, IEntityContainerCreator, IPersistableElement {\r
\r
/**\r
* See menu parameters for "taxeditor-bulkeditor.commandParameter.inputType" \r
\r
static public BulkEditorInput NewInstance(String inputType) {\r
if (REFERENCE_INPUT_TYPE.equals(inputType)) {\r
- return new ReferenceEditorInput(); \r
+ return (BulkEditorInput) new ReferenceEditorInput(); \r
}\r
- return new BulkEditorInput();\r
+ return null;\r
+// return new BulkEditorInput();\r
}\r
\r
/* (non-Javadoc)\r
/* (non-Javadoc)\r
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)\r
*/\r
+ @SuppressWarnings("unchecked")\r
public Object getAdapter(Class adapter) {\r
return null;\r
} \r
\r
- public List<IEntityContainer<T>> getList() {\r
+ public List<IEntityContainer<?>> getList() {\r
return null;\r
}\r
\r
* @version 1.0\r
*/\r
public class BulkEditorInputFactory implements IElementFactory {\r
+ @SuppressWarnings("unused")\r
private static final Logger logger = Logger\r
.getLogger(BulkEditorInputFactory.class);\r
\r
return BulkEditorInput.NewInstance(inputType);\r
}\r
\r
- public static void saveState(IMemento memento, BulkEditorInput<?> input) {\r
+ public static void saveState(IMemento memento, BulkEditorInput input) {\r
String inputType = input.getInputType();\r
if (inputType != null) {\r
memento.putString(INPUT_TYPE, inputType);\r
IRegion lineRegion = document.getLineInformation(i);\r
String lineText = document.get(lineRegion.getOffset(), lineRegion.getLength());\r
\r
- List<BulkEditorAnnotation> annotationsCurrentLine = ((BulkEditorAnnotationModel) getAnnotationModel()).\r
+ List<CdmEntityAnnotation> annotationsCurrentLine = ((CdmEntityAnnotationModel) getAnnotationModel()).\r
getAnnotations(lineOffset, lineLength);\r
\r
if (annotationsCurrentLine.size() == 0) {\r
logger.debug("Adding new annotation " + lineText);\r
addAnnotation(lineText, lineRegion);\r
} else {\r
- BulkEditorAnnotation currentAnnotation = annotationsCurrentLine.get(0);\r
+ CdmEntityAnnotation currentAnnotation = annotationsCurrentLine.get(0);\r
// int length = lineLength + document.getLineDelimiter(i).length();\r
int length = lineLength;\r
logger.debug("Position before: " + getAnnotationModel().getPosition(currentAnnotation));\r
\r
// Deletes have already taken place\r
\r
- ((BulkEditorAnnotationModel) getAnnotationModel()).printAnnotations();\r
+ ((CdmEntityAnnotationModel) getAnnotationModel()).printAnnotations();\r
}\r
\r
+ @SuppressWarnings("unused")\r
synchronized private void doReconcile_(DirtyRegion dirtyRegion) throws BadLocationException {\r
\r
int dirtyOffset = dirtyRegion.getOffset();\r
int currentLength = 0; \r
// Get all annotations on current line\r
for (Annotation annotation : \r
- ((BulkEditorAnnotationModel) getAnnotationModel()).getAnnotations(firstLineRegion.getOffset(), firstLineRegion.getLength())) {\r
+ ((CdmEntityAnnotationModel) getAnnotationModel()).getAnnotations(firstLineRegion.getOffset(), firstLineRegion.getLength())) {\r
if (currentAnnotation == null) {\r
// First annotation updated w text of entire line\r
currentAnnotation = annotation;\r
}\r
\r
logger.debug(dirtyRegion.getType());\r
- if (getAnnotationModel() instanceof BulkEditorAnnotationModel) {\r
- ((BulkEditorAnnotationModel) getAnnotationModel()).printAnnotations();\r
+ if (getAnnotationModel() instanceof CdmEntityAnnotationModel) {\r
+ ((CdmEntityAnnotationModel) getAnnotationModel()).printAnnotations();\r
}\r
-\r
}\r
\r
private void addAnnotation(String text, IRegion region) {\r
Position position = new Position(region.getOffset(), region.getLength());\r
- ReferenceContainer container = new ReferenceContainer(Generic.NewInstance());\r
- container.setText(text);\r
- Annotation annotation = new BulkEditorAnnotation(container);\r
+ Annotation annotation = ((CdmEntityAnnotationModel) getAnnotationModel()).createAnnotation(text);\r
getAnnotationModel().addAnnotation(annotation, position);\r
}\r
\r
package eu.etaxonomy.taxeditor.bulkeditor;\r
\r
import org.apache.log4j.Logger;\r
-\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.reconciler.MonoReconciler;\r
import org.eclipse.jface.text.source.ISourceViewer;\r
import org.eclipse.jface.text.source.SourceViewerConfiguration;\r
-import org.eclipse.swt.browser.Browser;\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.ui.editors.text.EditorsUI;\r
\r
*/\r
public class BulkEditorSourceViewerConfiguration extends\r
SourceViewerConfiguration {\r
+ @SuppressWarnings("unused")\r
private static final Logger logger = Logger.getLogger(BulkEditorSourceViewerConfiguration.class);\r
\r
/* (non-Javadoc)\r
* @created 25.06.2009\r
* @version 1.0\r
*/\r
-public class BulkEditorAnnotation extends Annotation {\r
+public class CdmEntityAnnotation extends Annotation {\r
\r
public static final String TYPE_GENERIC = Annotation.TYPE_UNKNOWN;\r
- public static final String TYPE_MERGE_TARGET = "merge_target_annotation";\r
- public static final String TYPE_MERGE_CANDIDATE = "merge_candidate_annotation";\r
\r
- private IEntityContainer container;\r
+ private IEntityContainer<?> container;\r
\r
- public BulkEditorAnnotation(IEntityContainer container) {\r
+ public CdmEntityAnnotation(IEntityContainer<?> container) {\r
Assert.isNotNull(container);\r
this.container = container;\r
setType(TYPE_GENERIC);\r
}\r
\r
- public IEntityContainer getContainer() {\r
+ public IEntityContainer<?> getEntityContainer() {\r
return container;\r
}\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.Position;\r
import org.eclipse.jface.text.source.Annotation;\r
import org.eclipse.jface.text.source.AnnotationModel;\r
import org.eclipse.jface.text.source.AnnotationModelEvent;\r
-import org.eclipse.jface.text.source.IAnnotationModelExtension2;\r
\r
/**\r
* @author p.ciardelli\r
* @created 25.06.2009\r
* @version 1.0\r
*/\r
-public class BulkEditorAnnotationModel extends AnnotationModel {\r
+public class CdmEntityAnnotationModel extends AnnotationModel {\r
private static final Logger logger = Logger\r
- .getLogger(BulkEditorAnnotationModel.class);\r
+ .getLogger(CdmEntityAnnotationModel.class);\r
\r
private Comparator<Annotation> comparator;\r
+\r
+ private IEntityContainerCreator cdmEntityCreator;\r
\r
/**\r
* Changes the annotation's type and fires model changed \r
* in annotation's decoration to be displayed. \r
* \r
* @param annotation\r
+ * @param type\r
*/\r
public void changeAnnotationType(Annotation annotation, String type) {\r
annotation.setType(type);\r
annotation.markDeleted(true);\r
super.removeAnnotation(annotation, fireModelChanged);\r
}\r
- \r
+ \r
/**\r
- * @param model\r
+ * @param type\r
*/\r
- public void removeMergeTargetAnnotations() {\r
- Iterator iterator = getAnnotationIterator();\r
+ public void removeAllTargetsOfType(String type) {\r
+ Iterator<?> iterator = getAnnotationIterator();\r
while (iterator.hasNext()) {\r
Annotation annotation = ((Annotation) iterator.next());\r
- if (annotation.getType().equals(BulkEditorAnnotation.TYPE_MERGE_TARGET)) {\r
+ if (annotation.getType().equals(type)) {\r
annotation.setType(Annotation.TYPE_UNKNOWN);\r
}\r
- }\r
+ } \r
}\r
-\r
+ \r
/**\r
- * @param model\r
+ * @param type\r
* @return\r
*/\r
- public Set<Annotation> getMergeCandidateAnnotations() {\r
+ public Set<Annotation> getAllAnnotationsOfType(String type) {\r
Set<Annotation> candidates = new HashSet<Annotation>();\r
- Iterator iterator = getAnnotationIterator();\r
+ Iterator<?> iterator = getAnnotationIterator();\r
while (iterator.hasNext()) {\r
Annotation annotation = ((Annotation) iterator.next());\r
- if (annotation.getType().equals(BulkEditorAnnotation.TYPE_MERGE_CANDIDATE)) {\r
+ if (annotation.getType().equals(type)) {\r
candidates.add(annotation);\r
}\r
- }\r
- return candidates;\r
- }\r
-\r
+ } \r
+ return candidates; \r
+ } \r
+ \r
/**\r
- * @param model\r
+ * @param type\r
* @return\r
*/\r
- public Annotation getMergeTargetAnnotation() {\r
- Iterator iterator = getAnnotationIterator();\r
+ public Annotation getFirstAnnotationOfType(String type) {\r
+ Iterator<?> iterator = getAnnotationIterator();\r
while (iterator.hasNext()) {\r
Annotation annotation = ((Annotation) iterator.next());\r
- if (annotation.getType().equals(BulkEditorAnnotation.TYPE_MERGE_TARGET)) {\r
+ if (annotation.getType().equals(type)) {\r
return annotation;\r
}\r
- }\r
+ } \r
return null;\r
}\r
\r
try {\r
int offset = document.getLineOffset(line);\r
int length = document.getLineLength(line);\r
- Iterator iterator = getAnnotationIterator(offset, length, true, true);\r
+ Iterator<?> iterator = getAnnotationIterator(offset, length, true, true);\r
if (iterator.hasNext()) {\r
annotation = (Annotation) iterator.next();\r
}\r
return annotation;\r
}\r
\r
+ /**\r
+ * @return\r
+ */\r
public List<Annotation> getOrderedAnnotations() {\r
List<Annotation> list = new ArrayList<Annotation>();\r
- Iterator iterator = getAnnotationIterator();\r
+ Iterator<?> iterator = getAnnotationIterator();\r
while (iterator.hasNext()) {\r
list.add((Annotation) iterator.next());\r
}\r
logger.debug("--------");\r
}\r
\r
- public List<BulkEditorAnnotation> getAnnotations(int offset, int length) {\r
+ /**\r
+ * @param offset\r
+ * @param length\r
+ * @return\r
+ */\r
+ public List<CdmEntityAnnotation> getAnnotations(int offset, int length) {\r
\r
- List<BulkEditorAnnotation> list = new ArrayList<BulkEditorAnnotation>();\r
+ List<CdmEntityAnnotation> list = new ArrayList<CdmEntityAnnotation>();\r
\r
- Iterator iterator = getAnnotationIterator(offset, length, true, true);\r
+ Iterator<?> iterator = getAnnotationIterator(offset, length, true, true);\r
while (iterator.hasNext()) {\r
Object next = iterator.next();\r
- if (next instanceof BulkEditorAnnotation) {\r
- list.add((BulkEditorAnnotation) next); \r
+ if (next instanceof CdmEntityAnnotation) {\r
+ list.add((CdmEntityAnnotation) next); \r
}\r
}\r
Collections.sort(list, getAnnotationComparator());\r
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)\r
*/\r
public int compare(Annotation annotation1, Annotation annotation2) {\r
- int offset1 = BulkEditorAnnotationModel.this.\r
+ int offset1 = CdmEntityAnnotationModel.this.\r
getPosition(annotation1).getOffset();\r
- int offset2 = BulkEditorAnnotationModel.this.\r
+ int offset2 = CdmEntityAnnotationModel.this.\r
getPosition(annotation2).getOffset();\r
if (offset1 > offset2) {\r
return 1;\r
} else {\r
return 0;\r
}\r
+ } \r
+ }\r
+ \r
+ /**\r
+ * The annotation model is assigned responsibility for creating new CDM entities\r
+ * from blocks of text.\r
+ * \r
+ * @param cdmEntityCreator\r
+ */\r
+ public void setCdmEntityCreator(IEntityContainerCreator cdmEntityCreator) {\r
+ this.cdmEntityCreator = cdmEntityCreator;\r
+ }\r
+ \r
+ /**\r
+ * Creates an annotation without adding it to the model.\r
+ * \r
+ * This object must have its <code>cdmEntityCreator</code> set. \r
+ * \r
+ * @param text\r
+ * @return\r
+ */\r
+ public Annotation createAnnotation(String text) {\r
+ Annotation annotation = null;\r
+ if (cdmEntityCreator != null) {\r
+ IEntityContainer<?> container = cdmEntityCreator.createContainer(text);\r
+ annotation = new CdmEntityAnnotation(container);\r
}\r
- \r
+ return annotation;\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
+\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public interface IBulkEditorConstants {\r
+ public static final String TYPE_MERGE_TARGET = "merge_target_annotation";\r
+ public static final String TYPE_MERGE_CANDIDATE = "merge_candidate_annotation";\r
+}\r
boolean isMarkedAsDeleted();\r
\r
void setText(String text);\r
+\r
+ Object getPropertySource();\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
+\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public interface IEntityContainerCreator {\r
+\r
+ /**\r
+ * Creates both a new container and a new CDM object, using\r
+ * titleCache.\r
+ * \r
+ * @param titleCache\r
+ * @return\r
+ */\r
+ IEntityContainer<?> createContainer(String titleCache);\r
+ \r
+ /**\r
+ * Creates a new container using an existing CDM object.\r
+ * \r
+ * @param cdmEntity\r
+ * @return\r
+ */\r
+ IEntityContainer<?> createContainer(CdmBase cdmEntity);\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
+\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public interface ILineSelectionSource {\r
+ \r
+ Object getSelectedObjectAtLine(int line);\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
+\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.TextSelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public class LineSelection extends TextSelection implements IStructuredSelection {\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger.getLogger(LineSelection.class);\r
+\r
+ private StructuredSelection structuredSelection;\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public LineSelection(TextSelection selection, IDocument document, Object selectedObject) {\r
+ super(document, selection.getOffset(), selection.getLength());\r
+ this.structuredSelection = new StructuredSelection(selectedObject);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement()\r
+ */\r
+ public Object getFirstElement() {\r
+ return structuredSelection.getFirstElement();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()\r
+ */\r
+ public Iterator<?> iterator() {\r
+ return structuredSelection.iterator();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.viewers.IStructuredSelection#size()\r
+ */\r
+ public int size() {\r
+ return structuredSelection.size();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()\r
+ */\r
+ public Object[] toArray() {\r
+ return structuredSelection.toArray();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toList()\r
+ */\r
+ public List<?> toList() {\r
+ return structuredSelection.toList();\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
+\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.BadLocationException;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.source.Annotation;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.jface.text.source.IAnnotationModelExtension2;\r
+import org.eclipse.jface.text.source.ISourceViewer;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public class LineSelectionSource implements ILineSelectionSource {\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger\r
+ .getLogger(LineSelectionSource.class);\r
+\r
+ private ISourceViewer viewer;\r
+\r
+ /**\r
+ * \r
+ */\r
+ public LineSelectionSource(ISourceViewer viewer) {\r
+ this.viewer = viewer;\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.neweditor.ILineSelectionSource#getSelectedObjectAtLine(int)\r
+ */\r
+ public Object getSelectedObjectAtLine(int line) {\r
+ IDocument document = viewer.getDocument();\r
+ IAnnotationModel model = viewer.getAnnotationModel();\r
+ try {\r
+ int offset = document.getLineOffset(line);\r
+ int length = document.getLineLength(line);\r
+ Iterator<?> iterator = ((IAnnotationModelExtension2) model).\r
+ getAnnotationIterator(offset, length, true, true);\r
+ if (iterator.hasNext()) {\r
+ Annotation annotation = (Annotation) iterator.next();\r
+ if (annotation instanceof CdmEntityAnnotation) {\r
+ IEntityContainer<?> container = ((CdmEntityAnnotation) annotation).getEntityContainer();\r
+ return container.getPropertySource();\r
+ }\r
+ }\r
+ } catch (BadLocationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ return null;\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
+\r
+package eu.etaxonomy.taxeditor.bulkeditor;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.jface.text.TextSelection;\r
+import org.eclipse.jface.text.source.IOverviewRuler;\r
+import org.eclipse.jface.text.source.IVerticalRuler;\r
+import org.eclipse.jface.text.source.SourceViewer;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.SelectionChangedEvent;\r
+import org.eclipse.swt.events.KeyAdapter;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.MouseAdapter;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+/**\r
+ * Notifies selection service every time the user changes focus to a new line.\r
+ * \r
+ * @author p.ciardelli\r
+ * @created 03.07.2009\r
+ * @version 1.0\r
+ */\r
+public class LineSelectionViewer extends SourceViewer {\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger\r
+ .getLogger(LineSelectionViewer.class);\r
+\r
+ private int lastLine = 0;\r
+ private ILineSelectionSource lineSelectionSource;\r
+ \r
+ /**\r
+ * @param parent\r
+ * @param verticalRuler\r
+ * @param overviewRuler\r
+ * @param showAnnotationsOverview\r
+ * @param styles\r
+ */\r
+ public LineSelectionViewer(Composite parent, IVerticalRuler verticalRuler,\r
+ IOverviewRuler overviewRuler, boolean showAnnotationsOverview,\r
+ int styles) {\r
+ super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);\r
+\r
+ createLineChangeListeners();\r
+ fireLineSelection();\r
+ }\r
+ \r
+ /**\r
+ * @param lineSelectionSource\r
+ */\r
+ public void setLineSelectionSource(ILineSelectionSource lineSelectionSource) {\r
+ this.lineSelectionSource = lineSelectionSource;\r
+ }\r
+ \r
+ /**\r
+ * \r
+ */\r
+ private void createLineChangeListeners() {\r
+ getTextWidget().addKeyListener(new KeyAdapter() {\r
+ @Override\r
+ public void keyReleased(KeyEvent e) {\r
+ checkLineChange();\r
+ }\r
+ });\r
+ getTextWidget().addMouseListener(new MouseAdapter() {\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ checkLineChange(); \r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * If the user has put the cursor on a new line, change the selection\r
+ */\r
+ private void checkLineChange() {\r
+ ISelection selection = getSelection();\r
+ if (selection instanceof TextSelection) {\r
+ int line = ((TextSelection) selection).getStartLine();\r
+ if (line != lastLine) { \r
+ fireLineSelection();\r
+ lastLine = line;\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * \r
+ */\r
+ private void fireLineSelection() {\r
+ if (lineSelectionSource == null) {\r
+ return;\r
+ }\r
+ ISelection selection = getSelection();\r
+ if (selection instanceof TextSelection) {\r
+ int line = ((TextSelection) selection).getStartLine();\r
+ Object selectionObject = lineSelectionSource.getSelectedObjectAtLine(line);\r
+ selection = new LineSelection((TextSelection) selection, getDocument(), selectionObject);\r
+ SelectionChangedEvent event= new SelectionChangedEvent(this, selection);\r
+ fireSelectionChanged(event);\r
+ }\r
+ }\r
+}
\ No newline at end of file
\r
import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
+import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;\r
\r
/**\r
* @author p.ciardelli\r
* @created 25.06.2009\r
* @version 1.0\r
*/\r
-public class ReferenceContainer implements IEntityContainer<ReferenceBase> {\r
+public class ReferenceContainer implements IEntityContainer<ReferenceBase<?>> {\r
private static final Logger logger = Logger\r
.getLogger(ReferenceContainer.class);\r
\r
- private ReferenceBase reference;\r
+ private ReferenceBase<?> reference;\r
private boolean deleted;\r
private boolean merged;\r
\r
- ReferenceContainer(ReferenceBase reference) {\r
+ ReferenceContainer(ReferenceBase<?> reference) {\r
this.reference = reference;\r
}\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getCdmEntity()\r
*/\r
- public ReferenceBase getCdmEntity() {\r
+ public ReferenceBase<?> getCdmEntity() {\r
return reference;\r
}\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsMerged(eu.etaxonomy.cdm.model.common.CdmBase)\r
*/\r
- public void markAsMerged(ReferenceBase mergeTarget) {\r
+ public void markAsMerged(ReferenceBase<?> mergeTarget) {\r
logger.debug("Marking " + reference.getTitleCache() + \r
" for merger w " + mergeTarget.getTitleCache()); \r
this.merged = true;\r
" to " + titleCache); \r
reference.setTitleCache(titleCache);\r
}\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getPropertySource()\r
+ */\r
+ public Object getPropertySource() {\r
+ return new ReferencePropertySource(reference);\r
+ }\r
+\r
}
\ No newline at end of file
import java.util.ArrayList;\r
import java.util.List;\r
\r
+import org.apache.log4j.Logger;\r
import org.eclipse.ui.IEditorInput;\r
\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.reference.Journal;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
\r
* @created 25.06.2009\r
* @version 1.0\r
*/\r
-public class ReferenceEditorInput extends BulkEditorInput<ReferenceBase> implements\r
+public class ReferenceEditorInput extends BulkEditorInput implements\r
IEditorInput {\r
+ private static final Logger logger = Logger\r
+ .getLogger(ReferenceEditorInput.class);\r
\r
- private ArrayList<IEntityContainer<ReferenceBase>> list;\r
+ private ArrayList<IEntityContainer<?>> list;\r
\r
/* (non-Javadoc)\r
* @see eu.etaxonomy.taxeditor.bulkeditor.BulkEditorInput#getList()\r
*/\r
- public List<IEntityContainer<ReferenceBase>> getList() {\r
+ public List<IEntityContainer<?>> getList() {\r
if (list == null) {\r
- list = new ArrayList<IEntityContainer<ReferenceBase>>();\r
+ list = new ArrayList<IEntityContainer<?>>();\r
\r
- list.add(getNewContainer("Acta universitatis carolinae. Biologica Prague"));\r
- list.add(getNewContainer("Acta universitatis asiae mediae. Botanica"));\r
- list.add(getNewContainer("Acta phytogeographica suecica Uppsala"));\r
- list.add(getNewContainer("Acta botanica neerlandica Amsterdam"));\r
- list.add(getNewContainer("Acta geobotanica hungarica Debrecen, Hungary"));\r
+ list.add(createContainer("Acta universitatis carolinae. Biologica Prague"));\r
+ list.add(createContainer("Acta universitatis asiae mediae. Botanica"));\r
+ list.add(createContainer("Acta phytogeographica suecica Uppsala"));\r
+ list.add(createContainer("Acta botanica neerlandica Amsterdam"));\r
+ list.add(createContainer("Acta geobotanica hungarica Debrecen, Hungary"));\r
}\r
return list;\r
}\r
- \r
- private IEntityContainer<ReferenceBase> getNewContainer(String titleCache) {\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainerCreator#create(java.lang.String)\r
+ */\r
+ public IEntityContainer<?> createContainer(String titleCache) {\r
Journal journal = Journal.NewInstance();\r
journal.setTitleCache(titleCache);\r
- return new ReferenceContainer(journal);\r
+ return createContainer(journal);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainerCreator#create(eu.etaxonomy.cdm.model.common.CdmBase)\r
+ */\r
+ public IEntityContainer<?> createContainer(CdmBase cdmEntity) {\r
+ logger.info("creating");\r
+ return new ReferenceContainer((ReferenceBase<?>) cdmEntity);\r
}\r
}
\ No newline at end of file
\r
import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;\r
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorAnnotation;\r
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorAnnotationModel;\r
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorInput;\r
+import eu.etaxonomy.taxeditor.bulkeditor.CdmEntityAnnotation;\r
+import eu.etaxonomy.taxeditor.bulkeditor.CdmEntityAnnotationModel;\r
+import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;\r
import eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer;\r
\r
/**\r
if (editor instanceof BulkEditor && input instanceof BulkEditorInput) {\r
\r
IDocumentProvider provider = ((BulkEditor) editor).getDocumentProvider();\r
- BulkEditorAnnotationModel model = \r
- (BulkEditorAnnotationModel) provider.getAnnotationModel(input);\r
+ CdmEntityAnnotationModel model = \r
+ (CdmEntityAnnotationModel) provider.getAnnotationModel(input);\r
IDocument document = provider.getDocument(input);\r
\r
// Check whether there are any group annotations\r
- Set<Annotation> candidateAnnotations = model.getMergeCandidateAnnotations();\r
+ Set<Annotation> candidateAnnotations = model.getAllAnnotationsOfType(IBulkEditorConstants.TYPE_MERGE_CANDIDATE);\r
if (candidateAnnotations.size() == 0) {\r
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), \r
"No merge candidates", "No objects have been chosen for merging.");\r
}\r
\r
// Check whether group merge target has been set\r
- Annotation targetAnnotation = model.getMergeTargetAnnotation();\r
+ Annotation targetAnnotation = model.getFirstAnnotationOfType(IBulkEditorConstants.TYPE_MERGE_TARGET);\r
if (targetAnnotation == null) {\r
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), \r
"No group merge target set", "No group merge target has been set.");\r
return null;\r
} \r
- CdmBase targetEntity = ((BulkEditorAnnotation) targetAnnotation).\r
- getContainer().getCdmEntity();\r
+ CdmBase targetEntity = ((CdmEntityAnnotation) targetAnnotation).\r
+ getEntityContainer().getCdmEntity();\r
\r
logger.info("Merging group");\r
model.printAnnotations();\r
\r
// Mark entity container for merging with target entity\r
IEntityContainer container = \r
- ((BulkEditorAnnotation) annotation).getContainer();\r
+ ((CdmEntityAnnotation) annotation).getEntityContainer();\r
container.markAsMerged(targetEntity);\r
logger.info("Merging " + annotation + " with " + targetAnnotation);\r
\r
import org.eclipse.ui.texteditor.IDocumentProvider;\r
\r
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;\r
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorAnnotation;\r
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorAnnotationModel;\r
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorInput;\r
+import eu.etaxonomy.taxeditor.bulkeditor.CdmEntityAnnotationModel;\r
+import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;\r
\r
/**\r
* @author p.ciardelli\r
if (editor instanceof BulkEditor && input instanceof BulkEditorInput) {\r
\r
IDocumentProvider provider = ((BulkEditor) editor).getDocumentProvider();\r
- BulkEditorAnnotationModel model = \r
- (BulkEditorAnnotationModel) provider.getAnnotationModel(input);\r
+ CdmEntityAnnotationModel model = \r
+ (CdmEntityAnnotationModel) provider.getAnnotationModel(input);\r
IDocument document = provider.getDocument(input);\r
\r
ISelection selection = HandlerUtil.getActiveMenuSelection(event);\r
annotation = model.getAnnotationAtLine(line, document);\r
\r
// Remove existing merge target\r
- model.removeMergeTargetAnnotations();\r
+ model.removeAllTargetsOfType(IBulkEditorConstants.TYPE_MERGE_TARGET);\r
\r
// Set annotation in current line to merge target\r
if (annotation != null) {\r
model.changeAnnotationType(\r
- annotation, BulkEditorAnnotation.TYPE_MERGE_TARGET);\r
+ annotation, IBulkEditorConstants.TYPE_MERGE_TARGET);\r
}\r
}\r
} \r
package eu.etaxonomy.taxeditor.bulkeditor.internal;\r
\r
-import java.net.URL;\r
-\r
-import org.eclipse.core.runtime.IPath;\r
-import org.eclipse.core.runtime.Path;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.resource.ImageRegistry;\r
import org.eclipse.ui.plugin.AbstractUIPlugin;\r
-import org.osgi.framework.Bundle;\r
import org.osgi.framework.BundleContext;\r
\r
/**\r
public static TaxeditorBulkeditorPlugin getDefault() {\r
return plugin;\r
}\r
-\r
- /**\r
- * Returns an image descriptor for the image file at the given\r
- * plug-in relative path\r
- *\r
- * @param path the path\r
- * @return the image descriptor\r
- */\r
- public static ImageDescriptor getImageDescriptor(String path) {\r
- return imageDescriptorFromPlugin(PLUGIN_ID, path);\r
- }\r
- \r
- public static final String IMAGE_ID = "sample.image";\r
- \r
- protected void initializeImageRegistry(ImageRegistry registry) {\r
- Bundle bundle = Platform.getBundle(PLUGIN_ID);\r
- IPath path = new Path("translate.gif");\r
- URL url = Platform.find(bundle, path);\r
- ImageDescriptor desc = ImageDescriptor.createFromURL(url);\r
- registry.put(IMAGE_ID, desc);\r
- }\r
-\r
-}\r
+}
\ No newline at end of file