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
.editor
.view
.descriptive
.operation
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
20 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
21 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
22 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
23 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
24 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
25 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
26 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
27 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
28 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
32 * @created Feb 11, 2011
35 public class AddDerivedUnitFacadeMediaOperation
extends AbstractPostTaxonOperation
{
37 private final SpecimenOrObservationBase
<?
> specimen
;
42 * @param postOperationEnabled
44 public AddDerivedUnitFacadeMediaOperation(String label
, IUndoContext undoContext
, SpecimenOrObservationBase
<?
> specimen
,
45 IPostOperationEnabled postOperationEnabled
) {
46 super(label
, undoContext
, postOperationEnabled
);
48 this.specimen
= specimen
;
52 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
55 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
56 DerivedUnitFacade facade
;
58 if(specimen
instanceof FieldUnit
){
59 facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.FieldUnit
, (FieldUnit
) specimen
);
60 if(facade
.hasFieldObjectImageGallery()){
61 MessagingUtils
.informationDialog("Image gallery creation failed", "Only one image gallery is possible.");
62 return Status
.CANCEL_STATUS
;
65 facade
.getFieldObjectImageGallery(true);
68 else if(specimen
instanceof DerivedUnit
){
69 facade
= DerivedUnitFacade
.NewInstance((DerivedUnit
)specimen
);
70 if(facade
.hasDerivedUnitImageGallery()){
71 MessagingUtils
.informationDialog("Image gallery creation failed", "Only one image gallery is possible.");
72 return Status
.CANCEL_STATUS
;
75 facade
.getDerivedUnitImageGallery(true);
78 } catch (DerivedUnitFacadeNotSupportedException e
) {
79 MessagingUtils
.error(getClass(), e
);
82 return postExecute(specimen
);
87 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 // TODO Auto-generated method stub
97 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
100 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
101 throws ExecutionException
{
102 // TODO Auto-generated method stub