cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [3/4] cayenne git commit: fix scroll. change tool tip text. fix header renderer. fix autocompletion
Date Wed, 16 Dec 2015 12:57:06 GMT
fix scroll. change tool tip text. fix header renderer. fix autocompletion


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

Branch: refs/heads/master
Commit: 16ee52034887dbd0739df6943fa3f5908b190829
Parents: c52fac6
Author: AlexandrShestak <shestakalexandr@mail.ru>
Authored: Tue Dec 15 10:42:20 2015 +0300
Committer: AlexandrShestak <shestakalexandr@mail.ru>
Committed: Tue Dec 15 10:42:20 2015 +0300

----------------------------------------------------------------------
 .../editor/ObjEntityRelationshipPanel.java      |  2 +-
 .../util/DbRelationshipPathComboBoxEditor.java  |  2 +-
 .../util/PathChooserComboBoxCellEditor.java     | 14 +++++++++++++-
 .../modeler/util/SortButtonRenderer.java        | 10 ++++------
 .../modeler/util/combo/AutoCompletion.java      | 20 +++++---------------
 5 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/16ee5203/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipPanel.java
index fd08bde..41061e3 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityRelationshipPanel.java
@@ -321,7 +321,7 @@ public class ObjEntityRelationshipPanel extends JPanel implements ObjEntityDispl
             public Component getTableCellRendererComponent(JTable table, Object value, boolean
isSelected, boolean hasFocus, int row, int column) {
                 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
column);
                 setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
-                setToolTipText("To choose relationship press enter two times. \n To choose
next relationship press dot.");
+                setToolTipText("To choose relationship press enter two times.To choose next
relationship press dot.");
                 return this;
             }
         });

http://git-wip-us.apache.org/repos/asf/cayenne/blob/16ee5203/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbRelationshipPathComboBoxEditor.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbRelationshipPathComboBoxEditor.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbRelationshipPathComboBoxEditor.java
index 8a5ca0a..a3e6935 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbRelationshipPathComboBoxEditor.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbRelationshipPathComboBoxEditor.java
@@ -69,7 +69,7 @@ public class DbRelationshipPathComboBoxEditor extends PathChooserComboBoxCellEdi
         comboBoxPathChooser.setSelectedItem(((ObjRelationshipTableModel) model).getRelationship(row).getDbRelationshipPath());
 
         enterPressedCount = 0;
