[hg] main-silver: #221428: Fields are not always marked as green...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #221428: Fields are not always marked as green...
  • Date: Tue, 06 Nov 2012 12:06:57 -0800

changeset 953ae2376417 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/953ae2376417
description:
        #221428: Fields are not always marked as green if they are edited

diffstat:

 db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java 
|  32 ++++++++-
 1 files changed, 26 insertions(+), 6 deletions(-)

diffs (95 lines):

diff --git 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
--- 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
+++ 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/DataViewTableUI.java
@@ -43,6 +43,7 @@
  */
 package org.netbeans.modules.db.dataview.output;
 
+import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Toolkit;
@@ -56,16 +57,19 @@
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.swing.JComponent;
 import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.JTable;
 import javax.swing.RowFilter;
+import javax.swing.border.LineBorder;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableCellRenderer;
 import javax.swing.table.TableModel;
+import org.jdesktop.swingx.renderer.JRendererCheckBox;
 import org.netbeans.modules.db.dataview.meta.DBColumn;
 import org.netbeans.modules.db.dataview.meta.DBException;
 import org.netbeans.modules.db.dataview.meta.DBTable;
@@ -74,7 +78,6 @@
 import org.netbeans.modules.db.dataview.table.ResultSetTableModel;
 import org.openide.DialogDisplayer;
 import org.openide.NotifyDescriptor;
-import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
 import org.openide.util.NbBundle;
 import org.openide.util.datatransfer.ExClipboard;
@@ -150,13 +153,15 @@
     }
 
     private static class UpdatedResultSetCellRenderer extends 
ResultSetCellRenderer {
-
+        static int borderThickness = 1;
         static Color green = new Color(0, 128, 0);
         static Color gray = new Color(245, 245, 245);
+        private JComponent holder = new JComponent() {};
         DataView dataView;
 
         public UpdatedResultSetCellRenderer(DataView dView) {
             dataView = dView;
+            holder.setLayout(new BorderLayout());
         }
 
         @Override
@@ -166,19 +171,34 @@
                     table.convertRowIndexToModel(row),
                     table.convertColumnIndexToModel(column));
 
+            Color color;
+            boolean override = false;
+
             if (isSelected) {
                 if ((obj == null && value == null) || (obj != null && value 
!= null && value.equals(obj))) {
-                    c.setForeground(gray);
+                    color = gray;
+                    override = true;
                 } else {
-                    c.setForeground(Color.ORANGE);
+                    color = Color.ORANGE;
+                    override = true;
                 }
             } else {
                 if ((obj == null && value == null) || (obj != null && value 
!= null && value.equals(obj))) {
-                    c.setForeground(table.getForeground());
+                    color = table.getForeground();
                 } else {
-                    c.setForeground(green);
+                    color = green;
+                    override = true;
                 }
             }
+
+            if(override && c instanceof JRendererCheckBox) {
+                holder.removeAll();
+                holder.setBorder(new LineBorder(color, borderThickness));
+                holder.add(c);
+                return holder;
+            } else {
+                c.setForeground(color);
+            }
             return c;
         }
     }

[hg] main-silver: #221428: Fields are not always marked as green...

Jaroslav Havlin 11/06/2012

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close