Revision: 6719
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6719&view=rev
Author: gerdwagner
Date: 2012-11-17 20:58:32 +0000 (Sat, 17 Nov 2012)
Log Message:
-----------
Bug fix: Tables cells that contained html where rendered incorrect. Now the plain html string is shown.
Modified Paths:
--------------
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellComponentFactory.java
Added Paths:
-----------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellRenderer.java
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2012-11-17 20:28:27 UTC (rev 6718)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2012-11-17 20:58:32 UTC (rev 6719)
@@ -48,6 +48,8 @@
Bug fixes:
+Tables cells that contained html where rendered incorrect. Now the plain html string is shown.
+
When schema info was refreshed (using F5) the SQL editor used to color tables as undefined (error red).
Column sorting indicator icon was lost when sorted column headers where dragged to reorder columns
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellComponentFactory.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellComponentFactory.java 2012-11-17 20:28:27 UTC (rev 6718)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellComponentFactory.java 2012-11-17 20:58:32 UTC (rev 6719)
@@ -1,6 +1,5 @@
package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
-import java.awt.Component;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -13,12 +12,10 @@
import java.util.HashMap;
import javax.swing.DefaultCellEditor;
-import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
-import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
@@ -230,90 +227,9 @@
{
return new CellRenderer(getDataTypeObject(null, colDef));
}
-
- /**
- * The base component of a DefaultTableCellRenderer is a JLabel.
- * @author gwg
- */
- static private final class CellRenderer extends DefaultTableCellRenderer implements SquirrelTableCellRenderer
- {
- private static final long serialVersionUID = 1L;
- transient private final IDataTypeComponent _dataTypeObject;
- CellRenderer(IDataTypeComponent dataTypeObject)
- {
- super();
-
- _dataTypeObject = dataTypeObject;
- }
-
- /**
- *
- * Returns the default table cell renderer - overridden from DefaultTableCellRenderer.
- *
- * @param table the <code>JTable</code>
- * @param value the value to assign to the cell at
- * <code>[row, column]</code>
- * @param isSelected true if cell is selected
- * @param hasFocus true if cell has focus
- * @param row the row of the cell to render
- * @param column the column of the cell to render
- * @return the default table cell renderer
- */
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
-
- JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- // if text cannot be edited in the cell but can be edited in
- // the popup, show that by changing the text colors.
- if (_dataTypeObject != null &&
- _dataTypeObject.isEditableInCell(value) == false &&
- _dataTypeObject.isEditableInPopup(value) == true) {
- // Use a CYAN background to indicate that the cell is
- // editable in the popup
- setBackground(SquirrelConstants.MULTI_LINE_CELL_COLOR);
- }
- else {
- // since the previous entry might have changed the color,
- // we need to reset the color back to default value for table cells,
- // taking into account whether the cell is selected or not.
- if (isSelected)
- setBackground(table.getSelectionBackground());
- else
- setBackground(table.getBackground());
- }
-
-
- return label;
- }
-
-
- public void setValue(Object value)
- {
- // default behavior if no DataType object is to use the
- // DefaultColumnRenderer with no modification.
- if (_dataTypeObject != null)
- super.setValue(_dataTypeObject.renderObject(value));
- else super.setValue(DefaultColumnRenderer.getInstance().renderObject(value));
- }
-
- public Object renderValue(Object value)
- {
- if (_dataTypeObject != null)
- {
- return _dataTypeObject.renderObject(value);
- }
- else
- {
- return DefaultColumnRenderer.getInstance().renderObject(value);
- }
- }
- }
-
-
- /**
+ /**
* Return true if the data type for the column may be edited
* within the table cell, false if not.
*/
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellRenderer.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellRenderer.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellRenderer.java 2012-11-17 20:58:32 UTC (rev 6719)
@@ -0,0 +1,90 @@
+package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
+
+import net.sourceforge.squirrel_sql.fw.util.SquirrelConstants;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.*;
+
+/**
+ * The base component of a DefaultTableCellRenderer is a JLabel.
+ * @author gwg
+ */
+public final class CellRenderer extends DefaultTableCellRenderer implements SquirrelTableCellRenderer
+{
+transient private final IDataTypeComponent _dataTypeObject;
+
+ CellRenderer(IDataTypeComponent dataTypeObject)
+ {
+ super();
+
+ _dataTypeObject = dataTypeObject;
+ }
+
+ /**
+ *
+ * Returns the default table cell renderer - overridden from DefaultTableCellRenderer.
+ *
+ * @param table the <code>JTable</code>
+ * @param value the value to assign to the cell at
+ * <code>[row, column]</code>
+ * @param isSelected true if cell is selected
+ * @param hasFocus true if cell has focus
+ * @param row the row of the cell to render
+ * @param column the column of the cell to render
+ * @return the default table cell renderer
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+
+ JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ // if text cannot be edited in the cell but can be edited in
+ // the popup, show that by changing the text colors.
+ if (_dataTypeObject != null &&
+ _dataTypeObject.isEditableInCell(value) == false &&
+ _dataTypeObject.isEditableInPopup(value) == true)
+ {
+ // Use a CYAN background to indicate that the cell is
+ // editable in the popup
+ setBackground(SquirrelConstants.MULTI_LINE_CELL_COLOR);
+ }
+ else
+ {
+ // since the previous entry might have changed the color,
+ // we need to reset the color back to default value for table cells,
+ // taking into account whether the cell is selected or not.
+ if (isSelected)
+ setBackground(table.getSelectionBackground());
+ else
+ setBackground(table.getBackground());
+ }
+
+ label.putClientProperty("html.disable", Boolean.TRUE);
+
+
+ return label;
+ }
+
+
+ public void setValue(Object value)
+ {
+ // default behavior if no DataType object is to use the
+ // DefaultColumnRenderer with no modification.
+ if (_dataTypeObject != null)
+ super.setValue(_dataTypeObject.renderObject(value));
+ else super.setValue(DefaultColumnRenderer.getInstance().renderObject(value));
+ }
+
+ public Object renderValue(Object value)
+ {
+ if (_dataTypeObject != null)
+ {
+ return _dataTypeObject.renderObject(value);
+ }
+ else
+ {
+ return DefaultColumnRenderer.getInstance().renderObject(value);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|