This is an automated email from the git hooks/post-receive script.

ben pushed a commit to branch master
in repository autocomplete.

commit 456d1867bd541be670ab20d61211454ad93d8417
Author: bobbylight <[email protected]>
Date:   Wed Jun 17 13:21:15 2009 +0000

    Better RTL support for AutoComplete.
---
 .../ui/autocomplete/AutoCompleteDescWindow.java     |   19 +++++++++++++------
 .../ui/autocomplete/AutoCompletePopupWindow.java    |    7 ++++---
 src/org/fife/ui/autocomplete/AutoCompletion.java    |   17 +++++++++++++++++
 src/org/fife/ui/autocomplete/SizeGrip.java          |    9 ++++-----
 4 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java 
b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
index 022a7fa..e90d59c 100644
--- a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
@@ -25,6 +25,7 @@ package org.fife.ui.autocomplete;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.ComponentOrientation;
 import java.awt.Font;
 import java.awt.SystemColor;
 import java.awt.Window;
@@ -132,6 +133,8 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
                super(owner);
                this.ac = ac;
 
+               ComponentOrientation o = ac.getTextComponentOrientation();
+               
                JPanel cp = new JPanel(new BorderLayout());
 //             cp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
 
@@ -145,8 +148,8 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
                cp.add(scrollPane);
 
                descWindowNavBar = new JToolBar();
-               backAction = new ToolBarBackAction();
-               forwardAction = new ToolBarForwardAction();
+               backAction = new ToolBarBackAction(o.isLeftToRight());
+               forwardAction = new ToolBarForwardAction(o.isLeftToRight());
                descWindowNavBar.setFloatable(false);
                descWindowNavBar.add(new JButton(backAction));
                descWindowNavBar.add(new JButton(forwardAction));
