ref #10056: add delete button to date element
authorKatja Luther <k.luther@bgbm.org>
Tue, 31 May 2022 10:43:34 +0000 (12:43 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 31 May 2022 10:43:34 +0000 (12:43 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElement.java

index cc0067fb9ff811238e66b905770b642a634eac1d..77904f32155726fed21fd478ddbf3c36eca4f31f 100644 (file)
@@ -49,7 +49,8 @@ public class DateElement
     private org.joda.time.DateTime initialDateTime;
     private final Text textDate;
     private final Button openDateDialog;
-
+    private final Button btnRemove;
+    
     protected CacheRelevanceHelper cacheRelevanceHelper = new CacheRelevanceHelper();
 
     /**
@@ -83,7 +84,7 @@ public class DateElement
         Composite composite = new Composite (this, SWT.NONE);
        GridLayout layout = new GridLayout ();
 
-       layout.numColumns = 2;
+       layout.numColumns = 3;
        layout.marginWidth = 0;
 
        composite.setLayout(layout);
@@ -137,7 +138,17 @@ public class DateElement
                        dialog.open ();
                }
         });
+        btnRemove = new Button (composite, SWT.PUSH);
+        Image imageRemove = ImageResources.getImage(ImageResources.ACTIVE_DELETE_ICON);
+   //     openDateDialog.setText ("Open Date Dialog");
+        btnRemove.setImage(imageRemove);
 
+        btnRemove.addSelectionListener (new SelectionAdapter() {
+               @Override
+               public void widgetSelected(SelectionEvent e){
+                       setData(null);
+               }
+        });
         toolkit.adapt(textDate, true, true);
     }
 
@@ -174,10 +185,15 @@ public class DateElement
                  widget.setMinutes(dateTime.getMinutes());
        }
 
-       public void setData (org.joda.time.DateTime data) {
+       public void setData (org.joda.time.DateTime data) { 
+               
                        this.initialDateTime = data;
                        this.controller.setDateTime(data);
-                       this.textDate.setText(initialDateTime.toString(pattern));
+                       if (data == null){
+                               this.textDate.setText("");
+                       }else{
+                               this.textDate.setText(initialDateTime.toString(pattern));
+                       }
        }
 
     @Override