[hg] main-silver: #227456: Add Properties and Create Fixed Watch...

  • From:
  • To:
  • Subject: [hg] main-silver: #227456: Add Properties and Create Fixed Watch...
  • Date: Fri, 26 Apr 2013 21:47:48 -0700

changeset 35604cda159f in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/35604cda159f
description:
        #227456: Add Properties and Create Fixed Watch action on the GUI 
snapshot and component tree.

diffstat:

 
debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/FixedWatchesManager.java
                    |    2 +-
 debugger.jpda.visual/nbproject/project.xml                                   
                          |    8 +
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteAWTScreenshot.java
            |    5 +
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/Bundle.properties
           |    2 +
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/CreateFixedWatchAction.java
 |  115 ++++++++++
 5 files changed, 131 insertions(+), 1 deletions(-)

diffs (195 lines):

diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/FixedWatchesManager.java
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/FixedWatchesManager.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/FixedWatchesManager.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/FixedWatchesManager.java
@@ -372,7 +372,7 @@
         }
     }
 
-    private void addFixedWatch (String name, Variable variable) {
+    public void addFixedWatch (String name, Variable variable) {
         // Clone the variable to assure that it's unique and sticks to the 
JDI value.
         if (variable instanceof Cloneable) {
             try { // terrible code to invoke the clone() method
diff --git a/debugger.jpda.visual/nbproject/project.xml 
b/debugger.jpda.visual/nbproject/project.xml
--- a/debugger.jpda.visual/nbproject/project.xml
+++ b/debugger.jpda.visual/nbproject/project.xml
@@ -151,6 +151,14 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>org.openide.actions</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>6.31</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>org.openide.awt</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteAWTScreenshot.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteAWTScreenshot.java
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteAWTScreenshot.java
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteAWTScreenshot.java
@@ -90,6 +90,7 @@
 import org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl;
 import org.netbeans.modules.debugger.jpda.visual.RemoteServices.ServiceType;
 import 
org.netbeans.modules.debugger.jpda.visual.actions.ComponentBreakpointActionProvider;
+import 
org.netbeans.modules.debugger.jpda.visual.actions.CreateFixedWatchAction;
 import 
org.netbeans.modules.debugger.jpda.visual.actions.GoToAddIntoHierarchyAction;
 import 
org.netbeans.modules.debugger.jpda.visual.actions.GoToFieldDeclarationAction;
 import org.netbeans.modules.debugger.jpda.visual.actions.GoToSourceAction;
@@ -99,6 +100,7 @@
 import 
org.netbeans.modules.debugger.jpda.visual.models.ComponentBreakpointsActionsProvider;
 import org.netbeans.modules.debugger.jpda.visual.spi.ComponentInfo;
 import org.netbeans.modules.debugger.jpda.visual.spi.RemoteScreenshot;
+import org.openide.actions.PropertiesAction;
 import org.openide.nodes.Node;
 import org.openide.util.Exceptions;
 import org.openide.util.HelpCtx;
@@ -772,11 +774,14 @@
             }
             actions.add(null);
             actions.add(ShowListenersAction.get(ShowListenersAction.class));
+            
actions.add(CreateFixedWatchAction.get(CreateFixedWatchAction.class));
             actions.add(null);
             
actions.add(ToggleComponentBreakpointAction.get(ToggleComponentBreakpointAction.class));
             if (b != null) {
                 actions.add(CBP_CUSTOMIZE_ACTION);
             }
+            actions.add(null);
+            actions.add(PropertiesAction.get(PropertiesAction.class));
             return actions.toArray(new Action[] {});
         }
 
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/Bundle.properties
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/Bundle.properties
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/Bundle.properties
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/Bundle.properties
@@ -52,5 +52,7 @@
 
 MSG_NoSourceFile=Cannot find source file {0} for class {1}.
 
+CTL_CreateFixedWatch=Create Fixed Watch
+
 # {0} - The language
 USG_DEBUG_VISUAL={0} Visual Debugger
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/CreateFixedWatchAction.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/CreateFixedWatchAction.java
new file mode 100644
--- /dev/null
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/actions/CreateFixedWatchAction.java
@@ -0,0 +1,115 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.debugger.jpda.visual.actions;
+
+import com.sun.jdi.ObjectReference;
+import java.util.Iterator;
+import java.util.List;
+import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+import org.netbeans.modules.debugger.jpda.ui.FixedWatchesManager;
+import org.netbeans.modules.debugger.jpda.visual.JavaComponentInfo;
+import org.netbeans.spi.viewmodel.NodeActionsProviderFilter;
+import org.openide.nodes.Node;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle;
+import org.openide.util.actions.NodeAction;
+
+/**
+ * Add the component as a fixed watch so that it can be examined there.
+ * 
+ * @author Martin Entlicher
+ */
+public class CreateFixedWatchAction extends NodeAction {
+
+    @Override
+    public String getName() {
+        return NbBundle.getMessage(GoToSourceAction.class, 
"CTL_CreateFixedWatch");
+    }
+
+    @Override
+    protected boolean enable(Node[] activatedNodes) {
+        boolean enabled = false;
+        for (Node n : activatedNodes) {
+            JavaComponentInfo ci = 
n.getLookup().lookup(JavaComponentInfo.class);
+            if (ci != null) {
+                enabled = true;
+                break;
+            }
+        }
+        return enabled;
+        
+    }
+
+    @Override
+    protected void performAction(Node[] activatedNodes) {
+        for (Node n : activatedNodes) {
+            JavaComponentInfo ci = 
n.getLookup().lookup(JavaComponentInfo.class);
+            if (ci != null) {
+                addFixedWatch(ci);
+            }
+        }
+    }
+    
+    private void addFixedWatch(JavaComponentInfo ci) {
+        JPDADebuggerImpl debugger = ci.getThread().getDebugger();
+        List list = debugger.getSession().lookup("WatchesView", 
NodeActionsProviderFilter.class); // NOI18N
+        FixedWatchesManager fwman = null;
+        for (Iterator iter = list.iterator(); iter.hasNext();)  {
+            Object obj = iter.next();
+            if (obj instanceof FixedWatchesManager) {
+                fwman = (FixedWatchesManager) obj;
+                break;
+            }
+        }
+        if (fwman != null) {
+            ObjectReference component = ci.getComponent();
+            fwman.addFixedWatch(ci.getDisplayName(), 
debugger.getVariable(component));
+        }
+        
+    }
+
+    @Override
+    public HelpCtx getHelpCtx() {
+        return new HelpCtx(CreateFixedWatchAction.class);
+    }
+    
+}

[hg] main-silver: #227456: Add Properties and Create Fixed Watch...

mentlicher 04/27/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 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