Project

General

Profile

« Previous | Next » 

Revision c43d0839

Added by Patrick Plitzner over 9 years ago

#4389

  • unified "New Image Gallery" command and handler for TaxonEditor and BulkEditor
  • Removed "Add Derived/Field Unit Media" command
  • added interface IPartContentHasMedia to specify that the MediaView should react to selection changes of implementers

View differences:

.gitattributes
86 86
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicMarkerTypeEditingMenu.java -text
87 87
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java -text
88 88
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/OpenBulkEditorContributionItem.java -text
89
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AbstractAddDerivedUnitFacadeMediaHandler.java -text
90
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AddDerivedUnitMediaHandler.java -text
91
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AddFieldObjectMediaHandler.java -text
92
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/operation/AddDerivedUnitFacadeMediaOperation.java -text
93 89
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java -text
94 90
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/MergeGroupHandler.java -text
95 91
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/OpenBulkEditorHandler.java -text
......
560 556
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DynamicFeatureMenu.java -text
561 557
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java -text
562 558
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java -text
559
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/AddDerivedUnitFacadeMediaOperation.java -text
563 560
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateDescriptionElementOperation.java -text
564 561
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateSpecimenDescriptionOperation.java -text
565 562
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/CreateTaxonDescriptionOperation.java -text
......
1272 1269
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartChangeListener.java -text
1273 1270
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasDetails.java -text
1274 1271
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasFactualData.java -text
1272
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.java -text
1275 1273
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasSupplementalData.java -text
1276 1274
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java -text
1277 1275
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/LineSelection.java -text
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
138 138
               style="push">
139 139
         </command>
140 140
      </menuContribution>
141
      <menuContribution
142
            allPopups="false"
143
            locationURI="popup:eu.etaxonomy.taxeditor.editor.view.media">
144
         <command
145
               commandId="eu.etaxonomy.taxeditor.bulkeditor.command.derivedunit.addDerivedUnitMedia"
146
               label="Add Derived Unit Media"
147
               style="push">
148
            <visibleWhen>
149
               <not>
150
                  <reference
151
                        definitionId="isTaxonEditor">
152
                  </reference>
153
               </not>
154
            </visibleWhen>
155
         </command>
156
         <command
157
               commandId="eu.etaxonomy.taxeditor.bulkeditor.command.derivedunit.addFieldObjectMedia"
158
               label="Add Field Object Media"
159
               style="push">
160
            <visibleWhen>
161
               <not>
162
                  <reference
163
                        definitionId="isTaxonEditor">
164
                  </reference>
165
               </not>
166
            </visibleWhen>
167
         </command>
168
      </menuContribution>
169 141
      <menuContribution
170 142
            allPopups="false"
171 143
            locationURI="popup:#DataImportEditorContext">
......
317 289
            properties="isMergingEnabled"
318 290
            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
319 291
      </propertyTester>
292
      <propertyTester
293
            class="eu.etaxonomy.taxeditor.bulkeditor.PropertyTester"
294
            id="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
295
            namespace="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
296
            properties="isDerivedUnitEditor"
297
            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
298
      </propertyTester>
320 299
   </extension>
321 300
   <extension
322 301
         point="org.eclipse.ui.handlers">
......
384 363
            name="%page.name.0">
385 364
      </page>
386 365
   </extension>
387
   <extension
388
         point="org.eclipse.core.expressions.propertyTesters">
389
      <propertyTester
390
            class="eu.etaxonomy.taxeditor.bulkeditor.PropertyTester"
391
            id="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
392
            namespace="eu.etaxonomy.taxeditor.bulkeditor.propertyTester"
393
            properties="isDerivedUnitEditor"
394
            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
395
      </propertyTester>
396
   </extension>
397 366
   <extension
398 367
         point="org.eclipse.ui.perspectiveExtensions">
399 368
      <perspectiveExtension
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
44 44
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
45 45
import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
46 46
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
47
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
47 48
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
48 49
import eu.etaxonomy.taxeditor.store.CdmStore;
49 50

  
50 51
/**
51
 * <p>BulkEditor class.</p>
52
 * <p>
53
 * BulkEditor class.
54
 * </p>
52 55
 *
53 56
 * @author p.ciardelli
54 57
 * @created 07.07.2009
55 58
 * @version 1.0
56 59
 */
