Project

General

Profile

« Previous | Next » 

Revision a345da86

Added by Niels Hoffmann over 14 years ago

moved image functionality into the library

View differences:

.gitattributes
569 569
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java -text
570 570
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/IDataChangeBehavior.java -text
571 571
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java -text
572
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java -text
573 572
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/NameHelper.java -text
574 573
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/NomenclaturalCodeHelper.java -text
575 574
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/Resources.java -text
......
611 610
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveHomotypicalGroupBasionymOperation.java -text
612 611
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveImageFromDescriptionElementOperation.java -text
613 612
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/SwapSynonymAndAcceptedOperation.java -text
613
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java -text
614 614
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java -text
615 615
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/CdmPreferences.java -text
616 616
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/DescriptionPreferences.java -text
.gitignore
13 13
taxeditor-editor/.project
14 14
taxeditor-editor/.settings
15 15
taxeditor-editor/target
16
taxeditor-feature-product/compile.eu.etaxonomy.taxeditor.product.feature.xml
16 17
taxeditor-feature-product/plugin_customization.ini
17 18
taxeditor-feature-product/workspace
18 19
taxeditor-navigation/.classpath
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/DescriptionContentProvider.java
7 7
import org.eclipse.jface.viewers.ITreeContentProvider;
8 8
import org.eclipse.jface.viewers.Viewer;
9 9

  
10
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
10 11
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
11 12
import eu.etaxonomy.cdm.model.description.Feature;
12 13
import eu.etaxonomy.cdm.model.description.TaxonDescription;
13 14
import eu.etaxonomy.cdm.model.taxon.Taxon;
14 15
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
15
import eu.etaxonomy.taxeditor.model.ImagesHelper;
16 16

  
17 17
/**
18 18
 * @author p.ciardelli
......
54 54
		if (parentElement instanceof DescriptionElementBase) {
55 55
			DescriptionElementBase descriptionElement = (DescriptionElementBase) parentElement; 
56 56
			if (descriptionElement.getInDescription().isImageGallery()) {
57
				return ImagesHelper.getOrderedImages(descriptionElement).toArray();
57
				return ImagesUtility.getOrderedImages(descriptionElement).toArray();
58 58
			}
59 59
		}
60 60
		return NO_CHILDREN;
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/DescriptionMasterDetailsBlock.java
34 34
import org.eclipse.ui.forms.widgets.FormToolkit;
35 35
import org.eclipse.ui.forms.widgets.Section;
36 36

  
37
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
37 38
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
38 39
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
39 40
import eu.etaxonomy.cdm.model.description.Distribution;
......
51 52
import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.LabelDetailsPage;
52 53
import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.TaxonInteractionDetailsPage;
53 54
import eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.TextDataDetailsPage;
54
import eu.etaxonomy.taxeditor.model.ImagesHelper;
55 55

  
56 56
/**
57 57
 * @author p.ciardelli
......
209 209
		}
210 210
		if (revealObject instanceof ImageFile) {
211 211
			ImageFile image = (ImageFile) revealObject;
212
			DescriptionElementBase element = ImagesHelper.findImageElement(image, getTaxon());
212
			DescriptionElementBase element = ImagesUtility.findImageElement(image, getTaxon());
213 213
			
214 214
			segments = new Object[3];
215 215
			segments[0] = element.getInDescription();
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/handler/MoveImageDownInListHandler.java
22 22
import org.eclipse.ui.forms.editor.FormEditor;
23 23
import org.eclipse.ui.handlers.HandlerUtil;
24 24

  
25
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
25 26
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
26 27
import eu.etaxonomy.cdm.model.media.ImageFile;
27 28
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 29
import eu.etaxonomy.taxeditor.editor.EditorUtil;
29 30
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
30
import eu.etaxonomy.taxeditor.model.ImagesHelper;
31
import eu.etaxonomy.taxeditor.operations.AddImageToDescriptionElementOperation;
32 31
import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
33 32
import eu.etaxonomy.taxeditor.operations.MoveImageInListOperation;
34 33

  
......
70 69
				try {
71 70
					// TODO use undo context specific to editor
72 71
					operation = new MoveImageInListOperation(event.getCommand().getName(), 
73
							EditorUtil.getUndoContext(), taxon, element, image, ImagesHelper.DOWN, (IPostOperationEnabled) editor);
72
							EditorUtil.getUndoContext(), taxon, element, image, ImagesUtility.DOWN, (IPostOperationEnabled) editor);
74 73
					EditorUtil.executeOperation(operation);
75 74
				} catch (NotDefinedException e) {
76 75
					logger.warn("Command name not set");
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiontree/handler/MoveImageUpInListHandler.java
22 22
import org.eclipse.ui.forms.editor.FormEditor;
23 23
import org.eclipse.ui.handlers.HandlerUtil;
24 24

  
25
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
25 26
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
26 27
import eu.etaxonomy.cdm.model.media.ImageFile;
27 28
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 29
import eu.etaxonomy.taxeditor.editor.EditorUtil;
29 30
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
30
import eu.etaxonomy.taxeditor.model.ImagesHelper;
31 31
import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
32 32
import eu.etaxonomy.taxeditor.operations.MoveImageInListOperation;
33 33

  
......
69 69
				try {
70 70
					// TODO use undo context specific to editor
71 71
					operation = new MoveImageInListOperation(event.getCommand().getName(), 
72
							EditorUtil.getUndoContext(), taxon, element, image, ImagesHelper.UP, (IPostOperationEnabled) editor);
72
							EditorUtil.getUndoContext(), taxon, element, image, ImagesUtility.UP, (IPostOperationEnabled) editor);
73 73
					EditorUtil.executeOperation(operation);
74 74
				} catch (NotDefinedException e) {
75 75
					logger.warn("Command name not set");
taxeditor-store/plugin.xml
324 324
      <wizard
325 325
            category="eu.etaxonomy.taxeditor.import.category.cdm"
326 326
            class="eu.etaxonomy.taxeditor.io.wizard.JaxbImportWizard"
327
            id="eu.etaxonomy.taxeditor.io.import.excel"
327
            id="eu.etaxonomy.taxeditor.io.import.jaxb"
328 328
            name="JAXB">
329 329
      </wizard>
330 330
      <category
331 331
            id="eu.etaxonomy.taxeditor.import.category.excel"
332
            name="Excel">
332
            name="Excel"
333
            parentCategory="eu.etaxonomy.taxeditor.import.category.cdm">
333 334
      </category>
334 335
      <wizard
335 336
            category="eu.etaxonomy.taxeditor.import.category.cdm"
......
344 345
            name="Endnote">
345 346
      </wizard>
346 347
      <wizard
347
            category="eu.etaxonomy.taxeditor.import.category.cdm"
348
            category="eu.etaxonomy.taxeditor.import.category.excel"
348 349
            class="eu.etaxonomy.taxeditor.io.wizard.ExcelNormalExplicitTaxaImportWizard"
349 350
            id="eu.etaxonomy.taxeditor.io.import.excel.taxa"
350 351
            name="Excel Normal Explicit Taxa">
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesHelper.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.model;
12

  
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.HashSet;
16
import java.util.List;
17
import java.util.Set;
18

  
19
import org.apache.log4j.Logger;
20

  
21
import eu.etaxonomy.cdm.model.description.DescriptionBase;
22
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
23
import eu.etaxonomy.cdm.model.description.Feature;
24
import eu.etaxonomy.cdm.model.description.TaxonDescription;
25
import eu.etaxonomy.cdm.model.description.TextData;
26
import eu.etaxonomy.cdm.model.media.ImageFile;
27
import eu.etaxonomy.cdm.model.media.Media;
28
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
29
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
30
import eu.etaxonomy.cdm.model.media.ReferencedMedia;
31
import eu.etaxonomy.cdm.model.taxon.Taxon;
32

  
33
/**
34
 * @author p.ciardelli
35
 * @created 31.03.2009
36
 * @version 1.0
37
 * 
38
 * This has to be moved to library at some point. Unfortunately, the whole handling of images
39
 * is very half heartedly implemented in the library. We will not mark this here as depreciated 
40
 * until the situation in the library improves. 
41
 * 
42
 */