-        comboBoxPathChooser.setToolTipText("To choose relationship press enter two times.
\n To choose next relationship press dot.");
+        comboBoxPathChooser.setToolTipText("To choose relationship press enter two times.To
choose next relationship press dot.");
         JTextComponent textEditor = (JTextComponent) (comboBoxPathChooser).
                 getEditor().getEditorComponent();
         textEditor.addFocusListener(this);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/16ee5203/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java
index 07633da..2c5509b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java
@@ -41,6 +41,8 @@ import javax.swing.text.JTextComponent;
 import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
@@ -51,7 +53,7 @@ import java.util.regex.Pattern;
  * This class used as cell editor, when you need to
  * choose path in comboBox and use autocompletion.
  */
-public abstract class PathChooserComboBoxCellEditor extends AbstractCellEditor implements
TableCellEditor {
+public abstract class PathChooserComboBoxCellEditor extends AbstractCellEditor implements
TableCellEditor, ActionListener {
 
     protected JComboBox comboBoxPathChooser;
     protected int previousEmbeddedLevel = 0;
@@ -87,6 +89,7 @@ public abstract class PathChooserComboBoxCellEditor extends AbstractCellEditor
i
         ((JComponent) comboBoxPathChooser.getEditor().getEditorComponent()).setBorder(null);
         comboBoxPathChooser.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
         comboBoxPathChooser.setRenderer(new PathChooserComboBoxCellRenderer());
+        comboBoxPathChooser.addActionListener(this);
     }
 
     private void setComboModelAccordingToPath(String pathString) {
@@ -204,6 +207,15 @@ public abstract class PathChooserComboBoxCellEditor extends AbstractCellEditor
i
         return currentNodeChildren;
     }
 
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        //for some reason comboBoxPathChooser don't load selected item text, so we made it
by hand
+        if (comboBoxPathChooser.getSelectedIndex() != (-1)) {
+            ((JTextComponent) (comboBoxPathChooser).
+                    getEditor().getEditorComponent()).setText(comboBoxPathChooser.getSelectedItem().toString());
+        }
+    }
+
     private final class PathChooserComboBoxCellRenderer extends DefaultListCellRenderer {
 
         private  final ImageIcon rightArrow = ModelerUtil.buildIcon("scroll_right.gif");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/16ee5203/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/SortButtonRenderer.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/SortButtonRenderer.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/SortButtonRenderer.java
index a68998e..1cab21a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/SortButtonRenderer.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/SortButtonRenderer.java
@@ -20,7 +20,6 @@ package org.apache.cayenne.modeler.util;
 
 import javax.swing.BorderFactory;
 import javax.swing.ImageIcon;
-import javax.swing.JButton;
 import javax.swing.JLabel;
 import javax.swing.JTable;
 import javax.swing.border.CompoundBorder;
@@ -58,12 +57,11 @@ public class SortButtonRenderer  extends DefaultTableCellRenderer {
         }
 
         setText( ((value == null) ? "" : value.toString()));
-        setFont(new Font("Verdana", Font.BOLD , 13));
+        setFont(new Font("Verdana", Font.BOLD, 12));
         setHorizontalTextPosition(JLabel.LEFT);
-        setOpaque(true);
-        setBackground(new JButton().getBackground());
-        CompoundBorder compoundBorder = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY,
1),
-                BorderFactory.createEmptyBorder(0, 4, 0, 0));
+        CompoundBorder compoundBorder = BorderFactory.createCompoundBorder(
+                BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY),
+                BorderFactory.createEmptyBorder(0, 5, 0, 0));
         setBorder(compoundBorder);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/16ee5203/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/AutoCompletion.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/AutoCompletion.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/AutoCompletion.java
index 86ec2b5..e5839da 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/AutoCompletion.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/AutoCompletion.java
@@ -20,11 +20,9 @@
 package org.apache.cayenne.modeler.util.combo;
 
 import javax.swing.JComboBox;
-import javax.swing.JScrollBar;
-import javax.swing.JScrollPane;
+import javax.swing.JList;
 import javax.swing.SwingUtilities;
 import javax.swing.text.JTextComponent;
-import java.awt.Component;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 import java.awt.event.KeyEvent;
@@ -156,8 +154,6 @@ public class AutoCompletion implements FocusListener, KeyListener, Runnable
{
 
         //scroll doesn't work in suggestionList..so we will scroll manually
         suggestionListScrolling();
-
-        textEditor.requestFocus();
     }
 
     private void   processKeyPressedWhenSuggestionListIsInvisible(KeyEvent e){
@@ -274,20 +270,14 @@ public class AutoCompletion implements FocusListener, KeyListener, Runnable
{
                     comboBox.setSelectedIndex(next);
                 }
             }
+            textEditor.requestFocus();
         }
     }
 
     private void suggestionListScrolling(){
-        Component c = suggestionList.getComponent(0);
-        if (c instanceof JScrollPane) {
-            int itemCount = suggestionList.getItemCount();
-            int selectedIndex = suggestionList.getSelectedIndex();
-            JScrollPane scrollPane = (JScrollPane) c;
-            JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
-            double height = scrollBar.getMaximum();
-            double scrollValue = Math.ceil(height*selectedIndex/itemCount);
-            scrollBar.setValue((int) scrollValue);
-        }
+        JList list = suggestionList.getList();
+        int selectedIndex = suggestionList.getSelectedIndex();
+        list.ensureIndexIsVisible(selectedIndex);
     }
 }
 


Mime
View raw message