[hg] main-silver: Issue #211766 - Double click on node does not ...

  • From: Ralph Benjamin Ruijs < >
  • To: , ,
  • Subject: [hg] main-silver: Issue #211766 - Double click on node does not ...
  • Date: Wed, 21 Nov 2012 10:06:21 -0800

changeset 27337b3c44d0 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/27337b3c44d0
description:
        Issue #211766 - Double click on node does not expand it

diffstat:

 
refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/CheckNodeListener.java
    |  37 +++++++--
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java
     |   2 +-
 
refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
 |  16 ++++-
 3 files changed, 45 insertions(+), 10 deletions(-)

diffs (129 lines):

diff --git 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/CheckNodeListener.java
 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/CheckNodeListener.java
--- 
a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/CheckNodeListener.java
+++ 
b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/CheckNodeListener.java
@@ -102,15 +102,25 @@
             if (isQuery) {
                 if (e.getClickCount() == 2) {
                     Object o = node.getUserObject();
-                    if (o instanceof TreeElement) {
+                    if (o instanceof Openable) {
+                        ((Openable) o).open();
+                    } else if (o instanceof TreeElement) {
                         o = ((TreeElement) o).getUserObject();
-                        if (o instanceof RefactoringElement || o instanceof 
FileObject) {
-                            findInSource(node);
-                        } else if (o instanceof Openable) {
-                            ((Openable) o).open();
+                        if (o instanceof RefactoringElement || o instanceof 
FileObject || o instanceof Openable) {
+                            if(!findInSource(node)) {
+                                if (tree.isCollapsed(row)) {
+                                    tree.expandRow(row);
+                                } else {
+                                    tree.collapseRow(row);
                         }
-                    } else if (o instanceof Openable) {
-                        ((Openable) o).open();
+                            }
+                        } else {
+                            if (tree.isCollapsed(row)) {
+                                tree.expandRow(row);
+                            } else {
+                                tree.collapseRow(row);
+                            }
+                        }
                     } else {
                         if (tree.isCollapsed(row)) {
                             tree.expandRow(row);
@@ -303,17 +313,26 @@
 
     }
 
-    static void findInSource(CheckNode node) {
+    static boolean findInSource(CheckNode node) {
         Object o = node.getUserObject();
         if (o instanceof TreeElement) {
+            if (o instanceof Openable) {
+                ((Openable) o).open();
+                return true;
+            } else {
             o = ((TreeElement) o).getUserObject();
             if (o instanceof RefactoringElement) {
                 
APIAccessor.DEFAULT.getRefactoringElementImplementation((RefactoringElement) 
o).openInEditor();
+                return true;
+            } else if (o instanceof Openable) {
+                ((Openable) o).open();
+                return true;
             } else if (o instanceof FileObject) {
                 try {
                     OpenCookie oc = DataObject.find((FileObject) 
o).getCookie(OpenCookie.class);
                     if (oc != null) {
                         oc.open();
+                        return true;
                     }
                 } catch (DataObjectNotFoundException ex) {
                     //ignore, unknown file, do nothing
@@ -321,6 +340,8 @@
             }
         }
     }
+        return false;
+    }
 
     static void openDiff(CheckNode node) {
         Object o = node.getUserObject();
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java
@@ -101,7 +101,7 @@
         // API support.
         
this.query.getContext().add(RefactoringUtils.getClasspathInfoFor(handle));
         this.element = handle;
-        if (UIUtilities.allowedElementKinds.contains(element.getKind())) {
+        if (UIUtilities.allowedElementKinds.contains(el.getKind())) {
             elementHandle = ElementHandle.create(el);
         }
         kind = el.getKind();
diff --git 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
--- 
a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
+++ 
b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java
@@ -48,6 +48,7 @@
 import java.beans.BeanInfo;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
+import org.netbeans.api.actions.Openable;
 import org.netbeans.api.project.FileOwnerQuery;
 import org.netbeans.api.project.Project;
 import org.netbeans.modules.refactoring.spi.ui.TreeElement;
@@ -55,13 +56,16 @@
 import org.openide.filesystems.FileObject;
 import org.openide.loaders.DataObject;
 import org.openide.loaders.DataObjectNotFoundException;
+import org.openide.text.Line;
+import org.openide.text.NbDocument;
+import org.openide.util.Exceptions;
 import org.openide.util.ImageUtilities;
 
 /**
  *
  * @author Jan Becicka
  */
-public class FileTreeElement implements TreeElement {
+public class FileTreeElement implements TreeElement, Openable {
 
     private FileObject fo;
     FileTreeElement(FileObject fo) {
@@ -104,4 +108,14 @@
     public Object getUserObject() {
         return fo;
     }
+
+    @Override
+    public void open() {
+        try {
+            DataObject od = DataObject.find(fo);
+            NbDocument.openDocument(od, 0, Line.ShowOpenType.OPEN, 
Line.ShowVisibilityType.FOCUS);
+        } catch (DataObjectNotFoundException ex) {
+            Exceptions.printStackTrace(ex);
 }
+    }
+}

[hg] main-silver: Issue #211766 - Double click on node does not ...

Ralph Benjamin Ruijs 11/21/2012

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close