[Schmitzm-commits] r2403 - in trunk: schmitzm-core/src/main/java/de/schmitzm/swing schmitzm-core/src/main/java/de/schmitzm/swing/table schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat May 24 14:14:33 CEST 2014
Author: mojays
Date: 2014-05-24 14:14:33 +0200 (Sat, 24 May 2014)
New Revision: 2403
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/ComponentRenderer.java
trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java
Log:
DatabaseEntityTable: automatically render boolean columns as CheckBox
ComponentRenderer: apply table background to renderer component (also for unselected case)
SelectableTable: getColumnBackground(.) made public (instead of protected)
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java 2014-05-24 11:22:01 UTC (rev 2402)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java 2014-05-24 12:14:33 UTC (rev 2403)
@@ -282,7 +282,7 @@
* @see #setDefaultColumnBackground(Color)
* @see #setAlternatingColumnBackground(Color)
*/
- protected Color getColumnBackground(int col) {
+ public Color getColumnBackground(int col) {
// if alternating column colors are disabled always
// return the default color
if ( getAlternatingColumnBackground() == null )
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/ComponentRenderer.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/ComponentRenderer.java 2014-05-24 11:22:01 UTC (rev 2402)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/table/ComponentRenderer.java 2014-05-24 12:14:33 UTC (rev 2403)
@@ -38,6 +38,8 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
+import de.schmitzm.swing.SelectableJTable;
+
/**
* Diese Klasse stellt einen Tabellen-Renderer fuer jede Art von
* {@link Component}-Objekten dar. Um z.B. einen Button oder eine
@@ -179,6 +181,8 @@
if ( isSelected ) {
rendComp.setBackground(table.getSelectionBackground());
rendComp.setForeground(table.getSelectionForeground());
+ } else {
+ rendComp.setBackground( table instanceof SelectableJTable ? ((SelectableJTable)table).getColumnBackground(column) : table.getBackground());
}
return rendComp;
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 2014-05-24 11:22:01 UTC (rev 2402)
+++ trunk/schmitzm-hibernate/src/main/java/de/schmitzm/db/hibernate/gui/DatabaseEntityTable.java 2014-05-24 12:14:33 UTC (rev 2403)
@@ -42,10 +42,20 @@
}
});
- // Initialize renderer for numeric columns
+ initializeCellRenderers();
+ }
+
+ /**
+ * (Re)initializes the column cell renderers depending on the column
+ * class.
+ */
+ protected void initializeCellRenderers() {
+ // Initialize renderer for columns
for ( int i=0; i<getColumnCount(); i++) {
if ( Integer.class.isAssignableFrom(getColumnClass(i)) )
getColumnModel().getColumn(i).setCellRenderer( de.schmitzm.swing.table.DoubleRenderer.INTEGER );
+ if ( Boolean.class.isAssignableFrom(getColumnClass(i)) )
+ getColumnModel().getColumn(i).setCellRenderer( new de.schmitzm.swing.table.ComponentRenderer.JCheckBox() );
}
}
More information about the Schmitzm-commits
mailing list