had to rename the packages to make them compliant with buckminster
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / derivedunit / operation / AddDerivedUnitFacadeMediaOperation.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.bulkeditor.derivedunit.operation;
12
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
19 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
20 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
21 import eu.etaxonomy.cdm.model.description.DescriptionBase;
22 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
23 import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
24 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
25 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
26 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
27
28 /**
29 * @author n.hoffmann
30 * @created Feb 11, 2011
31 * @version 1.0
32 */
33 public class AddDerivedUnitFacadeMediaOperation extends
34 AbstractPostOperation {
35
36 public static final int DERIVED_UNIT_MEDIA = 0;
37 public static final int FIELD_OBJECT_MEDIA = 1;
38
39 private DerivedUnitBase derivedUnit;
40 private int mode;
41
42 /**
43 * @param label
44 * @param undoContext
45 * @param postOperationEnabled
46 */
47 public AddDerivedUnitFacadeMediaOperation(String label, IUndoContext undoContext, DerivedUnitBase derivedUnit,
48 int mode, IPostOperationEnabled postOperationEnabled) {
49 super(label, undoContext, postOperationEnabled);
50
51 this.derivedUnit = derivedUnit;
52 this.mode = mode;
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 @Override
59 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
60 throws ExecutionException {
61 DerivedUnitFacade facade;
62 try {
63 facade = DerivedUnitFacade.NewInstance(derivedUnit);
64
65 createImageGallery(facade);
66 } catch (DerivedUnitFacadeNotSupportedException e) {
67 BulkEditorUtil.error(getClass(), e);
68 }
69
70 return postExecute(derivedUnit);
71 }
72
73
74
75 /**
76 * @param facade
77 * @return
78 */
79 protected void createImageGallery(DerivedUnitFacade facade){
80 if(mode == DERIVED_UNIT_MEDIA){
81 facade.getDerivedUnitImageGallery(true);
82 }
83 else if(mode == FIELD_OBJECT_MEDIA){
84 facade.getFieldObjectImageGallery(true);
85 }
86 else{
87 throw new IllegalArgumentException("Mode not supported: " + mode);
88 }
89 }
90
91 /* (non-Javadoc)
92 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 */
94 @Override
95 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
96 throws ExecutionException {
97 // TODO Auto-generated method stub
98 return null;
99 }
100
101 /* (non-Javadoc)
102 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
103 */
104 @Override
105 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
106 throws ExecutionException {
107 // TODO Auto-generated method stub
108 return null;
109 }
110
111 }