You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/03/24 00:25:30 UTC

svn commit: r757591 - /incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java

Author: tvolkert
Date: Mon Mar 23 23:25:30 2009
New Revision: 757591

URL: http://svn.apache.org/viewvc?rev=757591&view=rev
Log:
Updated TreeViewNodeEditor to not use the popup affiliate

Modified:
    incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java?rev=757591&r1=757590&r2=757591&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeEditor.java Mon Mar 23 23:25:30 2009
@@ -65,10 +65,6 @@
         }
 
         public void windowOpened(Window window) {
-            // Add this as a container mouse listener on display
-            Display display = window.getDisplay();
-            display.getContainerMouseListeners().add(displayMouseHandler);
-
             treeView.getTreeViewListeners().add(treeViewHandler);
             treeView.getTreeViewBranchListeners().add(treeViewHandler);
             treeView.getTreeViewNodeListeners().add(treeViewHandler);
@@ -85,7 +81,6 @@
 
         public void windowClosed(Window window, Display display) {
             // Clean up
-            display.getContainerMouseListeners().remove(displayMouseHandler);
             treeView.getTreeViewListeners().remove(treeViewHandler);
             treeView.getTreeViewBranchListeners().remove(treeViewHandler);
             treeView.getTreeViewNodeListeners().remove(treeViewHandler);
@@ -152,44 +147,6 @@
     };
 
     /**
-     * Responsible for closing the popup whenever the user clicks outside the
-     * bounds of the popup. This is required because the popup affiliates
-     * itself with the tree view, meaning that the popup won't close itself
-     * automatically when the user clicks on the tree view. Further, we don't
-     * want to register a mouse button listener on the tree view, because we
-     * want to intercept the mouse event during the tunneling phase.
-     *
-     * @author tvolkert
-     */
-    private ContainerMouseListener displayMouseHandler = new ContainerMouseListener() {
-        public void mouseMove(Container container, int x, int y) {
-            // No-op
-        }
-
-        public void mouseDown(Container container, Mouse.Button button, int x, int y) {
-            // If the event did not occur within a window that is owned by
-            // this popup, close the popup
-            Display display = (Display)container;
-            Window window = (Window)display.getComponentAt(x, y);
-
-            if (popup != null
-                && (window == null
-                || !popup.isOwningAncestorOf(window))) {
-                popup.close();
-            }
-        }
-
-        public void mouseUp(Container container, Mouse.Button button, int x, int y) {
-            // No-op
-        }
-
-        public void mouseWheel(Container container, Mouse.ScrollType scrollType,
-            int scrollAmount, int wheelRotation, int x, int y) {
-            // No-op
-        }
-    };
-
-    /**
      * Responsible for cancelling the edit if any relevant changes are made to
      * the tree view while we're editing.
      */
@@ -324,6 +281,13 @@
         textBounds.x += textIndent;
         textBounds.width -= textIndent;
 
+        // Scroll to make the text as visible as possible
+        nodeRenderer.render(nodeData, treeView, false, false,
+            TreeView.NodeCheckState.UNCHECKED, false, false);
+        Component textComponent = nodeRenderer.get(1);
+        int textWidth = textComponent.getPreferredWidth(-1);
+        treeView.scrollAreaToVisible(textBounds.x, textBounds.y, textWidth + 3, textBounds.height);
+
         // Constrain the bounds by what is visible through Viewport ancestors
         treeView.constrainToViewportBounds(textBounds);
 
@@ -337,7 +301,7 @@
         popup.setLocation(displayCoordinates.x + textBounds.x, displayCoordinates.y +
             textBounds.y + (textBounds.height - textInput.getPreferredHeight(-1)) / 2);
         popup.getWindowStateListeners().add(popupStateHandler);
-        popup.open(treeView);
+        popup.open(treeView.getWindow());
 
         textInput.requestFocus();
     }