You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2013/11/15 05:56:50 UTC

svn commit: r1542172 - in /pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra: TerraFileBrowserSkin.java TerraVFSBrowserSkin.java

Author: rwhitcomb
Date: Fri Nov 15 04:56:49 2013
New Revision: 1542172

URL: http://svn.apache.org/r1542172
Log:
PIVOT-930: Extend the solution to the VFS Browser (which is based on the
basic file browser).


Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java?rev=1542172&r1=1542171&r2=1542172&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java Fri Nov 15 04:56:49 2013
@@ -935,7 +935,7 @@ public class TerraFileBrowserSkin extend
                 String text = null;
 
                 if (file != null){
-                    text = text = file.getName();
+                    text = file.getName();
                 }
 
                 if (text == null || text.isEmpty()) {

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java?rev=1542172&r1=1542171&r2=1542172&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraVFSBrowserSkin.java Fri Nov 15 04:56:49 2013
@@ -1052,6 +1052,59 @@ public class TerraVFSBrowserSkin extends
         });
 
         fileTableView.setSort(TableViewFileRenderer.NAME_KEY, SortDirection.ASCENDING);
+        fileTableView.getComponentTooltipListeners().add(new ComponentTooltipListener() {
+ 
+            @Override
+            public void tooltipTriggered(Component component, int x, int y) {
+
+                // Check that we are on the first column.
+                if (fileTableView.getColumnAt(x) != 0) {
+                    return;
+                }
+
+                // Gets the underlying file
+                FileObject file = (FileObject) fileTableView.getTableData().get(fileTableView.getRowAt(y));
+
+                // Construct and show the tooltip.
+                final Tooltip tooltip = new Tooltip();
+
+                String text = null;
+
+                if (file != null){
+                    text = file.getName().getBaseName();
+                }
+
+                if (text == null || text.isEmpty()) {
+                    return;
+                }
+
+                TextArea toolTipTextArea = new TextArea();
+
+                toolTipTextArea.setText(text);
+                toolTipTextArea.getStyles().put("wrapText", true);
+
+                tooltip.setContent(toolTipTextArea);
+
+                Point location = component.getDisplay().getMouseLocation();
+                x = location.x;
+                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;
+                }
+
+                int tooltipXOffset = 16;
+                int padding = 15;
+                
+                toolTipTextArea.setMaximumWidth(display.getWidth() - ( x + tooltipXOffset + padding) );
+                tooltip.setLocation(x + tooltipXOffset, y);
+                tooltip.open(component.getWindow());
+            }
+        });
+
         rootDirectoryChanged(fileBrowser, null);
         selectedFilesChanged(fileBrowser, null);
     }