-
- Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(mediaView.getSelectionProvidingPart());
- if (e4WrappedPart instanceof FormEditor) {
- IEditorPart editor = null;
- editor = (FormEditor) e4WrappedPart;
- IEditorInput input = editor.getEditorInput();
- if (input instanceof CdmEntitySessionInput) {
- ISelection selection = mediaView.getViewer().getSelection();
- if (selection instanceof TreeSelection) {
- TreePath[] paths = ((TreeSelection) selection).getPaths();
- int count = paths[0].getSegmentCount();
- DescriptionBase description = null;
- for (int i = 0; i < count; i++ ) {
- if (paths[0].getSegment(i) instanceof DescriptionBase) {
- description = (DescriptionBase) paths[0].getSegment(i);
- break;
- }
- }
- // TODO use undo context specific to editor
- MediaDeletionConfigurator config = new MediaDeletionConfigurator();
-
- config.setDeleteFromDescription(true);
- config.setOnlyRemoveFromGallery(false);
-
- if (description instanceof SpecimenDescription){
- config.setDeleteFrom(((SpecimenDescription)description).getDescribedSpecimenOrObservation());
- } else if (description instanceof TaxonDescription){
- config.setDeleteFrom(((TaxonDescription)description).getTaxon());
- }else if (description instanceof TaxonNameDescription){
- config.setDeleteFrom(((TaxonNameDescription)description).getTaxonName());
- }
-
-
- DeleteConfiguratorDialog dialog;
- dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0);
- int result_dialog= dialog.open();
- if (result_dialog != IStatus.OK){
- return;
- }
- AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, media, config, mediaView);
- AbstractUtility.executeOperation(operation, sync);
-
+ ISelection selection = mediaView.getViewer().getSelection();
+ if (selection instanceof TreeSelection) {
+ TreePath[] paths = ((TreeSelection) selection).getPaths();
+ int count = paths[0].getSegmentCount();
+ DescriptionBase description = null;
+ for (int i = 0; i < count; i++ ) {
+ if (paths[0].getSegment(i) instanceof DescriptionBase) {
+ description = (DescriptionBase) paths[0].getSegment(i);
+ break;
+ }
+ }
+ // TODO use undo context specific to editor
+ MediaDeletionConfigurator config = new MediaDeletionConfigurator();
+
+ config.setDeleteFromDescription(true);
+ config.setOnlyRemoveFromGallery(false);
+
+ if (description instanceof SpecimenDescription){
+ config.setDeleteFrom(((SpecimenDescription)description).getDescribedSpecimenOrObservation());
+ } else if (description instanceof TaxonDescription){
+ config.setDeleteFrom(((TaxonDescription)description).getTaxon());
+ }else if (description instanceof TaxonNameDescription){
+ config.setDeleteFrom(((TaxonNameDescription)description).getTaxonName());
+ }
+ DeleteConfiguratorDialog dialog;
+ dialog = new DeleteConfiguratorDialog(config, shell, Messages.DeleteMediaHandler_CONFIRM, null, Messages.DeleteMediaHandler_CONFIRM_MESSAGE, MessageDialog.WARNING, new String[] { Messages.DeleteMediaHandler_DELETE, Messages.DeleteMediaHandler_SKIP }, 0);
+ int result_dialog= dialog.open();
+ if (result_dialog != IStatus.OK){
+ return;
+ }
+ if(object instanceof Media){
+ AbstractPostOperation<?> operation = new DeleteMediaOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), description, (Media) object, config, mediaView);
+ AbstractUtility.executeOperation(operation, sync);
+ }
+ if(object instanceof DescriptionBase && ((DescriptionBase) object).isImageGallery()){
+ if(object instanceof TaxonDescription){
+ DeleteTaxonDescriptionOperation deleteTaxonDescriptionOperation = new DeleteTaxonDescriptionOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), (TaxonDescription)object, mediaView, null);
+ AbstractUtility.executeOperation(deleteTaxonDescriptionOperation, sync);
+ }
+ else if(object instanceof SpecimenDescription){
+ DeleteSpecimenDescriptionOperation deleteTaxonDescriptionOperation = new DeleteSpecimenDescriptionOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), (SpecimenDescription)object, mediaView, null);
+ AbstractUtility.executeOperation(deleteTaxonDescriptionOperation, sync);