57
public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDetails, IDirtyMarkableSelectionProvider{
60
public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDetails, IPartContentHasMedia,
61
        IDirtyMarkableSelectionProvider {
58 62

  
59 63
	/** Constant <code>ID="bulkeditor.editor"</code> */
60 64
	public static final String ID = "bulkeditor.editor";
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AbstractAddDerivedUnitFacadeMediaHandler.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.handler;
12

  
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.common.NotDefinedException;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.ui.IEditorInput;
20
import org.eclipse.ui.IEditorPart;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.handlers.HandlerUtil;
23

  
24
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
25
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
26
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
27
import eu.etaxonomy.taxeditor.bulkeditor.derivedunit.operation.AddDerivedUnitFacadeMediaOperation;
28
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
29
import eu.etaxonomy.taxeditor.model.MessagingUtils;
30
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
31
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
32

  
33
/**
34
 * @author n.hoffmann
35
 * @created Feb 11, 2011
36
 * @version 1.0
37
 */
38
public abstract class AbstractAddDerivedUnitFacadeMediaHandler extends AbstractHandler {
39

  
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
42
	 */
43
	@Override
44
	public Object execute(ExecutionEvent event) throws ExecutionException {
45
		IWorkbenchPart part = HandlerUtil.getActivePart(event);
46
		IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
47
		
48
		
49
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
50
		IEditorInput input = editor.getEditorInput();
51
		
52
		
53
		if(input instanceof OccurrenceEditorInput){
54
			BulkEditor bulkEditor = (BulkEditor) editor;
55
			ISelection selection = bulkEditor.getSelectionProvider().getSelection();
56
			
57
			if(selection instanceof IStructuredSelection){
58
				Object element = ((IStructuredSelection) selection).getFirstElement();
59
				if(element instanceof DerivedUnit){
60
					
61
					try{
62
						AbstractPostOperation operation = new AddDerivedUnitFacadeMediaOperation(event.getCommand().getName(), BulkEditorUtil.getUndoContext(), (DerivedUnit) element, getMode(), postOperationEnabled);
63
						BulkEditorUtil.executeOperation(operation);
64
					} catch (NotDefinedException e) {
65
						MessagingUtils.warn(getClass(), "Command name not set.");
66
					}					
67
				}
68
			}
69
		}
70
		return null;
71
	}
72

  
73
	/**
74
	 * @return
75
	 */
76
	protected abstract int getMode();
77

  
78
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AddDerivedUnitMediaHandler.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.handler;
12

  
13
import eu.etaxonomy.taxeditor.bulkeditor.derivedunit.operation.AddDerivedUnitFacadeMediaOperation;
14

  
15

  
16
/**
17
 * @author n.hoffmann
18
 * @created Feb 7, 2011
19
 * @version 1.0
20
 */
21
public class AddDerivedUnitMediaHandler extends AbstractAddDerivedUnitFacadeMediaHandler {
22

  
23
	/* (non-Javadoc)
24
	 * @see eu.etaxonomy.taxeditor.bulkeditor.derivedunit.handler.AbstractAddDerivedUnitFacadeMediaHandler#getMode()
25
	 */
26
	@Override
27
	protected int getMode() {
28
		return AddDerivedUnitFacadeMediaOperation.DERIVED_UNIT_MEDIA;
29
	}
30

  
31
	
32
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/derivedunit/handler/AddFieldObjectMediaHandler.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.handler;
12

  
13
import eu.etaxonomy.taxeditor.bulkeditor.derivedunit.operation.AddDerivedUnitFacadeMediaOperation;
14

  
15
/**
16
 * @author n.hoffmann
17
 * @created Feb 11, 2011
18
 * @version 1.0
19
 */
20
public class AddFieldObjectMediaHandler extends
21
		AbstractAddDerivedUnitFacadeMediaHandler {
22

  
23
	/* (non-Javadoc)
24
	 * @see eu.etaxonomy.taxeditor.bulkeditor.derivedunit.handler.AbstractAddDerivedUnitFacadeMediaHandler#getMode()
25
	 */
26
	@Override
27
	protected int getMode() {
28
		return AddDerivedUnitFacadeMediaOperation.FIELD_OBJECT_MEDIA;
29
	}
30

  
31
}
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.DerivedUnit;
24
import eu.etaxonomy.taxeditor.model.MessagingUtils;
25
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
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
		AbstractPostTaxonOperation {
35

  
36
	public static final int DERIVED_UNIT_MEDIA = 0;
37
	public static final int FIELD_OBJECT_MEDIA = 1;
38
	
39
	private DerivedUnit derivedUnit;
40
	private int mode;
41
	
42
	/**
43
	 * @param label
44
	 * @param undoContext
45
	 * @param postOperationEnabled
46
	 */
47
	public AddDerivedUnitFacadeMediaOperation(String label, IUndoContext undoContext, DerivedUnit 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
			MessagingUtils.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
}
eu.etaxonomy.taxeditor.editor/plugin.xml
707 707
               commandId="taxeditor-editor.command.newimagegallery"
708 708
               label="%command.label.37"
709 709
               style="push">
710
            <visibleWhen>
711
               <or>
712
                  <reference
713
                        definitionId="isBulkEditor">
714
                  </reference>
715
                  <reference
716
                        definitionId="isTaxonEditor">
717
                  </reference>
718
                  <reference
719
                        definitionId="isDerivateEditor">
720
                  </reference>
721
               </or>
722
            </visibleWhen>
710 723
         </command>
711 724
         <separator
712 725
               name="taxeditor-editor.separator1"
......
1261 1274
            </test>
1262 1275
         </with>
1263 1276
      </definition>
1277
      <definition
1278
            id="isBulkEditor">
1279
         <with
1280
               variable="selection">
1281
            <test
1282
                  property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isBulkEditor">
1283
            </test>
1284
         </with>
1285
      </definition>
1286
      <definition
1287
            id="isDerivateEditor">
1288
         <with
1289
               variable="selection">
1290
            <test
1291
                  property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isDerivateEditor">
1292
            </test>
1293
         </with>
1294
      </definition>
1264 1295
      <definition
1265 1296
            id="isDescription">
1266 1297
         <with
......
1329 1360
            class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DescriptionsMenuPropertyTester"
1330 1361
            id="eu.etaxonomy.taxeditor.descriptions.PropertyTester"
1331 1362
            namespace="eu.etaxonomy.taxeditor.descriptions.propertyTester"
1332
            properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor"
1363
            properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor"
1333 1364
            type="org.eclipse.jface.viewers.TreeSelection">
1334 1365
      </propertyTester>
1335 1366
      <propertyTester
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DescriptionsMenuPropertyTester.java
9 9
import eu.etaxonomy.cdm.model.description.DescriptionBase;
10 10
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
11 11
import eu.etaxonomy.cdm.model.media.Media;
12
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
12 13
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
14
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
13 15
import eu.etaxonomy.taxeditor.model.AbstractUtility;
14 16
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
15 17

  
......
29 31
	private static final String DELETABLE = "isDeletable";
30 32
	private static final String IMAGE_GALLERY = "isImageGallery";
31 33
	private static final String TAXON_EDITOR = "isTaxonEditor";
34
	private static final String BULK_EDITOR = "isBulkEditor";
35
	private static final String DERIVATE_EDITOR = "isDerivateEditor";
32 36

  
33 37
	/* (non-Javadoc)
34 38
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
......
41 45
	    if(TAXON_EDITOR.equals(property)){
42 46
	        return isTaxonEditor();
43 47
	    }
48
	    else if(BULK_EDITOR.equals(property)){
49
	        return isBulkEditor();
50
	    }
51
	    else if(DERIVATE_EDITOR.equals(property)){
52
	        return isDerivateEditor();
53
	    }
44 54

  
45 55
	    Object[] selectedElements = ((IStructuredSelection) receiver).toArray();
46 56

  
......
141 151
	    }
142 152
	    return false;
143 153
	}
154

  
155
	private boolean isBulkEditor() {
156
	    if(AbstractUtility.getActiveEditor() instanceof BulkEditor){
157
	        return true;
158
	    }
159
	    return false;
160
	}
161

  
162
	private boolean isDerivateEditor() {
163
	    if(AbstractUtility.getActiveEditor() instanceof DerivateView){
164
	        return true;
165
	    }
166
	    return false;
167
	}
144 168
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/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.editor.view.descriptive.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.occurrence.DerivedUnit;
22
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
23
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
24
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
25
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
27
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
28

  
29
/**
30
 * @author n.hoffmann
31
 * @created Feb 11, 2011
32
 * @version 1.0
33
 */
34
public class AddDerivedUnitFacadeMediaOperation extends AbstractPostTaxonOperation {
35

  
36
	private final SpecimenOrObservationBase<?> specimen;
37

  
38
	/**
39
	 * @param label
40
	 * @param undoContext
41
	 * @param postOperationEnabled
42
	 */
43
	public AddDerivedUnitFacadeMediaOperation(String label, IUndoContext undoContext, SpecimenOrObservationBase<?> specimen,
44
	        IPostOperationEnabled postOperationEnabled) {
45
		super(label, undoContext, postOperationEnabled);
46

  
47
		this.specimen = specimen;
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) throws ExecutionException {
55
		DerivedUnitFacade facade;
56
		try {
57
		    if(specimen instanceof FieldUnit){
58
		        facade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) specimen);
59
		        facade.getFieldObjectImageGallery(true);
60
		    }
61
		    else if(specimen instanceof DerivedUnit){
62
		        facade = DerivedUnitFacade.NewInstance((DerivedUnit)specimen);
63
		        facade.getDerivedUnitImageGallery(true);
64
		    }
65
		} catch (DerivedUnitFacadeNotSupportedException e) {
66
			MessagingUtils.error(getClass(), e);
67
		}
68

  
69
		return postExecute(specimen);
70
	}
71

  
72

  
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75
	 */
76
	@Override
77
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
78
			throws ExecutionException {
79
		// TODO Auto-generated method stub
80
		return null;
81
	}
82

  
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85
	 */
86
	@Override
87
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
88
			throws ExecutionException {
89
		// TODO Auto-generated method stub
90
		return null;
91
	}
92

  
93
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
32 32
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
33 33
import eu.etaxonomy.taxeditor.model.AbstractUtility;
34 34
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
35
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
35 36
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
36 37
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
37 38

  
......
104 105
			showViewer(part, new StructuredSelection(input));
105 106
		}
106 107

  
107
		if(part instanceof BulkEditor && selection instanceof IStructuredSelection){
108
		else if(part instanceof IPartContentHasMedia && selection instanceof IStructuredSelection){
108 109
			showViewer(part, (IStructuredSelection) selection);
109 110
		}
110 111
	}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/handler/AddImageGalleryHandler.java
1 1
/**
2
 * 
2
 *
3 3
 */
4 4
package eu.etaxonomy.taxeditor.editor.view.media.handler;
5 5

  
......
7 7
import org.eclipse.core.commands.ExecutionEvent;
8 8
import org.eclipse.core.commands.ExecutionException;
9 9
import org.eclipse.core.commands.common.NotDefinedException;
10
import org.eclipse.jface.viewers.ISelection;
11
import org.eclipse.jface.viewers.IStructuredSelection;
10 12
import org.eclipse.ui.IEditorInput;
11 13
import org.eclipse.ui.IEditorPart;
12 14
import org.eclipse.ui.IWorkbenchPart;
13 15
import org.eclipse.ui.handlers.HandlerUtil;
14 16

  
17
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
15 18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
20
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
21
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
16 22
import eu.etaxonomy.taxeditor.editor.EditorUtil;
17 23
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
24
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.AddDerivedUnitFacadeMediaOperation;
18 25
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
19 27
import eu.etaxonomy.taxeditor.model.MessagingUtils;
20 28
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
21 29
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
32 40
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
33 41
	 */
34 42
	/** {@inheritDoc} */
35
	public Object execute(ExecutionEvent event) throws ExecutionException {
43
	@Override
44
    public Object execute(ExecutionEvent event) throws ExecutionException {
36 45

  
37 46
		IWorkbenchPart part = HandlerUtil.getActivePart(event);
38 47
		IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
39
		
40
		
48

  
49

  
41 50
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
42 51
		IEditorInput input = editor.getEditorInput();
52

  
43 53
		if (input instanceof TaxonEditorInput) {
44
			Taxon taxon = ((TaxonEditorInput) input).getTaxon();	
45
			AbstractPostOperation operation;
54
			Taxon taxon = ((TaxonEditorInput) input).getTaxon();
55
			AbstractPostOperation<?> operation;
46 56
			try {
47 57
				// TODO use undo context specific to editor
48
				operation = new CreateTaxonDescriptionOperation(event.getCommand().getName(), 
58
				operation = new CreateTaxonDescriptionOperation(event.getCommand().getName(),
49 59
						EditorUtil.getUndoContext(), taxon, postOperationEnabled, true);
50
				EditorUtil.executeOperation(operation);
60
				AbstractUtility.executeOperation(operation);
51 61
			} catch (NotDefinedException e) {
52 62
				MessagingUtils.warn(getClass(), "Command name not set.");
53 63
			}
54
		} 
64
		}
65
		else if(input instanceof OccurrenceEditorInput){
66
		    BulkEditor bulkEditor = (BulkEditor) editor;
67
		    ISelection selection = bulkEditor.getSelectionProvider().getSelection();
68

  
69
		    if(selection instanceof IStructuredSelection){
70
		        Object element = ((IStructuredSelection) selection).getFirstElement();
71
		        if(element instanceof SpecimenOrObservationBase<?>){
72
		            try {
73
		                AbstractPostOperation<?> operation = new AddDerivedUnitFacadeMediaOperation(event.getCommand().getName(),
74
		                        BulkEditorUtil.getUndoContext(), (SpecimenOrObservationBase<?>)element, postOperationEnabled);
75
		                AbstractUtility.executeOperation(operation);
76
		            } catch (NotDefinedException e) {
77
		                MessagingUtils.warn(getClass(), "Command name not set.");
78
		            }
79
		        }
80
		    }
81
		}
55 82
		return null;
56 83
	}
57 84

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/IPartContentHasMedia.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.model;
12

  
13

  
14
/**
15
 *
16
 * Clients implementing this interface indicate, that the data they present is suitable for the media view
17
 * and that the media view should handle selection from the implementing part.
18
 *
19
 * @author pplitzner
20
 * @date Sep 16, 2014
21
 *
22
 */
23
public interface IPartContentHasMedia {
24

  
25
}

Also available in: Unified diff