You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/04/22 21:03:15 UTC
svn commit: r767622 - in /incubator/pivot/trunk/wtk/src/pivot/wtk: content/
skin/terra/
Author: gbrown
Date: Wed Apr 22 19:03:14 2009
New Revision: 767622
URL: http://svn.apache.org/viewvc?rev=767622&view=rev
Log:
Ensure that table view cell renderers are called to render() when calculating row height.
Modified:
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewBooleanCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewDateCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewImageCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewMultiCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewNumberCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewFileRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTableViewSkin.java
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewBooleanCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewBooleanCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewBooleanCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewBooleanCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -55,33 +55,35 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- boolean checkboxSelected = false;
+ if (value != null) {
+ boolean checkboxSelected = false;
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
- }
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- Object cellData = rowData.get(columnName);
+ Object cellData = rowData.get(columnName);
- if (cellData instanceof String) {
- cellData = Boolean.parseBoolean((String)cellData);
- }
+ if (cellData instanceof String) {
+ cellData = Boolean.parseBoolean((String)cellData);
+ }
- if (cellData instanceof Boolean) {
- checkboxSelected = (Boolean)cellData;
- } else {
- System.err.println("Data for \"" + columnName + "\" is not an instance of "
- + Boolean.class.getName());
+ if (cellData instanceof Boolean) {
+ checkboxSelected = (Boolean)cellData;
+ } else {
+ System.err.println("Data for \"" + columnName + "\" is not an instance of "
+ + Boolean.class.getName());
+ }
}
- }
- checkbox.setSelected(checkboxSelected);
- checkbox.setEnabled(tableView.isEnabled() && !rowDisabled);
+ checkbox.setSelected(checkboxSelected);
+ checkbox.setEnabled(tableView.isEnabled() && !rowDisabled);
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -42,24 +42,26 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- Object cellData = null;
+ renderStyles(tableView, rowSelected, rowDisabled);
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
- }
+ if (value != null) {
+ Object cellData = null;
- cellData = rowData.get(columnName);
- }
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- setText(cellData == null ? null : cellData.toString());
+ cellData = rowData.get(columnName);
+ }
- renderStyles(tableView, rowSelected, rowDisabled);
+ setText(cellData == null ? null : cellData.toString());
+ }
}
protected void renderStyles(TableView tableView, boolean rowSelected, boolean rowDisabled) {
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewDateCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewDateCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewDateCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewDateCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -55,30 +55,32 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- String formattedDate = null;
+ renderStyles(tableView, rowSelected, rowDisabled);
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
- }
+ if (value != null) {
+ String formattedDate = null;
- Object cellData = rowData.get(columnName);
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- if (cellData instanceof Date) {
- formattedDate = dateFormat.format((Date)cellData);
- } else {
- System.err.println("Data for \"" + columnName + "\" is not an instance of "
- + Date.class.getName());
- }
- }
+ Object cellData = rowData.get(columnName);
- setText(formattedDate);
+ if (cellData instanceof Date) {
+ formattedDate = dateFormat.format((Date)cellData);
+ } else {
+ System.err.println("Data for \"" + columnName + "\" is not an instance of "
+ + Date.class.getName());
+ }
+ }
- renderStyles(tableView, rowSelected, rowDisabled);
+ setText(formattedDate);
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewImageCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewImageCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewImageCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewImageCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -58,28 +58,30 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- Image image = null;
+ if (value != null) {
+ Image image = null;
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
- }
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- Object cellData = rowData.get(columnName);
+ Object cellData = rowData.get(columnName);
- if (cellData instanceof Image) {
- image = (Image)cellData;
- } else {
- System.err.println("Data for \"" + columnName + "\" is not an instance of "
- + Image.class.getName());
+ if (cellData instanceof Image) {
+ image = (Image)cellData;
+ } else {
+ System.err.println("Data for \"" + columnName + "\" is not an instance of "
+ + Image.class.getName());
+ }
}
- }
- setImage(image);
+ setImage(image);
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewMultiCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewMultiCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewMultiCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewMultiCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -298,34 +298,42 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- Object cellData = null;
+ if (value == null) {
+ for (Class<?> key : cellRenderers) {
+ TableView.CellRenderer renderer = cellRenderers.get(key);
+ renderer.render(null, tableView, column, rowSelected,
+ rowHighlighted, rowDisabled);
+ }
+ } else {
+ Object cellData = null;
+
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
+ cellData = rowData.get(columnName);
}
- cellData = rowData.get(columnName);
- }
+ Class<?> valueClass = (cellData == null ? null : cellData.getClass());
+ TableView.CellRenderer cellRenderer = cellRenderers.get(valueClass);
- Class<?> valueClass = (cellData == null ? null : cellData.getClass());
- TableView.CellRenderer cellRenderer = cellRenderers.get(valueClass);
+ if (cellRenderer == null) {
+ cellRenderer = defaultRenderer;
+ }
- if (cellRenderer == null) {
- cellRenderer = defaultRenderer;
- }
+ if (cellRenderer != currentRenderer) {
+ currentRenderer = cellRenderer;
+ cellRenderer.setSize(width, height);
+ }
- if (cellRenderer != currentRenderer) {
- currentRenderer = cellRenderer;
- cellRenderer.setSize(width, height);
+ cellRenderer.render(value, tableView, column, rowSelected, rowHighlighted, rowDisabled);
}
-
- cellRenderer.render(value, tableView, column, rowSelected, rowHighlighted, rowDisabled);
}
public TableView.CellRenderer getDefaultRenderer() {
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewNumberCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewNumberCellRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewNumberCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewNumberCellRenderer.java Wed Apr 22 19:03:14 2009
@@ -61,30 +61,32 @@
@SuppressWarnings("unchecked")
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- String formattedNumber = null;
+ renderStyles(tableView, rowSelected, rowDisabled);
- // Get the row and cell data
- String columnName = column.getName();
- if (columnName != null) {
- Dictionary<String, Object> rowData;
- if (value instanceof Dictionary<?, ?>) {
- rowData = (Dictionary<String, Object>)value;
- } else {
- rowData = new BeanDictionary(value);
- }
+ if (value != null) {
+ String formattedNumber = null;
- Object cellData = rowData.get(columnName);
+ // Get the row and cell data
+ String columnName = column.getName();
+ if (columnName != null) {
+ Dictionary<String, Object> rowData;
+ if (value instanceof Dictionary<?, ?>) {
+ rowData = (Dictionary<String, Object>)value;
+ } else {
+ rowData = new BeanDictionary(value);
+ }
- if (cellData instanceof Number) {
- formattedNumber = numberFormat.format((Number)cellData);
- } else {
- System.err.println("Data for \"" + columnName + "\" is not an instance of "
- + Number.class.getName());
- }
- }
+ Object cellData = rowData.get(columnName);
- setText(formattedNumber);
+ if (cellData instanceof Number) {
+ formattedNumber = numberFormat.format((Number)cellData);
+ } else {
+ System.err.println("Data for \"" + columnName + "\" is not an instance of "
+ + Number.class.getName());
+ }
+ }
- renderStyles(tableView, rowSelected, rowDisabled);
+ setText(formattedNumber);
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewFileRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewFileRenderer.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewFileRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewFileRenderer.java Wed Apr 22 19:03:14 2009
@@ -75,18 +75,7 @@
public void render(Object node, TreeView treeView, boolean expanded,
boolean selected, TreeView.NodeCheckState checkState,
boolean highlighted, boolean disabled) {
- File file = (File)node;
-
- // Update the image view
- Image icon = (file instanceof Folder) ? folderImage : fileImage;
-
- imageView.setImage(icon);
- imageView.getStyles().put("opacity",
- (treeView.isEnabled() && !disabled) ? 1.0f : 0.5f);
-
- // Update the label
- label.setText(file.getName());
-
+ // Update styles
Object labelFont = treeView.getStyles().get("font");
if (labelFont instanceof Font) {
label.getStyles().put("font", labelFont);
@@ -110,5 +99,19 @@
if (color instanceof Color) {
label.getStyles().put("color", color);
}
+
+ if (node != null) {
+ File file = (File)node;
+
+ // Update the image view
+ Image icon = (file instanceof Folder) ? folderImage : fileImage;
+
+ imageView.setImage(icon);
+ imageView.getStyles().put("opacity",
+ (treeView.isEnabled() && !disabled) ? 1.0f : 0.5f);
+
+ // Update the label
+ label.setText(file.getName());
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTableViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTableViewSkin.java?rev=767622&r1=767621&r2=767622&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTableViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTableViewSkin.java Wed Apr 22 19:03:14 2009
@@ -290,6 +290,7 @@
for (int i = 0, n = columns.getLength(); i < n; i++) {
TableView.Column column = columns.get(i);
TableView.CellRenderer cellRenderer = column.getCellRenderer();
+ cellRenderer.render(null, tableView, column, false, false, false);
rowHeight = Math.max(rowHeight, cellRenderer.getPreferredHeight(-1));
}