2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.operations
;
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
;
18 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
19 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.taxeditor
.model
.ImagesHelper
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
29 public class MoveImageInListOperation
extends AbstractPostOperation
{
31 private DescriptionElementBase element
;
32 private ImageFile image
;
33 private int direction
;
44 public MoveImageInListOperation(String label
, IUndoContext undoContext
,
45 Taxon taxon
, DescriptionElementBase element
, ImageFile image
,
46 int direction
, IPostOperationEnabled postOperationEnabled
) {
47 super(label
, undoContext
, taxon
, postOperationEnabled
);
49 this.element
= element
;
51 this.direction
= direction
;
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
59 throws ExecutionException
{
61 // Start the main progress monitor.
62 IProgressMonitor newMonitor
= StoreUtil
.startMainMonitor(monitor
,"Moving Image in List", 2);
70 ImagesHelper
.moveImage(element
, image
, direction
);
71 StoreUtil
.isCanceled(newMonitor
, 1);
75 // Stop the progress monitor.
79 return postExecute(image
);
83 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
88 return execute(monitor
, info
);
92 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
95 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
96 throws ExecutionException
{
97 ImagesHelper
.moveImage(element
, image
, direction
* -1);
98 return postExecute(null);