Project

General

Profile

« Previous | Next » 

Revision 3be6ef3e

Added by Niels Hoffmann over 13 years ago

performed javacscript:fix and worked on documentation

View differences:

taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/RemoveImageFromDescriptionElementOperation.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.DescriptionElementBase;
20
import eu.etaxonomy.cdm.model.media.ImageFile;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22

  
23
/**
24
 * @author p.ciardelli
25
 * @created 05.02.2009
26
 * @version 1.0
27
 * @author n.hoffmann
28
 */
29
public class RemoveImageFromDescriptionElementOperation extends AbstractPostOperation {
30
	
31
	private DescriptionElementBase element;
32
	private ImageFile image;
33

  
34
	/**
35
	 * @param name
36
	 * @param undoContext
37
	 * @param taxon
38
	 * @param element
39
	 * @param postOperationEnabled
40
	 */
41
	public RemoveImageFromDescriptionElementOperation(String label,
42
			IUndoContext undoContext, Taxon taxon, ImageFile image,
43
			DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
44
		super(label, undoContext, taxon, postOperationEnabled);
45
		
46
		this.image = image;
47
		this.element = element;
48
	}
49

  
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
52
	 */
53
	@Override
54
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
55
			throws ExecutionException {
56

  
57
		monitor.worked(20);
58
		ImagesUtility.removeImage(element, image);
59
		monitor.worked(40);
60

  
61
		return postExecute(element);
62
	}
63

  
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66
	 */
67
	@Override
68
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
69
			throws ExecutionException {
70
		return execute(monitor, info);
71
	}
72

  
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75
	 */
76
	@Override
77
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
78
			throws ExecutionException {
79
		image = ImagesUtility.addImagePart(element);
80
		return postExecute(image);
81
	}
82
}
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.DescriptionElementBase;
20
import eu.etaxonomy.cdm.model.media.ImageFile;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22

  
23
/**
24
 * <p>RemoveImageFromDescriptionElementOperation class.</p>
25
 *
26
 * @author p.ciardelli
27
 * @author n.hoffmann
28
 * @created 05.02.2009
29
 * @version 1.0
30
 */
31
public class RemoveImageFromDescriptionElementOperation extends AbstractPostOperation {
32
	
33
	private DescriptionElementBase element;
34
	private ImageFile image;
35

  
36
	/**
37
	 * <p>Constructor for RemoveImageFromDescriptionElementOperation.</p>
38
	 *
39
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
40
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
41
	 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
42
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
43
	 * @param label a {@link java.lang.String} object.
44
	 * @param image a {@link eu.etaxonomy.cdm.model.media.ImageFile} object.
45
	 */
46
	public RemoveImageFromDescriptionElementOperation(String label,
47
			IUndoContext undoContext, Taxon taxon, ImageFile image,
48
			DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
49
		super(label, undoContext, taxon, postOperationEnabled);
50
		
51
		this.image = image;
52
		this.element = element;
53
	}
54

  
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
57
	 */
58
	/** {@inheritDoc} */
59
	@Override
60
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
61
			throws ExecutionException {
62

  
63
		monitor.worked(20);
64
		ImagesUtility.removeImage(element, image);
65
		monitor.worked(40);
66

  
67
		return postExecute(element);
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
		image = ImagesUtility.addImagePart(element);
88
		return postExecute(image);
89
	}
90
}

Also available in: Unified diff