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.store.operations;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.core.commands.ExecutionException;
|
15
|
import org.eclipse.core.commands.operations.IUndoContext;
|
16
|
import org.eclipse.core.runtime.IAdaptable;
|
17
|
import org.eclipse.core.runtime.IProgressMonitor;
|
18
|
import org.eclipse.core.runtime.IStatus;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
21
|
import eu.etaxonomy.cdm.model.media.ImageFile;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
23
|
import eu.etaxonomy.taxeditor.store.model.ImagesUtil;
|
24
|
|
25
|
/**
|
26
|
* @author p.ciardelli
|
27
|
* @created 31.03.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class CreateImageOperation extends AbstractPostOperation {
|
31
|
private static final Logger logger = Logger
|
32
|
.getLogger(CreateImageOperation.class);
|
33
|
|
34
|
private ImageFile imageFile;
|
35
|
|
36
|
private DescriptionBase description;
|
37
|
|
38
|
/**
|
39
|
* @param text
|
40
|
* @param undoContext
|
41
|
* @param taxon
|
42
|
* @param url
|
43
|
*/
|
44
|
public CreateImageOperation(String label, IUndoContext undoContext,
|
45
|
Taxon taxon, DescriptionBase description, ImageFile imageFile, IPostOperationEnabled postOperationEnabled) {
|
46
|
super(label, undoContext, taxon, postOperationEnabled);
|
47
|
this.imageFile = imageFile;
|
48
|
this.description = description;
|
49
|
}
|
50
|
|
51
|
/* (non-Javadoc)
|
52
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
53
|
*/
|
54
|
@Override
|
55
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
56
|
throws ExecutionException {
|
57
|
|
58
|
ImagesUtil.addTaxonImage(taxon, description, imageFile);
|
59
|
|
60
|
return postExecute(null);
|
61
|
}
|
62
|
|
63
|
/* (non-Javadoc)
|
64
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
65
|
*/
|
66
|
@Override
|
67
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
68
|
throws ExecutionException {
|
69
|
|
70
|
ImagesUtil.addTaxonImage(taxon, description, imageFile);
|
71
|
|
72
|
return postExecute(null);
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
77
|
*/
|
78
|
@Override
|
79
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
80
|
throws ExecutionException {
|
81
|
|
82
|
ImagesUtil.removeTaxonImage(taxon, description, imageFile);
|
83
|
|
84
|
return postExecute(null);
|
85
|
}
|
86
|
|
87
|
|
88
|
}
|