- added elevation to section title
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 29 Oct 2014 10:38:50 +0000 (10:38 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 29 Oct 2014 10:38:50 +0000 (10:38 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/MinMaxTextSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/NumberWithLabelElement.java

index bd16aa177bad08711ced3edfd7773859ac7d8276..a3b2e3e6b4979f1b8e72ce1041b2ae719ec418e5 100644 (file)
@@ -62,12 +62,12 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                switch(unitType) {
                        case ELEVATION:
                                text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
                switch(unitType) {
                        case ELEVATION:
                                text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
-                               text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);    
+                               text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);
                                break;
                        default:
                                text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
                                break;
                        default:
                                text_minVal = formFactory.createNumberTextWithLabelElement(this, "Min [m] : ", getMinimum(), style);
-                               text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);                                                            
-                               break;                  
+                               text_maxVal = formFactory.createNumberTextWithLabelElement(this, "Max [m] : ", getMaximum(), style);
+                               break;
                }
                text_freeText = formFactory.createTextWithLabelElement(this,
                                "Freetext : ", getFreetext(), style);
                }
                text_freeText = formFactory.createTextWithLabelElement(this,
                                "Freetext : ", getFreetext(), style);
@@ -87,6 +87,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
        public void setEntity(DerivedUnitFacade gatheringEvent) {
                super.setEntity(gatheringEvent);
                updateValues();
        public void setEntity(DerivedUnitFacade gatheringEvent) {
                super.setEntity(gatheringEvent);
                updateValues();
+               updateTitle();
        }
 
        private void updateValues() {
        }
 
        private void updateValues() {
@@ -166,10 +167,26 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                } else if (eventSource == text_freeText) {
                        updateFreetext();
                }
                } else if (eventSource == text_freeText) {
                        updateFreetext();
                }
+        updateTitle();
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 
-
+    private void updateTitle(){
+        String title = "";
+        if(text_minVal.getText()!=null){
+            title += text_minVal.getText();
+        }
+        if(text_maxVal.getText()!=null && !text_maxVal.getText().equals("")){
+            if(!title.equals("")){
+                title += " - "+text_maxVal.getText();
+            }
+        }
+        if(title.equals("") && text_freeText.getText()!=null){
+            title = text_freeText.getText();
+        }
+        this.setText(title);
+        layout();
+    }
 
        /*
         * (non-Javadoc)
 
        /*
         * (non-Javadoc)
@@ -186,7 +203,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
        private void updateMinimum() {
                switch(unitType) {
                case ELEVATION:
        private void updateMinimum() {
                switch(unitType) {
                case ELEVATION:
-                       getEntity().setAbsoluteElevation(text_minVal.getDouble().intValue());
+                       getEntity().setAbsoluteElevation(text_minVal.getDouble()!=null?text_minVal.getDouble().intValue():null);
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGround(text_minVal.getDouble());
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGround(text_minVal.getDouble());
@@ -215,7 +232,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
        private void updateMaximum() {
                switch(unitType) {
                case ELEVATION:
        private void updateMaximum() {
                switch(unitType) {
                case ELEVATION:
-                       getEntity().setAbsoluteElevationMax(text_maxVal.getDouble().intValue());
+                       getEntity().setAbsoluteElevationMax(text_maxVal.getDouble()!=null?text_maxVal.getDouble().intValue():null);
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGroundMax(text_maxVal.getDouble());
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGroundMax(text_maxVal.getDouble());
index 83e229bd4272bfeab55ed24bfa02f51964cc156c..57fade3d9416c81b3dc0ac9d1918352cee360288 100644 (file)
@@ -114,6 +114,7 @@ public class NumberWithLabelElement extends TextWithLabelElement {
                String value = text.getText();
                if(StringUtils.isBlank(value)){
                        text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
                String value = text.getText();
                if(StringUtils.isBlank(value)){
                        text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+                       super.modifyText(event);
                        return;
                }
 
                        return;
                }