43
public class ImagesHelper {
44
	private static final Logger logger = Logger
45
			.getLogger(ImagesHelper.class);
46
	
47
	/**
48
	 * Quick and dirty method to get an element's first image file.
49
	 * 
50
	 * @param element
51
	 * @return
52
	 */
53
	public static ImageFile getImage(DescriptionElementBase element) {
54
		List<Media> medias = element.getMedia();
55
		
56
		for(Media media : medias){
57
			Set<MediaRepresentation> representations = media.getRepresentations();
58
			
59
			for(MediaRepresentation representation : representations){
60
				List<MediaRepresentationPart> parts = representation.getParts();
61
				
62
				for (MediaRepresentationPart part : parts){
63
					if(part instanceof ImageFile){
64
						return (ImageFile) part;
65
					}
66
				}
67
			}							
68
		}
69
		return null;
70
	}
71
	
72
	public static List<ImageFile> getOrderedImages(DescriptionElementBase element){
73
		List<ImageFile> imageList = new ArrayList<ImageFile>();
74
		MediaRepresentation representation = getImageMediaRepresentation(element);
75
		if (representation != null) {
76
			for (MediaRepresentationPart part : representation.getParts()){
77
				if(!(part instanceof ImageFile)){
78
					throw new RuntimeException("Your database contains media that mix Image Files with non-Image Files.");
79
				} else {
80
					imageList.add((ImageFile) part);
81
				}
82
			}
83
		}
84
		return imageList;
85
	}
86
		
87
	/**
88
	 * Returns the first Representation with images. If none is found, a
89
	 * Representation for storing images is created and returned.
90
	 * 
91
	 * @param element
92
	 * @return
93
	 */
94
	private static MediaRepresentation getImageMediaRepresentation(DescriptionElementBase element) {
95
		// Drill down until a representation with images is found
96
		for(Media media : element.getMedia()){
97
			Set<MediaRepresentation> representations = media.getRepresentations();
98
			for(MediaRepresentation representation : representations){
99
				List<MediaRepresentationPart> parts = representation.getParts();
100
				for (MediaRepresentationPart part : parts){
101
					if(part instanceof ImageFile){
102
						return representation;
103
					}
104
				}
105
			}							
106
		}		
107
		// No representation with images found - create
108
		MediaRepresentation representation = MediaRepresentation.NewInstance();
109
		Media media = ReferencedMedia.NewInstance();
110
		element.addMedia(media);
111
		media.addRepresentation(representation);
112
		return representation;
113
	}
114
	
115
	/**
116
	 * @param description
117
	 * @return
118
	 */
119
	public static Set<ImageFile> getImages(TaxonDescription description){
120
		Set<ImageFile> images = new HashSet<ImageFile>();
121
		
122
		for (DescriptionElementBase element : description.getElements()){
123
			
124
			Feature feature = element.getFeature();
125
			
126
			if(feature.equals(Feature.IMAGE())){
127
				List<Media> medias = element.getMedia();
128
				
129
				for(Media media : medias){
130
					Set<MediaRepresentation> representations = media.getRepresentations();
131
					
132
					for(MediaRepresentation representation : representations){
133
						List<MediaRepresentationPart> parts = representation.getParts();
134
						
135
						for (MediaRepresentationPart part : parts){
136
							if(part instanceof ImageFile){
137
								images.add((ImageFile) part);
138
							}
139
						}
140
					}							
141
				}										
142
			}
143
		}
144
		
145
		return images;
146
	}
147

  
148
	/**
149
	 * @param taxon
150
	 * @param imageFile
151
	 */
152
	public static void addTaxonImage(Taxon taxon, DescriptionBase<?> imageGallery, ImageFile imageFile) {
153
				
154
		imageGallery.addElement(createImageElement(imageFile));
155
		
156
	}
157
	
158
	public static DescriptionElementBase createImageElement(ImageFile imageFile) {
159
		
160
		DescriptionElementBase descriptionElement = TextData.NewInstance(Feature.IMAGE());
161
		
162
		Media media = Media.NewInstance();
163
		MediaRepresentation representation = MediaRepresentation.NewInstance();
164
		
165
		representation.addRepresentationPart(imageFile);
166
		
167
		media.addRepresentation(representation);
168
		
169
		descriptionElement.addMedia(media);
170
		
171
		return descriptionElement;
172
		
173
	}
174
	
175
	/**
176
	 * Adds a new, empty image file to the end of a description element's
177
	 * ordered list of images.
178
	 * 
179
	 * @param element
180
	 * @return 
181
	 */
182
	public static ImageFile addImagePart(DescriptionElementBase element) {
183
		ImageFile imageFile = ImageFile.NewInstance(null, null);
184
		getImageMediaRepresentation(element).addRepresentationPart(imageFile);
185
		return imageFile;
186
	}
187
	
188
	/**
189
	 * @param taxon
190
	 * @param imageFile
191
	 */
192
	public static void removeTaxonImage(Taxon taxon, DescriptionBase<?> imageGallery, ImageFile imageFile) {
193
		Set<DescriptionElementBase> descriptionElementsToRemove = new HashSet<DescriptionElementBase>();
194
		Set<MediaRepresentationPart> representationPartsToRemove = new HashSet<MediaRepresentationPart>();
195
		
196
		Set<DescriptionElementBase> images = imageGallery.getElements();
197
		
198
		// overmodelling of media in cdmlib makes this a little bit complicated
199
		for(DescriptionElementBase descriptionElement : images){
200
			for(Media media : descriptionElement.getMedia()){
201
				for(MediaRepresentation representation : media.getRepresentations()){
202
					for(MediaRepresentationPart part : representation.getParts()){
203
						if(part.equals(imageFile)){
204
							// because of concurrent modification, we just collect the parts to remove 
205
							representationPartsToRemove.add(part);
206
						}
207
					}
208

  
209
					// and then remove the representation parts here
210
					for (MediaRepresentationPart part : representationPartsToRemove){
211
						representation.removeRepresentationPart(part);
212
					}
213
					// clear set for next run
214
					representationPartsToRemove.clear();
215
					
216
					// description elements with empty representations should be deleted as well
217
					if(representation.getParts().size() == 0){
218
						descriptionElementsToRemove.add(descriptionElement);
219
					}
220
				}
221
			}
222
		}	
223
		
224
		// remove the empty description elements
225
		for(DescriptionElementBase descriptionElement : descriptionElementsToRemove){
226
			imageGallery.removeElement(descriptionElement);
227
		}		
228
	}
229

  
230
	public static final int UP = 1;
231
	public static final int DOWN = -1;
232
	
233
	/**
234
	 * @param input
235
	 * @param selectedImage
236
	 * @param direction
237
	 */
238
	public static void moveImage(DescriptionElementBase element, ImageFile image,
239
			int direction) {
240
		
241
		MediaRepresentation representation = getImageMediaRepresentation(element);
242
		int index = representation.getParts().indexOf(image);
243
		if (index == -1) {
244
			return;
245
		}		
246
		if (direction == UP && index != 0) {
247
			Collections.swap(representation.getParts(), index, index - 1);
248
		}
249
		if (direction == DOWN && index < representation.getParts().size() - 1) {
250
			Collections.swap(representation.getParts(), index, index + 1);
251
		}
252
	}
253

  
254
	/**
255
	 * @param input
256
	 * @param selectedImage
257
	 */
258
	public static void removeImage(DescriptionElementBase element, ImageFile image) {
259
		getImageMediaRepresentation(element).getParts().remove(image);
260
	}
261

  
262
	/**
263
	 * Iterate through all taxon's image galleries until the descriptive element containing
264
	 * the ImageFile is found.
265
	 * 
266
	 * @param image
267
	 * @param taxon 
268
	 * @return 
269
	 */
270
	public static DescriptionElementBase findImageElement(ImageFile image, Taxon taxon) {
271
		if (taxon == null) {
272
			return null;
273
		}
274
		for (TaxonDescription description : taxon.getDescriptions()) {
275
			if (description.isImageGallery()) {
276
				for (DescriptionElementBase element : description.getElements()) {
277
					if (getOrderedImages(element).contains(image)) {
278
						return element;
279
					}
280
				}
281
			}
282
		}
283
		return null;		
284
	}
285
}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AddImageToDescriptionElementOperation.java
14 14
import org.eclipse.core.runtime.IAdaptable;
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.OperationCanceledException;
18 17

  
18
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
19 19
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
20 20
import eu.etaxonomy.cdm.model.media.ImageFile;
21 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.model.ImagesHelper;
23 22
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 23

  
25 24
/**
......
63 62

  
64 63
        try {
65 64
        	// Operation steps
66
			image = ImagesHelper.addImagePart(element);
65
			image = ImagesUtility.addImagePart(element);
67 66
			StoreUtil.isCanceled(newMonitor, 1);
68 67
        }
69 68
        finally {
......
90 89
	@Override
91 90
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
92 91
			throws ExecutionException {
93
		ImagesHelper.removeImage(element, image);
92
		ImagesUtility.removeImage(element, image);
94 93
		return postExecute(element);
95 94
	}
96 95
}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateDescriptionElementOperation.java
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17 17

  
18
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
18 19
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
19 20
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
20 21
import eu.etaxonomy.cdm.model.description.Distribution;
......
24 25
import eu.etaxonomy.cdm.model.description.TextData;
25 26
import eu.etaxonomy.cdm.model.media.ImageFile;
26 27
import eu.etaxonomy.cdm.model.taxon.Taxon;
27
import eu.etaxonomy.taxeditor.model.ImagesHelper;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29 28
import eu.etaxonomy.taxeditor.store.StoreUtil;
30 29

  
31 30
/**
......
88 87
				} else if (feature.isSupportsDistribution()) {
89 88
					element = Distribution.NewInstance();
90 89
				} else if (feature.equals(Feature.IMAGE())){
91
					element = ImagesHelper.createImageElement(ImageFile.NewInstance(null, null));
90
					element = ImagesUtility.createImageElement(ImageFile.NewInstance(null, null));
92 91
				} else if(feature.isSupportsTaxonInteraction()){
93 92
					element = TaxonInteraction.NewInstance(feature);
94 93
				} else {
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/CreateImageOperation.java
16 16
import org.eclipse.core.runtime.IProgressMonitor;
17 17
import org.eclipse.core.runtime.IStatus;
18 18

  
19
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
19 20
import eu.etaxonomy.cdm.model.description.DescriptionBase;
20 21
import eu.etaxonomy.cdm.model.media.ImageFile;
21 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.model.ImagesHelper;
23 23
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 24

  
25 25
/**
......
73 73
			}
74 74
			StoreUtil.isCanceled(newMonitor, 1);
75 75

  
76
			ImagesHelper.addTaxonImage(taxon, description, imageFile);
76
			ImagesUtility.addTaxonImage(taxon, description, imageFile);
77 77
			StoreUtil.isCanceled(newMonitor, 1);
78 78
        }
79 79
        finally {
......
92 92
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
93 93
			throws ExecutionException {
94 94
		
95
		ImagesHelper.addTaxonImage(taxon, description, imageFile);
95
		ImagesUtility.addTaxonImage(taxon, description, imageFile);
96 96
		
97 97
		return postExecute(imageFile);
98 98
	}
......
104 104
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
105 105
			throws ExecutionException {
106 106
		
107
		ImagesHelper.removeTaxonImage(taxon, description, imageFile);
107
		ImagesUtility.removeTaxonImage(taxon, description, imageFile);
108 108
		
109 109
		return postExecute(null);
110 110
	}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/DeleteImageOperation.java
16 16
import org.eclipse.core.runtime.IProgressMonitor;
17 17
import org.eclipse.core.runtime.IStatus;
18 18

  
19
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
19 20
import eu.etaxonomy.cdm.model.description.DescriptionBase;
20 21
import eu.etaxonomy.cdm.model.media.ImageFile;
21 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.model.ImagesHelper;
23 23
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 24

  
25 25
/**
......
63 63
        try {
64 64
        	// Operation steps
65 65

  
66
        	ImagesHelper.removeTaxonImage(taxon, description, imageFile);
66
        	ImagesUtility.removeTaxonImage(taxon, description, imageFile);
67 67
			StoreUtil.isCanceled(newMonitor, 1);
68 68
        }
69 69
        finally {
......
91 91
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
92 92
			throws ExecutionException {
93 93
		
94
		ImagesHelper.addTaxonImage(taxon, description, imageFile);
94
		ImagesUtility.addTaxonImage(taxon, description, imageFile);
95 95
		
96 96
		return postExecute(null);
97 97
	}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveImageInListOperation.java
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17 17

  
18
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
18 19
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
19 20
import eu.etaxonomy.cdm.model.media.ImageFile;
20 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.taxeditor.model.ImagesHelper;
22 22
import eu.etaxonomy.taxeditor.store.StoreUtil;
23 23

  
24 24
/**
......
67 67
        try {
68 68
        	// Operation steps
69 69
	
70
			ImagesHelper.moveImage(element, image, direction);
70
        	ImagesUtility.moveImage(element, image, direction);
71 71
			StoreUtil.isCanceled(newMonitor, 1);
72 72
        }
73 73
        finally {
......
94 94
	@Override
95 95
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
96 96
			throws ExecutionException {
97
		ImagesHelper.moveImage(element, image, direction * -1);
97
		ImagesUtility.moveImage(element, image, direction * -1);
98 98
		return postExecute(null);
99 99
	}
100 100
}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveImageFromDescriptionElementOperation.java
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17 17

  
18
import eu.etaxonomy.cdm.api.utility.ImagesUtility;
18 19
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
19 20
import eu.etaxonomy.cdm.model.media.ImageFile;
20 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.taxeditor.model.ImagesHelper;
22 22
import eu.etaxonomy.taxeditor.store.StoreUtil;
23 23

  
24 24
/**
......
64 64
        try {
65 65
        	// Operation steps
66 66
	
67
			ImagesHelper.removeImage(element, image);
67
			ImagesUtility.removeImage(element, image);
68 68
			StoreUtil.isCanceled(newMonitor, 1);
69 69
        }
70 70
        finally {
......
91 91
	@Override
92 92
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
93 93
			throws ExecutionException {
94
		image = ImagesHelper.addImagePart(element);
94
		image = ImagesUtility.addImagePart(element);
95 95
		return postExecute(image);
96 96
	}
97 97
}
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.parser;
12

  
13
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
14
import eu.etaxonomy.cdm.model.name.NonViralName;
15
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
16
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
17
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
18
import eu.etaxonomy.cdm.strategy.match.MatchException;
19
import eu.etaxonomy.cdm.strategy.match.MatchMode;
20

  
21
/**
22
 * This class defines the MatchStrategies that will be used by the ParseHandler.
23
 * 
24
 * @author n.hoffmann
25
 * @created Jan 22, 2010
26
 * @version 1.0
27
 */
