fix #6527: refactor media deletion configurator and the corresponding wizard
authorKatja Luther <k.luther@bgbm.org>
Wed, 31 May 2017 13:36:59 +0000 (15:36 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 31 May 2017 13:36:59 +0000 (15:36 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteMediaConfiguratorComposite.java

index cb52a8cb966a55157febfc46fcc57128c1381a59..e0fe2077275fce5b8560ea6640c3adfd2c593b05 100644 (file)
@@ -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);
index f6ad7ee75ca18033d66cd64af0d8e79429917a16..fadc0ad4c51e4851300fd48b401f95f3ea5b4097 100644 (file)
@@ -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;
     }