Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/AddMediaToImageGalleryOperation.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.operations; |
|
11 |
|
|
12 |
import org.eclipse.core.commands.ExecutionException; |
|
13 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
14 |
import org.eclipse.core.runtime.IAdaptable; |
|
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
16 |
import org.eclipse.core.runtime.IStatus; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.utility.ImagesUtility; |
|
19 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
20 |
import eu.etaxonomy.cdm.model.media.Media; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
22 |
/** |
|
23 |
* @author p.ciardelli |
|
24 |
* @created 05.02.2009 |
|
25 |
* @version 1.0 |
|
26 |
* @author n.hoffmann |
|
27 |
*/ |
|
28 |
public class AddMediaToImageGalleryOperation extends AbstractPostOperation { |
|
29 |
|
|
30 |
private DescriptionBase description; |
|
31 |
private Media media; |
|
32 |
|
|
33 |
/** |
|
34 |
* @param name |
|
35 |
* @param undoContext |
|
36 |
* @param taxon |
|
37 |
* @param element |
|
38 |
* @param postOperationEnabled |
|
39 |
*/ |
|
40 |
public AddMediaToImageGalleryOperation(String label, |
|
41 |
IUndoContext undoContext, Taxon taxon, |
|
42 |
DescriptionBase description, IPostOperationEnabled postOperationEnabled) { |
|
43 |
super(label, undoContext, taxon, postOperationEnabled); |
|
44 |
|
|
45 |
this.description = description; |
|
46 |
media = Media.NewInstance(); |
|
47 |
} |
|
48 |
|
|
49 |
/* (non-Javadoc) |
|
50 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
51 |
*/ |
|
52 |
@Override |
|
53 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
54 |
throws ExecutionException { |
|
55 |
|
|
56 |
monitor.worked(20); |
|
57 |
|
|
58 |
ImagesUtility.addMediaToGallery(description, media); |
|
59 |
|
|
60 |
monitor.worked(40); |
|
61 |
|
|
62 |
return postExecute(media); |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
70 |
throws ExecutionException { |
|
71 |
return execute(monitor, info); |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
76 |
*/ |
|
77 |
@Override |
|
78 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
79 |
throws ExecutionException { |
|
80 |
ImagesUtility.removeMediaFromGallery(description, media); |
|
81 |
return postExecute(description); |
|
82 |
} |
|
83 |
} |
|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.operations; |
|
11 |
|
|
12 |
import org.eclipse.core.commands.ExecutionException; |
|
13 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
14 |
import org.eclipse.core.runtime.IAdaptable; |
|
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
16 |
import org.eclipse.core.runtime.IStatus; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.utility.ImagesUtility; |
|
19 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
20 |
import eu.etaxonomy.cdm.model.media.Media; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
22 |
/** |
|
23 |
* <p>AddMediaToImageGalleryOperation class.</p> |
|
24 |
* |
|
25 |
* @author p.ciardelli |
|
26 |
* @author n.hoffmann |
|
27 |
* @created 05.02.2009 |
|
28 |
* @version 1.0 |
|
29 |
*/ |
|
30 |
public class AddMediaToImageGalleryOperation extends AbstractPostOperation { |
|
31 |
|
|
32 |
private DescriptionBase description; |
|
33 |
private Media media; |
|
34 |
|
|
35 |
/** |
|
36 |
* <p>Constructor for AddMediaToImageGalleryOperation.</p> |
|
37 |
* |
|
38 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
39 |
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. |
|
40 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object. |
|
41 |
* @param label a {@link java.lang.String} object. |
|
42 |
* @param description a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object. |
|
43 |
*/ |
|
44 |
public AddMediaToImageGalleryOperation(String label, |
|
45 |
IUndoContext undoContext, Taxon taxon, |
|
46 |
DescriptionBase description, IPostOperationEnabled postOperationEnabled) { |
|
47 |
super(label, undoContext, taxon, postOperationEnabled); |
|
48 |
|
|
49 |
this.description = description; |
|
50 |
media = Media.NewInstance(); |
|
51 |
} |
|
52 |
|
|
53 |
/* (non-Javadoc) |
|
54 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
55 |
*/ |
|
56 |
/** {@inheritDoc} */ |
|
57 |
@Override |
|
58 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
59 |
throws ExecutionException { |
|
60 |
|
|
61 |
monitor.worked(20); |
|
62 |
|
|
63 |
ImagesUtility.addMediaToGallery(description, media); |
|
64 |
|
|
65 |
monitor.worked(40); |
|
66 |
|
|
67 |
return postExecute(media); |
|
68 |
} |
|
69 |
|
|
70 |
/* (non-Javadoc) |
|
71 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
72 |
*/ |
|
73 |
/** {@inheritDoc} */ |
|
74 |
@Override |
|
75 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
76 |
throws ExecutionException { |
|
77 |
return execute(monitor, info); |
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
82 |
*/ |
|
83 |
/** {@inheritDoc} */ |
|
84 |
@Override |
|
85 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
86 |
throws ExecutionException { |
|
87 |
ImagesUtility.removeMediaFromGallery(description, media); |
|
88 |
return postExecute(description); |
|
89 |
} |
|
90 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation