diff -r b8470e9b3bac api.debugger/apichanges.xml --- a/api.debugger/apichanges.xml Wed Nov 03 16:50:14 2010 +0100 +++ b/api.debugger/apichanges.xml Fri Nov 05 13:34:33 2010 +0100 @@ -445,6 +445,24 @@ + + + Evaluate action is made generic, based on action providers. + + + + + +

+ Evaluate action is moved from JPDA Debugger into Debugger Core UI module. + ActionsManager.ACTION_EVALUATE constant was added for use by debugger-specific + provider (ActionsProvider) of Evaluate action. +

+
+ + +
+ diff -r b8470e9b3bac api.debugger/manifest.mf --- a/api.debugger/manifest.mf Wed Nov 03 16:50:14 2010 +0100 +++ b/api.debugger/manifest.mf Fri Nov 05 13:34:33 2010 +0100 @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.debugger/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/debugger/Bundle.properties -OpenIDE-Module-Specification-Version: 1.28 +OpenIDE-Module-Specification-Version: 1.29 OpenIDE-Module-Layer: org/netbeans/api/debugger/layer.xml diff -r b8470e9b3bac api.debugger/src/org/netbeans/api/debugger/ActionsManager.java --- a/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java Wed Nov 03 16:50:14 2010 +0100 +++ b/api.debugger/src/org/netbeans/api/debugger/ActionsManager.java Fri Nov 05 13:34:33 2010 +0100 @@ -113,7 +113,11 @@ * @since 1.24 */ public static final Object ACTION_NEW_WATCH = "newWatch"; - + /** Action constant for Evaluate Action. + * @since 1.29 */ + public static final Object ACTION_EVALUATE = "evaluate"; + + // variables ............................................................... private Vector listener = new Vector (); diff -r b8470e9b3bac debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml Wed Nov 03 16:50:14 2010 +0100 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/resources/mf-layer.xml Fri Nov 05 13:34:33 2010 +0100 @@ -119,7 +119,6 @@ - - - - diff -r b8470e9b3bac debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/actions/EvaluateAction.java --- a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/actions/EvaluateAction.java Wed Nov 03 16:50:14 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.modules.debugger.jpda.ui.actions; - -import java.awt.event.ActionEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.SwingUtilities; -import org.netbeans.api.debugger.DebuggerEngine; -import org.netbeans.api.debugger.DebuggerManager; -import org.netbeans.api.debugger.DebuggerManagerAdapter; -import org.netbeans.api.debugger.jpda.JPDADebugger; -import org.netbeans.modules.debugger.jpda.ui.CodeEvaluator; -import org.openide.util.NbBundle; - -/** - * Invokes the expression evaluator GUI - * - * @author Martin Entlicher - */ -public class EvaluateAction extends AbstractAction implements PropertyChangeListener, - Runnable { - - private EnableListener listener; - private transient Reference lastDebuggerRef = new WeakReference(null); - - public EvaluateAction () { -// listener = new EnableListener (this); -// DebuggerManager.getDebuggerManager().addDebuggerListener( -// DebuggerManager.PROP_CURRENT_ENGINE, -// listener); - putValue ( - Action.NAME, - NbBundle.getMessage(EvaluateAction.class, "CTL_Evaluate") // NOI18N - ); -// checkEnabled(); - } - - private synchronized boolean canBeEnabled() { - DebuggerEngine de = DebuggerManager.getDebuggerManager().getCurrentEngine(); - if (de == null) return false; - JPDADebugger debugger = de.lookupFirst(null, JPDADebugger.class); - JPDADebugger lastDebugger = (JPDADebugger) lastDebuggerRef.get(); - if (lastDebugger != null && debugger != lastDebugger) { - lastDebugger.removePropertyChangeListener( - JPDADebugger.PROP_CURRENT_THREAD, - this); - lastDebuggerRef = new WeakReference(null); - } - if (debugger != null) { - lastDebuggerRef = new WeakReference(debugger); - debugger.addPropertyChangeListener( - JPDADebugger.PROP_CURRENT_THREAD, - this); - return (debugger.getCurrentThread() != null); - } else { - return false; - } - } - - private void checkEnabled() { - SwingUtilities.invokeLater(this); - } - - public void run() { - setEnabled(canBeEnabled()); - } - - public void actionPerformed (ActionEvent evt) { -// DebuggerEngine de = DebuggerManager.getDebuggerManager().getCurrentEngine(); -// if (de == null) return; -// JPDADebugger debugger = de.lookupFirst(null, JPDADebugger.class); -// if (debugger == null) return; - - CodeEvaluator.openEvaluator(); - - // Evaluator2.open(debugger); - } - - public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - synchronized (this) { - JPDADebugger lastDebugger = (JPDADebugger) lastDebuggerRef.get(); - if (lastDebugger != null) { - setEnabled(lastDebugger.getCurrentThread() != null); - } - } - } - }); - } - - @Override - protected void finalize() throws Throwable { -// DebuggerManager.getDebuggerManager().removeDebuggerListener( -// DebuggerManager.PROP_CURRENT_ENGINE, -// listener); - } - - - private static class EnableListener extends DebuggerManagerAdapter { - - private Reference actionRef; - - public EnableListener(EvaluateAction action) { - actionRef = new WeakReference(action); - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - EvaluateAction action = (EvaluateAction) actionRef.get(); - if (action != null) { - action.checkEnabled(); - } - } - - } - -} diff -r b8470e9b3bac debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/actions/EvaluateActionProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/actions/EvaluateActionProvider.java Fri Nov 05 13:34:33 2010 +0100 @@ -0,0 +1,105 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ + +package org.netbeans.modules.debugger.jpda.ui.actions; + +import java.awt.event.ActionEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; +import java.util.Collections; +import java.util.Set; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.SwingUtilities; +import org.netbeans.api.debugger.ActionsManager; +import org.netbeans.api.debugger.DebuggerEngine; +import org.netbeans.api.debugger.DebuggerManager; +import org.netbeans.api.debugger.DebuggerManagerAdapter; +import org.netbeans.api.debugger.jpda.JPDADebugger; +import org.netbeans.modules.debugger.jpda.ui.CodeEvaluator; +import org.netbeans.spi.debugger.ActionsProvider; +import org.netbeans.spi.debugger.ContextProvider; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; + +/** + * Invokes the expression evaluator GUI + * + * @author Martin Entlicher + */ +@ActionsProvider.Registration(path="netbeans-JPDASession", actions="evaluate") +public class EvaluateActionProvider extends JPDADebuggerAction { + + public EvaluateActionProvider(ContextProvider lookupProvider) { + super ( + lookupProvider.lookupFirst(null, JPDADebugger.class) + ); + getDebuggerImpl ().addPropertyChangeListener + (JPDADebugger.PROP_CURRENT_THREAD, this); + } + + @Override + public Set getActions () { + return Collections.singleton (ActionsManager.ACTION_EVALUATE); + } + + @Override + protected void checkEnabled (int debuggerState) { + setEnabledSingleAction(getDebuggerImpl().getCurrentThread() != null); + } + + @Override + public void postAction(Object action, Runnable actionPerformedNotifier) { + CodeEvaluator.openEvaluator(); + } + + @Override + public void doAction(Object action) { + // Not called since we override postAction(). + throw new UnsupportedOperationException("Not supported."); + } + +} diff -r b8470e9b3bac spi.debugger.ui/src/org/netbeans/modules/debugger/resources/mf-layer.xml --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/resources/mf-layer.xml Wed Nov 03 16:50:14 2010 +0100 +++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/resources/mf-layer.xml Fri Nov 05 13:34:33 2010 +0100 @@ -146,6 +146,11 @@ + + + + + @@ -201,6 +206,10 @@ + + + + @@ -302,6 +311,9 @@ + + + diff -r b8470e9b3bac spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/Bundle.properties --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/Bundle.properties Wed Nov 03 16:50:14 2010 +0100 +++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/Bundle.properties Fri Nov 05 13:34:33 2010 +0100 @@ -115,6 +115,7 @@ #RunToCursorAction CTL_Run_to_cursor_action_name=R&un to Cursor +CTL_Evaluate=Evaluate E&xpression... #AddWatchPerformer CTL_WatchDialog_Title=New Watch diff -r b8470e9b3bac spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebuggerAction.java --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebuggerAction.java Wed Nov 03 16:50:14 2010 +0100 +++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebuggerAction.java Fri Nov 05 13:34:33 2010 +0100 @@ -282,6 +282,12 @@ return action; } + public static DebuggerAction createEvaluateAction() { + DebuggerAction action = new DebuggerAction(ActionsManager.ACTION_EVALUATE); + action.putValue (Action.NAME, "CTL_Evaluate"); // NOI18N + return action; + } + /** * Use this method to register an additional debugger action. * Register in a module layer manually as follows: