moved image functionality into the library
authorn.hoffmann <n.hoffmann@localhost>
Wed, 27 Jan 2010 13:14:58 +0000 (13:14 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 27 Jan 2010 13:14:58 +0000 (13:14 +0000)
15 files changed:
.gitattributes
.gitignore
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/DescriptionContentProvider.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/DescriptionMasterDetailsBlock.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/handler/MoveImageDownInListHandler.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/handler/MoveImageUpInListHandler.java
taxeditor-store/plugin.xml
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java [deleted file]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AddImageToDescriptionElementOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateDescriptionElementOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateImageOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteImageOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveImageInListOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveImageFromDescriptionElementOperation.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java [new file with mode: 0644]

index 3f4f61b34ec7035ba3c3d6ba7afdaf31c4feb685..caeaf21a52f48f677374f0d30f79fdb89cc47c60 100644 (file)
@@ -569,7 +569,6 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/DataChangeBridge.java
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/IDataChangeBehavior.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java -text
-taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/NameHelper.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/NomenclaturalCodeHelper.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/Resources.java -text
@@ -611,6 +610,7 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperati
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveHomotypicalGroupBasionymOperation.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveImageFromDescriptionElementOperation.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/SwapSynonymAndAcceptedOperation.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/CdmPreferences.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/DescriptionPreferences.java -text
index 42fb7e3a7779af31abd4944b61ecd25e06afeb74..1d1c96b72f016824c0aaf5df41fdbdfb6743dcdf 100644 (file)
@@ -13,6 +13,7 @@ taxeditor-editor/.classpath
 taxeditor-editor/.project
 taxeditor-editor/.settings
 taxeditor-editor/target
+taxeditor-feature-product/compile.eu.etaxonomy.taxeditor.product.feature.xml
 taxeditor-feature-product/plugin_customization.ini
 taxeditor-feature-product/workspace
 taxeditor-navigation/.classpath
index fcf63275c5cfa3fb835eb01271ce1146af0ae824..65c86d40b25cda1fcec1318770fac3e7a790baa1 100644 (file)
@@ -7,12 +7,12 @@ import org.apache.log4j.Logger;
 import org.eclipse.jface.viewers.ITreeContentProvider;\r
 import org.eclipse.jface.viewers.Viewer;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.description.Feature;\r
 import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 \r
 /**\r
  * @author p.ciardelli\r
@@ -54,7 +54,7 @@ public class DescriptionContentProvider implements ITreeContentProvider {
                if (parentElement instanceof DescriptionElementBase) {\r
                        DescriptionElementBase descriptionElement = (DescriptionElementBase) parentElement; \r
                        if (descriptionElement.getInDescription().isImageGallery()) {\r
-                               return ImagesHelper.getOrderedImages(descriptionElement).toArray();\r
+                               return ImagesUtility.getOrderedImages(descriptionElement).toArray();\r
                        }\r
                }\r
                return NO_CHILDREN;\r
index e7adbef7065a77732385d7ca7435ed291cdc38c6..5e156b696959c698d3a198151a7f3dbd12e9c2ce 100644 (file)
@@ -34,6 +34,7 @@ import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;\r
 import org.eclipse.ui.forms.widgets.Section;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.description.Distribution;\r
@@ -51,7 +52,6 @@ import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.ImageDetailsPage
 import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.LabelDetailsPage;\r
 import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.TaxonInteractionDetailsPage;\r
 import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.TextDataDetailsPage;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 \r
 /**\r
  * @author p.ciardelli\r
@@ -209,7 +209,7 @@ public class DescriptionMasterDetailsBlock extends MasterDetailsBlock {
                }\r
                if (revealObject instanceof ImageFile) {\r
                        ImageFile image = (ImageFile) revealObject;\r
-                       DescriptionElementBase element = ImagesHelper.findImageElement(image, getTaxon());\r
+                       DescriptionElementBase element = ImagesUtility.findImageElement(image, getTaxon());\r
                        \r
                        segments = new Object[3];\r
                        segments[0] = element.getInDescription();\r
index 62641698cc9cafa55a6921ad4016a9d35e95f9f1..9f4e2128a7105cc4d66e8c1e8a9c96b1534d8aba 100644 (file)
@@ -22,13 +22,12 @@ import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.forms.editor.FormEditor;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
-import eu.etaxonomy.taxeditor.operations.AddImageToDescriptionElementOperation;\r
 import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;\r
 import eu.etaxonomy.taxeditor.operations.MoveImageInListOperation;\r
 \r
@@ -70,7 +69,7 @@ public class MoveImageDownInListHandler extends AbstractHandler {
                                try {\r
                                        // TODO use undo context specific to editor\r
                                        operation = new MoveImageInListOperation(event.getCommand().getName(), \r
-                                                       EditorUtil.getUndoContext(), taxon, element, image, ImagesHelper.DOWN, (IPostOperationEnabled) editor);\r
+                                                       EditorUtil.getUndoContext(), taxon, element, image, ImagesUtility.DOWN, (IPostOperationEnabled) editor);\r
                                        EditorUtil.executeOperation(operation);\r
                                } catch (NotDefinedException e) {\r
                                        logger.warn("Command name not set");\r
index e6cb6695a4500aa980877136c15df65fe6b2f377..c6bfe63bc696db493216e6532967f7d93f8dc183 100644 (file)
@@ -22,12 +22,12 @@ import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.forms.editor.FormEditor;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;\r
 import eu.etaxonomy.taxeditor.operations.MoveImageInListOperation;\r
 \r
@@ -69,7 +69,7 @@ public class MoveImageUpInListHandler extends AbstractHandler {
                                try {\r
                                        // TODO use undo context specific to editor\r
                                        operation = new MoveImageInListOperation(event.getCommand().getName(), \r
-                                                       EditorUtil.getUndoContext(), taxon, element, image, ImagesHelper.UP, (IPostOperationEnabled) editor);\r
+                                                       EditorUtil.getUndoContext(), taxon, element, image, ImagesUtility.UP, (IPostOperationEnabled) editor);\r
                                        EditorUtil.executeOperation(operation);\r
                                } catch (NotDefinedException e) {\r
                                        logger.warn("Command name not set");\r
index d14c3a008cb97dc81609f833ba4bb190ebdaf878..593d41ac2c933c4fb942caf92705927fbb4c2957 100644 (file)
       <wizard
             category="eu.etaxonomy.taxeditor.import.category.cdm"
             class="eu.etaxonomy.taxeditor.io.wizard.JaxbImportWizard"
-            id="eu.etaxonomy.taxeditor.io.import.excel"
+            id="eu.etaxonomy.taxeditor.io.import.jaxb"
             name="JAXB">
       </wizard>
       <category
             id="eu.etaxonomy.taxeditor.import.category.excel"
-            name="Excel">
+            name="Excel"
+            parentCategory="eu.etaxonomy.taxeditor.import.category.cdm">
       </category>
       <wizard
             category="eu.etaxonomy.taxeditor.import.category.cdm"
             name="Endnote">
       </wizard>
       <wizard
-            category="eu.etaxonomy.taxeditor.import.category.cdm"
+            category="eu.etaxonomy.taxeditor.import.category.excel"
             class="eu.etaxonomy.taxeditor.io.wizard.ExcelNormalExplicitTaxaImportWizard"
             id="eu.etaxonomy.taxeditor.io.import.excel.taxa"
             name="Excel Normal Explicit Taxa">
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java
deleted file mode 100644 (file)
index 6d44624..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-// $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.model;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.apache.log4j.Logger;\r
-\r
-import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
-import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
-import eu.etaxonomy.cdm.model.description.TextData;\r
-import eu.etaxonomy.cdm.model.media.ImageFile;\r
-import eu.etaxonomy.cdm.model.media.Media;\r
-import eu.etaxonomy.cdm.model.media.MediaRepresentation;\r
-import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
-import eu.etaxonomy.cdm.model.media.ReferencedMedia;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-\r
-/**\r
- * @author p.ciardelli\r
- * @created 31.03.2009\r
- * @version 1.0\r
- * \r
- * This has to be moved to library at some point. Unfortunately, the whole handling of images\r
- * is very half heartedly implemented in the library. We will not mark this here as depreciated \r
- * until the situation in the library improves. \r
- * \r
- */\r
-public class ImagesHelper {\r
-       private static final Logger logger = Logger\r
-                       .getLogger(ImagesHelper.class);\r
-       \r
-       /**\r
-        * Quick and dirty method to get an element's first image file.\r
-        * \r
-        * @param element\r
-        * @return\r
-        */\r
-       public static ImageFile getImage(DescriptionElementBase element) {\r
-               List<Media> medias = element.getMedia();\r
-               \r
-               for(Media media : medias){\r
-                       Set<MediaRepresentation> representations = media.getRepresentations();\r
-                       \r
-                       for(MediaRepresentation representation : representations){\r
-                               List<MediaRepresentationPart> parts = representation.getParts();\r
-                               \r
-                               for (MediaRepresentationPart part : parts){\r
-                                       if(part instanceof ImageFile){\r
-                                               return (ImageFile) part;\r
-                                       }\r
-                               }\r
-                       }                                                       \r
-               }\r
-               return null;\r
-       }\r
-       \r
-       public static List<ImageFile> getOrderedImages(DescriptionElementBase element){\r
-               List<ImageFile> imageList = new ArrayList<ImageFile>();\r
-               MediaRepresentation representation = getImageMediaRepresentation(element);\r
-               if (representation != null) {\r
-                       for (MediaRepresentationPart part : representation.getParts()){\r
-                               if(!(part instanceof ImageFile)){\r
-                                       throw new RuntimeException("Your database contains media that mix Image Files with non-Image Files.");\r
-                               } else {\r
-                                       imageList.add((ImageFile) part);\r
-                               }\r
-                       }\r
-               }\r
-               return imageList;\r
-       }\r
-               \r
-       /**\r
-        * Returns the first Representation with images. If none is found, a\r
-        * Representation for storing images is created and returned.\r
-        * \r
-        * @param element\r
-        * @return\r
-        */\r
-       private static MediaRepresentation getImageMediaRepresentation(DescriptionElementBase element) {\r
-               // Drill down until a representation with images is found\r
-               for(Media media : element.getMedia()){\r
-                       Set<MediaRepresentation> representations = media.getRepresentations();\r
-                       for(MediaRepresentation representation : representations){\r
-                               List<MediaRepresentationPart> parts = representation.getParts();\r
-                               for (MediaRepresentationPart part : parts){\r
-                                       if(part instanceof ImageFile){\r
-                                               return representation;\r
-                                       }\r
-                               }\r
-                       }                                                       \r
-               }               \r
-               // No representation with images found - create\r
-               MediaRepresentation representation = MediaRepresentation.NewInstance();\r
-               Media media = ReferencedMedia.NewInstance();\r
-               element.addMedia(media);\r
-               media.addRepresentation(representation);\r
-               return representation;\r
-       }\r
-       \r
-       /**\r
-        * @param description\r
-        * @return\r
-        */\r
-       public static Set<ImageFile> getImages(TaxonDescription description){\r
-               Set<ImageFile> images = new HashSet<ImageFile>();\r
-               \r
-               for (DescriptionElementBase element : description.getElements()){\r
-                       \r
-                       Feature feature = element.getFeature();\r
-                       \r
-                       if(feature.equals(Feature.IMAGE())){\r
-                               List<Media> medias = element.getMedia();\r
-                               \r
-                               for(Media media : medias){\r
-                                       Set<MediaRepresentation> representations = media.getRepresentations();\r
-                                       \r
-                                       for(MediaRepresentation representation : representations){\r
-                                               List<MediaRepresentationPart> parts = representation.getParts();\r
-                                               \r
-                                               for (MediaRepresentationPart part : parts){\r
-                                                       if(part instanceof ImageFile){\r
-                                                               images.add((ImageFile) part);\r
-                                                       }\r
-                                               }\r
-                                       }                                                       \r
-                               }                                                                               \r
-                       }\r
-               }\r
-               \r
-               return images;\r
-       }\r
-\r
-       /**\r
-        * @param taxon\r
-        * @param imageFile\r
-        */\r
-       public static void addTaxonImage(Taxon taxon, DescriptionBase<?> imageGallery, ImageFile imageFile) {\r
-                               \r
-               imageGallery.addElement(createImageElement(imageFile));\r
-               \r
-       }\r
-       \r
-       public static DescriptionElementBase createImageElement(ImageFile imageFile) {\r
-               \r
-               DescriptionElementBase descriptionElement = TextData.NewInstance(Feature.IMAGE());\r
-               \r
-               Media media = Media.NewInstance();\r
-               MediaRepresentation representation = MediaRepresentation.NewInstance();\r
-               \r
-               representation.addRepresentationPart(imageFile);\r
-               \r
-               media.addRepresentation(representation);\r
-               \r
-               descriptionElement.addMedia(media);\r
-               \r
-               return descriptionElement;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Adds a new, empty image file to the end of a description element's\r
-        * ordered list of images.\r
-        * \r
-        * @param element\r
-        * @return \r
-        */\r
-       public static ImageFile addImagePart(DescriptionElementBase element) {\r
-               ImageFile imageFile = ImageFile.NewInstance(null, null);\r
-               getImageMediaRepresentation(element).addRepresentationPart(imageFile);\r
-               return imageFile;\r
-       }\r
-       \r
-       /**\r
-        * @param taxon\r
-        * @param imageFile\r
-        */\r
-       public static void removeTaxonImage(Taxon taxon, DescriptionBase<?> imageGallery, ImageFile imageFile) {\r
-               Set<DescriptionElementBase> descriptionElementsToRemove = new HashSet<DescriptionElementBase>();\r
-               Set<MediaRepresentationPart> representationPartsToRemove = new HashSet<MediaRepresentationPart>();\r
-               \r
-               Set<DescriptionElementBase> images = imageGallery.getElements();\r
-               \r
-               // overmodelling of media in cdmlib makes this a little bit complicated\r
-               for(DescriptionElementBase descriptionElement : images){\r
-                       for(Media media : descriptionElement.getMedia()){\r
-                               for(MediaRepresentation representation : media.getRepresentations()){\r
-                                       for(MediaRepresentationPart part : representation.getParts()){\r
-                                               if(part.equals(imageFile)){\r
-                                                       // because of concurrent modification, we just collect the parts to remove \r
-                                                       representationPartsToRemove.add(part);\r
-                                               }\r
-                                       }\r
-\r
-                                       // and then remove the representation parts here\r
-                                       for (MediaRepresentationPart part : representationPartsToRemove){\r
-                                               representation.removeRepresentationPart(part);\r
-                                       }\r
-                                       // clear set for next run\r
-                                       representationPartsToRemove.clear();\r
-                                       \r
-                                       // description elements with empty representations should be deleted as well\r
-                                       if(representation.getParts().size() == 0){\r
-                                               descriptionElementsToRemove.add(descriptionElement);\r
-                                       }\r
-                               }\r
-                       }\r
-               }       \r
-               \r
-               // remove the empty description elements\r
-               for(DescriptionElementBase descriptionElement : descriptionElementsToRemove){\r
-                       imageGallery.removeElement(descriptionElement);\r
-               }               \r
-       }\r
-\r
-       public static final int UP = 1;\r
-       public static final int DOWN = -1;\r
-       \r
-       /**\r
-        * @param input\r
-        * @param selectedImage\r
-        * @param direction\r
-        */\r
-       public static void moveImage(DescriptionElementBase element, ImageFile image,\r
-                       int direction) {\r
-               \r
-               MediaRepresentation representation = getImageMediaRepresentation(element);\r
-               int index = representation.getParts().indexOf(image);\r
-               if (index == -1) {\r
-                       return;\r
-               }               \r
-               if (direction == UP && index != 0) {\r
-                       Collections.swap(representation.getParts(), index, index - 1);\r
-               }\r
-               if (direction == DOWN && index < representation.getParts().size() - 1) {\r
-                       Collections.swap(representation.getParts(), index, index + 1);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * @param input\r
-        * @param selectedImage\r
-        */\r
-       public static void removeImage(DescriptionElementBase element, ImageFile image) {\r
-               getImageMediaRepresentation(element).getParts().remove(image);\r
-       }\r
-\r
-       /**\r
-        * Iterate through all taxon's image galleries until the descriptive element containing\r
-        * the ImageFile is found.\r
-        * \r
-        * @param image\r
-        * @param taxon \r
-        * @return \r
-        */\r
-       public static DescriptionElementBase findImageElement(ImageFile image, Taxon taxon) {\r
-               if (taxon == null) {\r
-                       return null;\r
-               }\r
-               for (TaxonDescription description : taxon.getDescriptions()) {\r
-                       if (description.isImageGallery()) {\r
-                               for (DescriptionElementBase element : description.getElements()) {\r
-                                       if (getOrderedImages(element).contains(image)) {\r
-                                               return element;\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               return null;            \r
-       }\r
-}
\ No newline at end of file
index 310db2bbdc199dba2e3e172cc7e156b85a75ade0..59002e3166c478aa5d5d558308296bc80d160d6c 100644 (file)
@@ -14,12 +14,11 @@ import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;\r
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.OperationCanceledException;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -63,7 +62,7 @@ public class AddImageToDescriptionElementOperation extends AbstractPostOperation
 \r
         try {\r
                // Operation steps\r
-                       image = ImagesHelper.addImagePart(element);\r
+                       image = ImagesUtility.addImagePart(element);\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
         }\r
         finally {\r
@@ -90,7 +89,7 @@ public class AddImageToDescriptionElementOperation extends AbstractPostOperation
        @Override\r
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
-               ImagesHelper.removeImage(element, image);\r
+               ImagesUtility.removeImage(element, image);\r
                return postExecute(element);\r
        }\r
 }\r
index 4a2427220f796478674eaa4d4befdc3d4eaceed9..5649f9f960e4c96352336fd2c746417c86ae72aa 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.description.Distribution;\r
@@ -24,8 +25,6 @@ import eu.etaxonomy.cdm.model.description.TaxonInteraction;
 import eu.etaxonomy.cdm.model.description.TextData;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
-import eu.etaxonomy.taxeditor.store.CdmStore;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -88,7 +87,7 @@ public class CreateDescriptionElementOperation extends AbstractPostOperation {
                                } else if (feature.isSupportsDistribution()) {\r
                                        element = Distribution.NewInstance();\r
                                } else if (feature.equals(Feature.IMAGE())){\r
-                                       element = ImagesHelper.createImageElement(ImageFile.NewInstance(null, null));\r
+                                       element = ImagesUtility.createImageElement(ImageFile.NewInstance(null, null));\r
                                } else if(feature.isSupportsTaxonInteraction()){\r
                                        element = TaxonInteraction.NewInstance(feature);\r
                                } else {\r
index 702e17e8b1d968876a9519e4185f26cb11f7f758..309fbd92bc063c156ccddd45b2428ab5c11d8089 100644 (file)
@@ -16,10 +16,10 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -73,7 +73,7 @@ public class CreateImageOperation extends AbstractPostOperation {
                        }\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
 \r
-                       ImagesHelper.addTaxonImage(taxon, description, imageFile);\r
+                       ImagesUtility.addTaxonImage(taxon, description, imageFile);\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
         }\r
         finally {\r
@@ -92,7 +92,7 @@ public class CreateImageOperation extends AbstractPostOperation {
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
                \r
-               ImagesHelper.addTaxonImage(taxon, description, imageFile);\r
+               ImagesUtility.addTaxonImage(taxon, description, imageFile);\r
                \r
                return postExecute(imageFile);\r
        }\r
@@ -104,7 +104,7 @@ public class CreateImageOperation extends AbstractPostOperation {
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
                \r
-               ImagesHelper.removeTaxonImage(taxon, description, imageFile);\r
+               ImagesUtility.removeTaxonImage(taxon, description, imageFile);\r
                \r
                return postExecute(null);\r
        }\r
index 5ffef32fb593cc3c3e659a28b452346c647c0624..80968c94146f52838c7de31f26336da0ada5618b 100644 (file)
@@ -16,10 +16,10 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -63,7 +63,7 @@ public class DeleteImageOperation extends AbstractPostOperation {
         try {\r
                // Operation steps\r
 \r
-               ImagesHelper.removeTaxonImage(taxon, description, imageFile);\r
+               ImagesUtility.removeTaxonImage(taxon, description, imageFile);\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
         }\r
         finally {\r
@@ -91,7 +91,7 @@ public class DeleteImageOperation extends AbstractPostOperation {
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
                \r
-               ImagesHelper.addTaxonImage(taxon, description, imageFile);\r
+               ImagesUtility.addTaxonImage(taxon, description, imageFile);\r
                \r
                return postExecute(null);\r
        }\r
index 859fa6b0ca4145d3b6e073b419aec3a2b478ad69..8d6108c1b50d620bb68ea2aa02977196e1cfc30a 100644 (file)
@@ -15,10 +15,10 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -67,7 +67,7 @@ public class MoveImageInListOperation extends AbstractPostOperation {
         try {\r
                // Operation steps\r
        \r
-                       ImagesHelper.moveImage(element, image, direction);\r
+               ImagesUtility.moveImage(element, image, direction);\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
         }\r
         finally {\r
@@ -94,7 +94,7 @@ public class MoveImageInListOperation extends AbstractPostOperation {
        @Override\r
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
-               ImagesHelper.moveImage(element, image, direction * -1);\r
+               ImagesUtility.moveImage(element, image, direction * -1);\r
                return postExecute(null);\r
        }\r
 }\r
index b0da82dc127e29a126185b1b4406eb473c191a40..f17687492931c6cbcdbf767c90cb86cfc9e3cf6a 100644 (file)
@@ -15,10 +15,10 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 \r
+import eu.etaxonomy.cdm.api.utility.ImagesUtility;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.media.ImageFile;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.taxeditor.model.ImagesHelper;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -64,7 +64,7 @@ public class RemoveImageFromDescriptionElementOperation extends AbstractPostOper
         try {\r
                // Operation steps\r
        \r
-                       ImagesHelper.removeImage(element, image);\r
+                       ImagesUtility.removeImage(element, image);\r
                        StoreUtil.isCanceled(newMonitor, 1);\r
         }\r
         finally {\r
@@ -91,7 +91,7 @@ public class RemoveImageFromDescriptionElementOperation extends AbstractPostOper
        @Override\r
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
-               image = ImagesHelper.addImagePart(element);\r
+               image = ImagesUtility.addImagePart(element);\r
                return postExecute(image);\r
        }\r
 }\r
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java
new file mode 100644 (file)
index 0000000..d757b8f
--- /dev/null
@@ -0,0 +1,173 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.parser;
+
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
+import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
+import eu.etaxonomy.cdm.strategy.match.MatchException;
+import eu.etaxonomy.cdm.strategy.match.MatchMode;
+
+/**
+ * This class defines the MatchStrategies that will be used by the ParseHandler.
+ * 
+ * @author n.hoffmann
+ * @created Jan 22, 2010
+ * @version 1.0
+ */
+public class MatchStrategyConfigurator {
+       
+       /**
+        * Singleton instance
+        */
+       private static MatchStrategyConfigurator instance = new MatchStrategyConfigurator();
+       
+       private IMatchStrategy nonViralNameMatchStrategy;
+       private IMatchStrategy teamOrPersonMatchStrategy;
+       private IMatchStrategy referenceMatchStrategy;
+       
+       /**
+        * 
+        * @return
+        * @throws MatchException
+        */
+       public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
+               return instance.getNonViralNameMatchStrategy();
+       }
+       
+       /**
+        * 
+        * @return
+        * @throws MatchException
+        */
+       public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
+               return instance.getTeamOrPersonMatchStrategy();
+       }
+       
+       /**
+        * 
+        * @return
+        * @throws MatchException
+        */
+       public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
+               return instance.getReferenceMatchStrategy();
+       }
+
+       /**
+        * @param strategy the nonViralNameMatchStrategy to set
+        */
+       private void doSetNonViralNameMatchStrategy(IMatchStrategy strategy) {
+               this.nonViralNameMatchStrategy = strategy;
+       }
+       
+       /**
+        * @param strategy the nonViralNameMatchStrategy to set
+        */
+       public static void setNonViralNameMatchStrategy(IMatchStrategy strategy) {
+               instance.doSetNonViralNameMatchStrategy(strategy);
+       }
+       
+       /**
+        * @param strategy the teamOrPersonMatchStrategy to set
+        */
+       private void doSetTeamOrPersonMatchStrategy(IMatchStrategy strategy) {
+               this.teamOrPersonMatchStrategy = strategy;
+       }
+
+       /**
+        * @param strategy the teamOrPersonMatchStrategy to set
+        */
+       public static void setTeamOrPersonMatchStrategy(IMatchStrategy strategy) {
+               instance.doSetTeamOrPersonMatchStrategy(strategy);
+       }
+
+       /**
+        * @param strategy the referenceMatchStrategy to set
+        */
+       private void doSetReferenceMatchStrategy(IMatchStrategy strategy) {
+               this.referenceMatchStrategy = strategy;
+       }
+       
+       /**
+        * @param strategy the referenceMatchStrategy to set
+        */
+       public static void setReferenceMatchStrategy(IMatchStrategy strategy) {
+               instance.doSetReferenceMatchStrategy(strategy);
+       }
+
+       /**
+        * @return the nonViralNameMatchStrategy
+        * @throws MatchException 
+        */
+       private IMatchStrategy getNonViralNameMatchStrategy() throws MatchException {
+               if(nonViralNameMatchStrategy == null){
+                       nonViralNameMatchStrategy = getDefaultNonViralNameMatchStrategy();
+               }
+               return nonViralNameMatchStrategy;
+       }
+       
+       /**
+        * 
+        * @return
+        * @throws MatchException
+        */
+       public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
+               DefaultMatchStrategy strategy = DefaultMatchStrategy.NewInstance(NonViralName.class);
+               
+               strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
+               strategy.setMatchMode("combinationAuthorTeam", MatchMode.IGNORE);
+               strategy.setMatchMode("exCombinationAuthorTeam", MatchMode.IGNORE);
+               strategy.setMatchMode("basionymAuthorTeam", MatchMode.IGNORE);
+               strategy.setMatchMode("exBasionymAuthorTeam", MatchMode.IGNORE);
+               
+               return strategy;
+       }
+
+       /**
+        * @return the teamOrPersonMatchStrategy
+        */
+       private IMatchStrategy getTeamOrPersonMatchStrategy() throws MatchException{
+               if(teamOrPersonMatchStrategy == null){
+                       teamOrPersonMatchStrategy = getDefaultTeamOrPersonMatchStrategy();
+               }
+               return teamOrPersonMatchStrategy;
+       }
+       
+       /**
+        * 
+        * @return
+        */
+       public static IMatchStrategy getDefaultTeamOrPersonMatchStrategy() throws MatchException{
+               IMatchStrategy strategy = DefaultMatchStrategy.NewInstance(TeamOrPersonBase.class);
+               
+               return strategy;
+       }
+       
+
+       /**
+        * @return the referenceMatchStrategy
+        */
+       private IMatchStrategy getReferenceMatchStrategy() throws MatchException{
+               if(referenceMatchStrategy == null){
+                       referenceMatchStrategy = getDefaultReferenceMatchStrategy();
+               }
+               return referenceMatchStrategy;
+       }
+       
+       public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
+               DefaultMatchStrategy strategy = DefaultMatchStrategy.NewInstance(ReferenceBase.class);
+               
+               return strategy;
+       }
+       
+}