You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/22 23:54:30 UTC

svn commit: r787418 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: content/TableViewFileRenderer.java skin/ActivityIndicatorSkin.java skin/ComponentSkin.java skin/terra/TerraPushButtonSkin.java

Author: gbrown
Date: Mon Jun 22 21:54:30 2009
New Revision: 787418

URL: http://svn.apache.org/viewvc?rev=787418&view=rev
Log:
Various minor fixes.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewFileRenderer.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ActivityIndicatorSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewFileRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewFileRenderer.java?rev=787418&r1=787417&r2=787418&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewFileRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewFileRenderer.java Mon Jun 22 21:54:30 2009
@@ -95,25 +95,37 @@
      * prefixes (1KB = 1024 bytes).
      *
      * @param length
-     * The length of the file, in bytes.
+     * The length of the file, in bytes. May be <tt>-1</tt> to indicate an
+     * unknown file size.
+     *
+     * @return
+     * The formatted file size, or null if <tt>length</tt> is <tt>-1</tt>.
      */
     public static String format(long length) {
-        double size = length;
-
-        int i = -1;
-        do {
-            size /= KILOBYTE;
-            i++;
-        } while (size > KILOBYTE);
+        String formattedSize;
 
-        NumberFormat numberFormat = NumberFormat.getNumberInstance();
-        if (i == 0
-            && size > 1) {
-            numberFormat.setMaximumFractionDigits(0);
+        if (length == -1) {
+            formattedSize = null;
         } else {
-            numberFormat.setMaximumFractionDigits(1);
+            double size = length;
+
+            int i = -1;
+            do {
+                size /= KILOBYTE;
+                i++;
+            } while (size > KILOBYTE);
+
+            NumberFormat numberFormat = NumberFormat.getNumberInstance();
+            if (i == 0
+                && size > 1) {
+                numberFormat.setMaximumFractionDigits(0);
+            } else {
+                numberFormat.setMaximumFractionDigits(1);
+            }
+
+            formattedSize = numberFormat.format(size) + " " + ABBREVIATIONS[i] + "B";
         }
 
-        return numberFormat.format(size) + " " + ABBREVIATIONS[i] + "B";
+        return formattedSize;
     }
 }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ActivityIndicatorSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ActivityIndicatorSkin.java?rev=787418&r1=787417&r2=787418&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ActivityIndicatorSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ActivityIndicatorSkin.java Mon Jun 22 21:54:30 2009
@@ -43,6 +43,11 @@
         super.uninstall();
     }
 
+    @Override
+    public boolean isFocusable() {
+        return false;
+    }
+
     public void layout() {
         // No-op
     }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=787418&r1=787417&r2=787418&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Mon Jun 22 21:54:30 2009
@@ -30,6 +30,7 @@
 import org.apache.pivot.wtk.Cursor;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.Direction;
+import org.apache.pivot.wtk.Display;
 import org.apache.pivot.wtk.Keyboard;
 import org.apache.pivot.wtk.Mouse;
 import org.apache.pivot.wtk.Point;
@@ -55,9 +56,18 @@
             if (tooltipText != null) {
                 Tooltip tooltip = new Tooltip(tooltipText);
 
-                // TODO Ensure that the tooltip stays on screen
-                Point mouseLocation = component.getDisplay().getMouseLocation();
-                tooltip.setLocation(mouseLocation.x + 16, mouseLocation.y);
+                Point location = component.getDisplay().getMouseLocation();
+                int x = location.x;
+                int y = location.y;
+
+                // Ensure that the tooltip stays on screen
+                Display display = component.getDisplay();
+                int tooltipHeight = tooltip.getPreferredHeight();
+                if (y + tooltipHeight > display.getHeight()) {
+                    y -= tooltipHeight;
+                }
+
+                tooltip.setLocation(x + 16, y);
                 tooltip.open(component.getWindow());
             }
         }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java?rev=787418&r1=787417&r2=787418&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java Mon Jun 22 21:54:30 2009
@@ -34,7 +34,6 @@
 import org.apache.pivot.wtk.Theme;
 import org.apache.pivot.wtk.skin.PushButtonSkin;
 
-
 /**
  * Terra push button skin.
  *
@@ -502,4 +501,14 @@
 
         repaintComponent();
     }
+
+    @Override
+    public void mouseOut(Component component) {
+        super.mouseOut(component);
+
+        if (toolbar
+            && component.isFocused()) {
+            Component.clearFocus();
+        }
+    }
 }