commit 55031c8b54ac487e9500d59ace74bc476a3931a1
Author: Katja Luther <k.luther@bgbm.org>
Date:   Wed May 31 15:36:59 2017 +0200

    fix  #6527: refactor media deletion configurator and the corresponding wizard

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java
index cb52a8cb9..e0fe20772 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java
@@ -64,7 +64,7 @@ public class DeleteMediaOperation extends AbstractPostTaxonOperation {
 	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
 			throws ExecutionException {
 
-	    ImagesUtility.removeMediaFromGallery(description, media);
+	   // ImagesUtility.removeMediaFromGallery(description, media);
 
 		monitor.worked(20);
 		CdmStore.getService(IMediaService.class).delete(media.getUuid(), config);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java
index f6ad7ee75..fadc0ad4c 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java
@@ -35,13 +35,17 @@ public class DeleteMediaConfiguratorComposite extends Composite {
 
     private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
     private final MediaDeletionConfigurator configurator;
-    private final Button btnDeleteIfUsedInTaxonDescription;
-    private final Button btnDeleteIfUsedInSpecimenDescription;
+    private Button btnDelete;
+    private Button btnDeleteIfUsedInTaxonDescription;
+    private Button btnDeleteIfUsedInSpecimenDescription;
     private Button btnRemoveFromImageGallery;
+    
+    private boolean inBulkEditor;
 
 
     public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style, boolean inBulkEditor) {
         super(parent, style);
+        this.inBulkEditor = inBulkEditor;
         this.configurator = configurator;
         addDisposeListener(new DisposeListener() {
             @Override
@@ -52,36 +56,38 @@ public class DeleteMediaConfiguratorComposite extends Composite {
         toolkit.paintBordersFor(this);
         setLayout(new RowLayout(SWT.VERTICAL));
         setBackground(getBackground());
-
+        
+        
         if (inBulkEditor){
             btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
             btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
+            btnDeleteIfUsedInTaxonDescription.setEnabled(true);
+            btnDeleteIfUsedInTaxonDescription.setSelection(configurator.isDeleteIfUsedInTaxonDescription());
+            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
+            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
+            btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
+            btnDeleteIfUsedInSpecimenDescription.setSelection(configurator.isDeleteIfUsedInSpecimenDescription());
         }
         else {
-            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.RADIO);
-            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_delete);
-
+        	
+        	btnDelete = new Button(this, SWT.RADIO);
+        	btnDelete.setText(Messages.DeleteConfiguration_media_delete);
+        	
+//            btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
+//            btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
+//            btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
+//            btnDeleteIfUsedInTaxonDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInTaxonDescription);
+//            btnDelete.addListener(SWT.Selection, (Event e) -> {
+//                Button b = (Button) e.widget;
+//                btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
+//                btnDeleteIfUsedInTaxonDescription.setEnabled(b.getSelection());
+//            });
             btnRemoveFromImageGallery = new Button(this, SWT.RADIO);
             btnRemoveFromImageGallery.setText(Messages.DeleteConfiguration_media_removeFromGallery);
+            btnDelete.setSelection(!configurator.isOnlyRemoveFromGallery());
+        	btnRemoveFromImageGallery.setSelection(configurator.isOnlyRemoveFromGallery());
         }
 
-        btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
-        btnDeleteIfUsedInSpecimenDescription.setText(Messages.DeleteConfiguration_media_deleteIfUsedInSpecimenDescription);
-
-        if(inBulkEditor){
-            btnDeleteIfUsedInSpecimenDescription.setEnabled(true);
-        }
-        else{
-            btnDeleteIfUsedInSpecimenDescription.setEnabled(false);
-
-            btnDeleteIfUsedInTaxonDescription.addListener(SWT.Selection, (Event e) -> {
-                Button b = (Button) e.widget;
-                btnDeleteIfUsedInSpecimenDescription.setEnabled(b.getSelection());
-
-            });
-        }
-        btnDeleteIfUsedInTaxonDescription.setSelection(true);
-
         m_bindingContext = initDataBindings();
 
     }
@@ -89,19 +95,26 @@ public class DeleteMediaConfiguratorComposite extends Composite {
     protected DataBindingContext initDataBindings() {
         DataBindingContext bindingContext = new DataBindingContext();
         //
-        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
-        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
-        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
-
-        if(btnRemoveFromImageGallery!=null){
+        if (inBulkEditor){
+	        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
+	        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
+	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
+	        
+	        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
+	        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
+	        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
+        } else{       
+        
+	        IObservableValue observeSelectionBtnDelete = WidgetProperties.selection().observe(btnDelete);
+	        IObservableValue deleteConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
+	        bindingContext.bindValue(observeSelectionBtnDelete, deleteConfiguratorObserveValue, null, null);
+       
             IObservableValue observeSelectionBtnRemoveFromImageGallery = WidgetProperties.selection().observe(btnRemoveFromImageGallery);
             IObservableValue removeFromImageGalleryConfiguratorObserveValue = PojoProperties.value("onlyRemoveFromGallery").observe(configurator);
             bindingContext.bindValue(observeSelectionBtnRemoveFromImageGallery, removeFromImageGalleryConfiguratorObserveValue, null, null);
         }
 
-        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
-        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
-        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
+       
 
         return bindingContext;
     }
