This is an automated email from the git hooks/post-receive script. ben pushed a commit to branch master in repository autocomplete.
commit f5929fc57d81099931125b839983decff9b35621 Author: bobbylight <[email protected]> Date: Mon Jun 15 13:43:20 2009 +0000 Better RTL support. Completion popup now properly aligns its right side with the caret for RTL locales. The size grip also properly resizes the popup in RTL. --- build.xml | 2 +- .../ui/autocomplete/AutoCompletePopupWindow.java | 26 ++++++++++++++++---- src/org/fife/ui/autocomplete/AutoCompletion.java | 22 +++++++++++++---- src/org/fife/ui/autocomplete/SizeGrip.java | 23 +++++++++++------ 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/build.xml b/build.xml index 3b40889..727a041 100644 --- a/build.xml +++ b/build.xml @@ -6,7 +6,7 @@ Available targets include: 1. compile: Compiles all org.fife classes into ${class-dir}. - 2. make-jar: Creates the jar file. + 2. make-jar: Createqs the jar file. 3. make-source-zip: Creates a source zip file. 3. make-javadoc: Creates the javadoc for RSyntaxTextArea. diff --git a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java index c0807c2..3cd33b4 100644 --- a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java +++ b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java @@ -24,6 +24,7 @@ package org.fife.ui.autocomplete; import java.awt.BorderLayout; +import java.awt.ComponentOrientation; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Toolkit; @@ -135,6 +136,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, public AutoCompletePopupWindow(Window parent, AutoCompletion ac) { super(parent); + ComponentOrientation o = parent.getComponentOrientation(); this.ac = ac; model = new CompletionListModel(); @@ -154,13 +156,14 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, // here. JPanel corner = new SizeGrip(); //sp.setCorner(JScrollPane.LOWER_TRAILING_CORNER, corner); - boolean isLeftToRight = getComponentOrientation().isLeftToRight(); + boolean isLeftToRight = o.isLeftToRight(); String str = isLeftToRight ? JScrollPane.LOWER_RIGHT_CORNER : JScrollPane.LOWER_LEFT_CORNER; sp.setCorner(str, corner); contentPane.add(sp); setContentPane(contentPane); + applyComponentOrientation(o); pack(); setFocusableWindowState(false); @@ -367,7 +370,8 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, /** * Positions the description window relative to the completion choices - * window. + * window. We assume there is room on one side of the other for this + * entire window to fit. */ private void positionDescWindow() { @@ -379,10 +383,19 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, Dimension screenSize = getToolkit().getScreenSize(); //int totalH = Math.max(getHeight(), descWindow.getHeight()); - // Try to position to the right first. - int x = getX() + getWidth() + 5; - if (x+descWindow.getWidth()>screenSize.width) { // doesn't fit + // Try to position to the right first (LTR) + int x; + if (getComponentOrientation().isLeftToRight()) { + x = getX() + getWidth() + 5; + if (x+descWindow.getWidth()>screenSize.width) { // doesn't fit + x = getX() - 5 - descWindow.getWidth(); + } + } + else { // RTL x = getX() - 5 - descWindow.getWidth(); + if (x<0) { // Doesn't fit + x = getX() + getWidth() + 5; + } } int y = getY(); @@ -603,6 +616,9 @@ 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()) { + x -= getWidth(); // RTL => align right edge + } if (x<0) { x = 0; } diff --git a/src/org/fife/ui/autocomplete/AutoCompletion.java b/src/org/fife/ui/autocomplete/AutoCompletion.java index 8d10c42..65d0684 100644 --- a/src/org/fife/ui/autocomplete/AutoCompletion.java +++ b/src/org/fife/ui/autocomplete/AutoCompletion.java @@ -406,33 +406,45 @@ public class AutoCompletion implements HierarchyListener { /** * Hides any child windows being displayed by the auto-completion system. + * + * @return Whether any windows were visible. */ - public void hideChildWindows() { - hidePopupWindow(); - hideToolTipWindow(); + public boolean hideChildWindows() { + //return hidePopupWindow() || hideToolTipWindow(); + boolean res = hidePopupWindow(); + res |= hideToolTipWindow(); + return res; } /** * Hides the popup window, if it is visible. + * + * @return Whether the popup window was visible. */ - private void hidePopupWindow() { + private boolean hidePopupWindow() { if (popupWindow!=null) { if (popupWindow.isVisible()) { popupWindow.setVisible(false); + return true; } } + return false; } /** * Hides the parameter tool tip, if it is visible. + * + * @return Whether the tool tip window was visible. */ - private void hideToolTipWindow() { + private boolean hideToolTipWindow() { if (descToolTip!=null) { descToolTip.setVisible(false, false); descToolTip = null; + return true; } + return false; } diff --git a/src/org/fife/ui/autocomplete/SizeGrip.java b/src/org/fife/ui/autocomplete/SizeGrip.java index f967021..df2ddd6 100644 --- a/src/org/fife/ui/autocomplete/SizeGrip.java +++ b/src/org/fife/ui/autocomplete/SizeGrip.java @@ -229,16 +229,23 @@ class SizeGrip extends JPanel { int yDelta = newPos.y - origPos.y; Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this); if (wind!=null) { // Should always be true - int w = wind.getWidth(); - if (newPos.x>=wind.getX()) { - w += xDelta; + if (getComponentOrientation().isLeftToRight()) { + int w = wind.getWidth(); + if (newPos.x>=wind.getX()) { + w += xDelta; + } + int h = wind.getHeight(); + if (newPos.y>=wind.getY()) { + h += yDelta; + } + wind.setSize(w,h); } - int h = wind.getHeight(); - if (newPos.y>=wind.getY()) { - h += yDelta; + else { // RTL + int newW = Math.max(1, wind.getWidth()-xDelta); + int newH = Math.max(1, wind.getHeight()+yDelta); + wind.setBounds(newPos.x, wind.getY(), newW, newH); } - wind.setSize(w,h); - // invalidate()/revalidate() needed pre-1.6. + // invalidate()/validate() needed pre-1.6. wind.invalidate(); wind.validate(); } -- 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

