3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.operations
.images
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.IStatus
;
21 import org
.eclipse
.core
.runtime
.Status
;
22 import org
.eclipse
.jface
.window
.Window
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
26 import eu
.etaxonomy
.taxeditor
.editor
.images
.ImagesController
;
27 import eu
.etaxonomy
.taxeditor
.editor
.images
.UrlDialog
;
28 import eu
.etaxonomy
.taxeditor
.operations
.AbstractEditorOperation
;
35 public class AddImageOperation
extends AbstractEditorOperation
{
36 private static final Logger logger
= Logger
37 .getLogger(AddImageOperation
.class);
47 public AddImageOperation(String label
, IUndoContext undoContext
,
49 super(label
, undoContext
, taxon
);
53 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
57 throws ExecutionException
{
59 url
= UrlDialog
.getUrl("Enter image URL", "Enter the new image's URL:");
61 return Status
.CANCEL_STATUS
;
64 ImagesController
.addTaxonImageUrl(taxon
, url
);
66 return redrawOpenEditor();
70 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
76 ImagesController
.addTaxonImageUrl(taxon
, url
);
78 return redrawOpenEditor();
82 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
86 throws ExecutionException
{
88 ImagesController
.removeTaxonImageUrl(taxon
, url
);
90 return redrawOpenEditor();