@@ -404,9 +407,11 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
         */
        class ToolBarBackAction extends AbstractAction {
 
-               public ToolBarBackAction() {
+               public ToolBarBackAction(boolean ltr) {
+                       String img = "org/fife/ui/autocomplete/arrow_" +
+                                               (ltr ? "left.png" : 
"right.png");
                        ClassLoader cl = getClass().getClassLoader();
-                       URL url = 
cl.getResource("org/fife/ui/autocomplete/arrow_left.png");
+                       URL url = cl.getResource(img);
                        try {
                                Icon icon = new ImageIcon(ImageIO.read(url));
                                putValue(Action.SMALL_ICON, icon);
@@ -432,9 +437,11 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
         */
        class ToolBarForwardAction extends AbstractAction {
 
-               public ToolBarForwardAction() {
+               public ToolBarForwardAction(boolean ltr) {
+                       String img = "org/fife/ui/autocomplete/arrow_" +
+                                                       (ltr ? "right.png" : 
"left.png");
                        ClassLoader cl = getClass().getClassLoader();
-                       URL url = 
cl.getResource("org/fife/ui/autocomplete/arrow_right.png");
+                       URL url = cl.getResource(img);
                        try {
                                Icon icon = new ImageIcon(ImageIO.read(url));
                                putValue(Action.SMALL_ICON, icon);
diff --git a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java 
b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
index 3cd33b4..a758582 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
@@ -136,7 +136,7 @@ class AutoCompletePopupWindow extends JWindow implements 
CaretListener,
        public AutoCompletePopupWindow(Window parent, AutoCompletion ac) {
 
                super(parent);
-               ComponentOrientation o = parent.getComponentOrientation();
+               ComponentOrientation o = ac.getTextComponentOrientation();
 
                this.ac = ac;
                model = new CompletionListModel();
@@ -197,6 +197,7 @@ class AutoCompletePopupWindow extends JWindow implements 
CaretListener,
         */
        private AutoCompleteDescWindow createDescriptionWindow() {
                AutoCompleteDescWindow dw = new AutoCompleteDescWindow(this, 
ac);
+               dw.applyComponentOrientation(ac.getTextComponentOrientation());
                Dimension size = preferredDescWindowSize;
                if (size==null) {
                        size = getSize();
@@ -385,7 +386,7 @@ class AutoCompletePopupWindow extends JWindow implements 
CaretListener,
 
                // Try to position to the right first (LTR)
                int x; 
-               if (getComponentOrientation().isLeftToRight()) {
+               if (ac.getTextComponentOrientation().isLeftToRight()) {
                        x = getX() + getWidth() + 5;
                        if (x+descWindow.getWidth()>screenSize.width) { // 
doesn't fit
                                x = getX() - 5 - descWindow.getWidth();
@@ -616,7 +617,7 @@ class AutoCompletePopupWindow extends JWindow implements 
CaretListener,
                // Get x-coordinate of completions.  Try to align left edge 
with the
                // caret first.
                int x = r.x;
-               if (!getComponentOrientation().isLeftToRight()) {
+               if (!ac.getTextComponentOrientation().isLeftToRight()) {
                        x -= getWidth(); // RTL => align right edge
                }
                if (x<0) {
diff --git a/src/org/fife/ui/autocomplete/AutoCompletion.java 
b/src/org/fife/ui/autocomplete/AutoCompletion.java
index 65d0684..33dea51 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletion.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletion.java
@@ -368,6 +368,18 @@ public class AutoCompletion implements HierarchyListener {
 
 
        /**
+        * Returns the orientation of the text component we're installed to.
+        *
+        * @return The orientation of the text component, or <code>null</code> 
if
+        *         we are not installed on one.
+        */
+       ComponentOrientation getTextComponentOrientation() {
+               return textComponent==null ? null :
+                                                                       
textComponent.getComponentOrientation();
+       }
+
+
+       /**
         * Returns the "trigger key" used for autocomplete.
         *
         * @return The trigger key.
@@ -613,6 +625,11 @@ try {
 
                        if (popupWindow==null) {
                                popupWindow = new 
AutoCompletePopupWindow(parentWindow, this);
+                               // Completion is usually done for code, which 
is always done
+                               // LTR, so make completion stuff RTL only if 
text component is
+                               // also RTL.
+                               popupWindow.applyComponentOrientation(
+                                                                               
        getTextComponentOrientation());
                                if (renderer!=null) {
                                        
popupWindow.setListCellRenderer(renderer);
                                }
diff --git a/src/org/fife/ui/autocomplete/SizeGrip.java 
b/src/org/fife/ui/autocomplete/SizeGrip.java
index df2ddd6..637268d 100644
--- a/src/org/fife/ui/autocomplete/SizeGrip.java
+++ b/src/org/fife/ui/autocomplete/SizeGrip.java
@@ -62,7 +62,6 @@ class SizeGrip extends JPanel {
                MouseHandler adapter = new MouseHandler();
                addMouseListener(adapter);
                addMouseMotionListener(adapter);
-               
possiblyFixCursor(ComponentOrientation.getOrientation(getLocale()));
                setPreferredSize(new Dimension(16, 16));
        }
 
@@ -74,7 +73,7 @@ class SizeGrip extends JPanel {
         * @param o The new orientation.
         */
        public void applyComponentOrientation(ComponentOrientation o) {
-               possiblyFixCursor(o);
+               possiblyFixCursor(o.isLeftToRight());
                super.applyComponentOrientation(o);
        }
 
@@ -176,11 +175,11 @@ class SizeGrip extends JPanel {
         * Ensures that the cursor for this component is appropriate for the
         * orientation.
         *
-        * @param o The new orientation.
+        * @param ltr Whether the current component orientation is LTR.
         */
-       protected void possiblyFixCursor(ComponentOrientation o) {
+       protected void possiblyFixCursor(boolean ltr) {
                int cursor = Cursor.NE_RESIZE_CURSOR;
-               if (o.isLeftToRight()) {
+               if (ltr) {
                        cursor = Cursor.NW_RESIZE_CURSOR;
                }
                if (cursor!=getCursor().getType()) {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-java/autocomplete.git

_______________________________________________
pkg-java-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to