28
public class MatchStrategyConfigurator {
29
	
30
	/**
31
	 * Singleton instance
32
	 */
33
	private static MatchStrategyConfigurator instance = new MatchStrategyConfigurator();
34
	
35
	private IMatchStrategy nonViralNameMatchStrategy;
36
	private IMatchStrategy teamOrPersonMatchStrategy;
37
	private IMatchStrategy referenceMatchStrategy;
38
	
39
	/**
40
	 * 
41
	 * @return
42
	 * @throws MatchException
43
	 */
44
	public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
45
		return instance.getNonViralNameMatchStrategy();
46
	}
47
	
48
	/**
49
	 * 
50
	 * @return
51
	 * @throws MatchException
52
	 */
53
	public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
54
		return instance.getTeamOrPersonMatchStrategy();
55
	}
56
	
57
	/**
58
	 * 
59
	 * @return
60
	 * @throws MatchException
61
	 */
62
	public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
63
		return instance.getReferenceMatchStrategy();
64
	}
65

  
66
	/**
67
	 * @param strategy the nonViralNameMatchStrategy to set
68
	 */
69
	private void doSetNonViralNameMatchStrategy(IMatchStrategy strategy) {
70
		this.nonViralNameMatchStrategy = strategy;
71
	}
72
	
73
	/**
74
	 * @param strategy the nonViralNameMatchStrategy to set
75
	 */
