[Schmitzm-commits] r2385 - trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 9 15:39:53 CEST 2013
Author: mojays
Date: 2013-08-09 15:39:53 +0200 (Fri, 09 Aug 2013)
New Revision: 2385
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/DatabaseEntityEditorFrame.java
trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java
Log:
BasicTypeComboBox: represent empty entry by empty string (instead of null) to avoid rendering problem
DatabaseEntityTable: automatically set DoubleRenderer.DOUBLE for numeric columns
DatabaseEntityEditorFrame: new constructor for Dialog parent
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 2013-08-09 13:36:44 UTC (rev 2384)
+++ trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/BasicTypeComboBox.java 2013-08-09 13:39:53 UTC (rev 2385)
@@ -10,6 +10,7 @@
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
+import org.apache.commons.lang.StringUtils;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
@@ -145,6 +146,13 @@
public F getSelectedItem() {
Object value = super.getSelectedItem();
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;
+
// Sometimes (especially if backspace was the last input) the value
// is String although there already is an corresponding list item.
// Thus at this point we double-check, whether there already is such
@@ -188,7 +196,7 @@
public void updateOptions(Criterion filter) {
removeAllItems();
if ( isNullable() )
- addItem(null);
+ addItem(" "); // wenn NULL, wird Label nicht richtig gerendert!
Map<Object,String> tooltips = new HashMap<Object, String>();
for ( F basicTypeInst : determineAllBasicTypes(filter) ) {
tooltips.put(basicTypeInst,basicTypeInst.toString());
Modified: trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityEditorFrame.java
===================================================================
--- trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityEditorFrame.java 2013-08-09 13:36:44 UTC (rev 2384)
+++ trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityEditorFrame.java 2013-08-09 13:39:53 UTC (rev 2385)
@@ -30,6 +30,7 @@
package de.schmitzm.db.hibernate.gui;
import java.awt.BorderLayout;
+import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.sql.SQLException;
@@ -74,6 +75,16 @@
/**
* Creates a new frame to edit a song's attributes.
*/
+ public DatabaseEntityEditorFrame(Dialog parent, String title, boolean modal, E entity, boolean editable) {
+ super(parent, title, modal, true);
+ setAlwaysOnTop(modal);
+ setEntity(entity);
+ setEditable(editable);
+ }
+
+ /**
+ * Creates a new frame to edit a song's attributes.
+ */
public DatabaseEntityEditorFrame(Frame parent, String title, boolean modal, E entity, boolean editable) {
super(parent, title, modal, true);
setAlwaysOnTop(modal);
Modified: trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java
===================================================================
--- trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java 2013-08-09 13:36:44 UTC (rev 2384)
+++ trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java 2013-08-09 13:39:53 UTC (rev 2385)
@@ -41,6 +41,12 @@
performEntitySelection(selectedEntity);
}
});
+
+ // Initialize renderer for numeric columns
+ for ( int i=0; i<getColumnCount(); i++) {
+ if ( Integer.class.isAssignableFrom(getColumnClass(i)) )
+ getColumnModel().getColumn(i).setCellRenderer( de.schmitzm.swing.table.DoubleRenderer.INTEGER );
+ }
}
/**
More information about the Schmitzm-commits
mailing list