cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: CAY-2306 dbEntity > Properties. Inactive checkboxes are not disabled
Date Thu, 25 May 2017 13:10:20 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 65a1fad65 -> f3f01263f


CAY-2306 dbEntity > Properties. Inactive checkboxes are not disabled


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/2501a314
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/2501a314
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/2501a314

Branch: refs/heads/master
Commit: 2501a314d5998270b511b76e97811e02dba05bd7
Parents: 09b0fdb
Author: Anton Dreka <drekoas@gmail.com>
Authored: Wed May 24 13:21:18 2017 +0300
Committer: Anton Dreka <drekoas@gmail.com>
Committed: Wed May 24 13:21:18 2017 +0300

----------------------------------------------------------------------
 .../dbentity/DbEntityRelationshipPanel.java     | 32 ++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/2501a314/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipPanel.java
index a37131c..186a913 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityRelationshipPanel.java
@@ -50,18 +50,24 @@ import javax.swing.ComboBoxModel;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.Icon;
 import javax.swing.JComboBox;
+import javax.swing.JCheckBox;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
+import javax.swing.JTable;
 import javax.swing.ListSelectionModel;
+import javax.swing.SwingConstants;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.event.TableModelEvent;
 import javax.swing.event.TableModelListener;
+import javax.swing.table.TableCellRenderer;
 import javax.swing.table.TableColumn;
 import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.Component;
+import java.awt.Color;
 import java.util.List;
 
 /**
@@ -221,8 +227,10 @@ public class DbEntityRelationshipPanel extends JPanel implements DbEntityDisplay
         targetCombo = Application.getWidgetFactory().createComboBox();
         AutoCompletion.enable(targetCombo);
 
-        targetCombo.setRenderer(CellRenderers.entityListRendererWithIcons(entity
-                .getDataMap()));
+        table.getColumnModel().getColumn(DbRelationshipTableModel.TO_DEPENDENT_KEY)
+                .setCellRenderer(new CheckBoxCellRenderer());
+
+        targetCombo.setRenderer(CellRenderers.entityListRendererWithIcons(entity.getDataMap()));
         targetCombo.setModel(createComboModel(entity));
         col.setCellEditor(Application.getWidgetFactory().createCellEditor(targetCombo));
 
@@ -347,4 +355,24 @@ public class DbEntityRelationshipPanel extends JPanel implements DbEntityDisplay
             parentPanel.updateActions(rels);
         }
     }
+
+    private class CheckBoxCellRenderer implements TableCellRenderer {
+
+        private final JCheckBox renderer;
+
+        public CheckBoxCellRenderer() {
+            renderer = new JCheckBox();
+            renderer.setHorizontalAlignment(SwingConstants.CENTER);
+        }
+
+        @Override
+        public Component getTableCellRendererComponent(JTable table, Object value,
+                                                       boolean isSelected, boolean hasFocus,
int row, int column) {
+            Color color = isSelected ? table.getSelectionBackground() : table.getBackground();
+            renderer.setBackground(color);
+            renderer.setEnabled(table.isCellEditable(row, column));
+            renderer.setSelected(value != null && (Boolean)value);
+            return renderer;
+        }
+    }
 }
\ No newline at end of file


Mime
View raw message