76
	public static void setNonViralNameMatchStrategy(IMatchStrategy strategy) {
77
		instance.doSetNonViralNameMatchStrategy(strategy);
78
	}
79
	
80
	/**
81
	 * @param strategy the teamOrPersonMatchStrategy to set
82
	 */
83
	private void doSetTeamOrPersonMatchStrategy(IMatchStrategy strategy) {
84
		this.teamOrPersonMatchStrategy = strategy;
85
	}
86

  
87
	/**
88
	 * @param strategy the teamOrPersonMatchStrategy to set
89
	 */
90
	public static void setTeamOrPersonMatchStrategy(IMatchStrategy strategy) {
91
		instance.doSetTeamOrPersonMatchStrategy(strategy);
92
	}
93

  
94
	/**
95
	 * @param strategy the referenceMatchStrategy to set
96
	 */
97
	private void doSetReferenceMatchStrategy(IMatchStrategy strategy) {
98
		this.referenceMatchStrategy = strategy;
99
	}
100
	
101
	/**
102
	 * @param strategy the referenceMatchStrategy to set
103
	 */
104
	public static void setReferenceMatchStrategy(IMatchStrategy strategy) {
105
		instance.doSetReferenceMatchStrategy(strategy);
106
	}
107

  
108
	/**
109
	 * @return the nonViralNameMatchStrategy
110
	 * @throws MatchException 
111
	 */
