[Schmitzm-commits] r2407 - in trunk: schmitzm-core/src/main/java/de/schmitzm/swing/input schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Nov 24 16:08:13 CET 2014


Author: mojays
Date: 2014-11-24 16:08:13 +0100 (Mon, 24 Nov 2014)
New Revision: 2407

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/SelectionInputOption.java
   trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/BasicTypeComboBox.java
Log:
BasicTypeComboBox:  BugFix: handling of special empty value (" ") has to be applied also in getItemAt(.)
SelectionInputOption: avoid NPE in some special cases that "selectionObject" is created belated

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/SelectionInputOption.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/SelectionInputOption.java	2014-11-12 21:42:31 UTC (rev 2406)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/input/SelectionInputOption.java	2014-11-24 15:08:13 UTC (rev 2407)
@@ -227,7 +227,7 @@
    */
   protected E performGetValue() {
     int idx = getSelectedIndex();
-    return idx < 0 ? null : selectionObject[getSelectedIndex()];
+    return idx < 0 || selectionObject == null ? null : selectionObject[getSelectedIndex()];
   }
 
   /**

Modified: trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/BasicTypeComboBox.java
===================================================================
--- trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/BasicTypeComboBox.java	2014-11-12 21:42:31 UTC (rev 2406)
+++ trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/BasicTypeComboBox.java	2014-11-24 15:08:13 UTC (rev 2407)
@@ -138,7 +138,25 @@
     updateOptions();
   }
   
+  
   /**
+   * Returns the list item at the specified index.
+   */
+  @Override
+  public F getItemAt(int idx) {
+    Object value = super.getItemAt(idx);
+    if ( value instanceof String ) {
+      // For proper rendering the selection option for NULL is a blank String (" ")
+      // and not NULL!
+      // So at this point we take care that no BasicType with empty description is
+      // created!
+      if ( StringUtils.isBlank((String)value) )
+        return null;
+    }
+    return (F)value;
+  }
+  
+  /**
    * Returns {@code super.getSelectedItem()} automatically
    * casted to the {@link BasicType}.
    */



More information about the Schmitzm-commits mailing list