112
	private IMatchStrategy getNonViralNameMatchStrategy() throws MatchException {
113
		if(nonViralNameMatchStrategy == null){
114
			nonViralNameMatchStrategy = getDefaultNonViralNameMatchStrategy();
115
		}
116
		return nonViralNameMatchStrategy;
117
	}
118
	
119
	/**
120
	 * 
121
	 * @return
122
	 * @throws MatchException
123
	 */
124
	public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
125
		DefaultMatchStrategy strategy = DefaultMatchStrategy.NewInstance(NonViralName.class);
126
		
127
		strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
128
		strategy.setMatchMode("combinationAuthorTeam", MatchMode.IGNORE);
129
		strategy.setMatchMode("exCombinationAuthorTeam", MatchMode.IGNORE);
130
		strategy.setMatchMode("basionymAuthorTeam", MatchMode.IGNORE);
131
		strategy.setMatchMode("exBasionymAuthorTeam", MatchMode.IGNORE);
132
		
133
		return strategy;
134
	}
135

  
136
	/**
137
	 * @return the teamOrPersonMatchStrategy
138
	 */
139
	private IMatchStrategy getTeamOrPersonMatchStrategy() throws MatchException{
140
		if(teamOrPersonMatchStrategy == null){
141
			teamOrPersonMatchStrategy = getDefaultTeamOrPersonMatchStrategy();
142
		}
143
		return teamOrPersonMatchStrategy;
144
	}
145
	
146
	/**
147
	 * 
148
	 * @return
149
	 */
150
	public static IMatchStrategy getDefaultTeamOrPersonMatchStrategy() throws MatchException{
151
		IMatchStrategy strategy = DefaultMatchStrategy.NewInstance(TeamOrPersonBase.class);
152
		
153
		return strategy;
154
	}
155
	
156

  
157
	/**
158
	 * @return the referenceMatchStrategy
159
	 */
160
	private IMatchStrategy getReferenceMatchStrategy() throws MatchException{
161
		if(referenceMatchStrategy == null){
162
			referenceMatchStrategy = getDefaultReferenceMatchStrategy();
163
		}
164
		return referenceMatchStrategy;
165
	}
166
	
167
	public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
168
		DefaultMatchStrategy strategy = DefaultMatchStrategy.NewInstance(ReferenceBase.class);
169
		
170
		return strategy;
171
	}
172
	
173
}

Also available in: Unified diff