--- a/spi.debugger.ui/manifest.mf +++ a/spi.debugger.ui/manifest.mf @@ -2,6 +2,5 @@ OpenIDE-Module: org.netbeans.spi.debugger.ui/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml -OpenIDE-Module-Specification-Version: 2.44 OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class --- a/spi.debugger.ui/nbproject/project.properties +++ a/spi.debugger.ui/nbproject/project.properties @@ -44,6 +44,7 @@ javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.6 javadoc.arch=${basedir}/arch.xml +spec.version.base=2.44.0 test.config.stableBTD.includes=**/*Test.class test.config.stableBTD.excludes=\ --- a/spi.debugger.ui/nbproject/project.xml +++ a/spi.debugger.ui/nbproject/project.xml @@ -109,7 +109,8 @@ 1 - 1.24 + + --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java +++ a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java @@ -52,6 +52,7 @@ import java.beans.PropertyChangeListener; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.LinkedList; import java.util.List; import javax.swing.Action; import javax.swing.ImageIcon; @@ -61,15 +62,20 @@ import javax.swing.JPopupMenu; import javax.swing.JSeparator; import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.api.debugger.Properties; import org.netbeans.api.project.Project; import org.netbeans.api.project.ui.OpenProjects; +import org.netbeans.modules.project.uiapi.BuildExecutionSupportImplementation; +import org.netbeans.modules.project.uiapi.Utilities; import org.netbeans.spi.debugger.ui.AttachType; import org.netbeans.spi.debugger.ui.Controller; import org.netbeans.spi.project.ActionProvider; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; import org.netbeans.spi.project.ui.support.MainProjectSensitiveActions; import org.openide.awt.Actions; import org.openide.awt.DropDownButtonFactory; @@ -78,6 +84,7 @@ import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; +import org.openide.util.WeakListeners; import org.openide.util.WeakSet; import org.openide.util.actions.Presenter; @@ -89,8 +96,9 @@ private static WeakSet ahs = null; - private Action delegate; - private AttachHistorySupport attachHistorySupport; + private final Action delegate; + private final DebugHistorySupport debugHistorySupport; + private final AttachHistorySupport attachHistorySupport; /** Creates a new instance of DebugMainProjectAction */ public DebugMainProjectAction() { @@ -98,6 +106,9 @@ ActionProvider.COMMAND_DEBUG, NbBundle.getMessage(DebugMainProjectAction.class, "LBL_DebugMainProjectAction_Name" ),ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/debugProject.png", false)); // NOI18N delegate.putValue("iconBase","org/netbeans/modules/debugger/resources/debugProject.png"); //NOI18N + //BuildExecutionSupport.registerFinishedItem(null); + //Utilities.getBuildExecutionSupportImplementation().getRunningItems(); + debugHistorySupport = new DebugHistorySupport(); attachHistorySupport = new AttachHistorySupport(); } @@ -188,6 +199,7 @@ @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JPopupMenu menu = (JPopupMenu)e.getSource(); + debugHistorySupport.init(menu); attachHistorySupport.init(menu); menu.removePopupMenuListener(this); } @@ -199,6 +211,102 @@ } // AttachHistorySupport ..................................................... + + private static class DebugHistorySupport implements ActionListener, ChangeListener { + + private JPopupMenu menu; + private JMenuItem[] items = new JMenuItem[0]; + private final JSeparator separator1 = new JPopupMenu.Separator(); + private final JSeparator separator2 = new JPopupMenu.Separator(); + private final BuildExecutionSupportImplementation besi; + private final LinkedList debugItems = new LinkedList(); + + private static final String DEBUG_ACTION_ITEM_PROP_NAME = "debug action item"; + private static final RequestProcessor RP = new RequestProcessor(DebugHistorySupport.class.getName()); + + public DebugHistorySupport() { + besi = Utilities.getBuildExecutionSupportImplementation(); + besi.addChangeListener(WeakListeners.change(this, besi)); + } + + void init(JPopupMenu menu) { + this.menu = menu; + computeItems(); + } + + private void computeItems() { + boolean wasSeparator = items.length > 0; + for (int i = 0; i < items.length; i++) { + menu.remove(items[i]); + } + synchronized (debugItems) { + if (debugItems.isEmpty()) { + items = new JMenuItem[0]; + } else { + int n = debugItems.size(); + items = new JMenuItem[n]; + int i = 0; + for (BuildExecutionSupport.ActionItem ai : debugItems) { + String dispName = ai.getDisplayName(); + items[i] = new JMenuItem(dispName); + items[i].putClientProperty(DEBUG_ACTION_ITEM_PROP_NAME, ai); + items[i].addActionListener(this); + i++; + } + } + } + if (items.length == 0) { + if (wasSeparator) { + menu.remove(separator1); + menu.remove(separator2); + } + } else { + if (!wasSeparator) { + menu.insert(separator1, 1); + } + int i; + for (i = 0; i < items.length; i++) { + menu.insert(items[i], i + 2); + } + menu.insert(separator2, i + 2); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + JMenuItem item = (JMenuItem)e.getSource(); + final BuildExecutionSupport.ActionItem ai = + (BuildExecutionSupport.ActionItem) item.getClientProperty(DEBUG_ACTION_ITEM_PROP_NAME); + RP.post(new Runnable() { + @Override + public void run() { + ai.repeatExecution(); + } + }); + } + + @Override + public void stateChanged(ChangeEvent e) { + BuildExecutionSupport.Item lastItem = besi.getLastItem(); + if (lastItem instanceof BuildExecutionSupport.ActionItem) { + BuildExecutionSupport.ActionItem ai = (BuildExecutionSupport.ActionItem) lastItem; + String action = ai.getAction(); + if (ActionProvider.COMMAND_DEBUG.equals(action)) { // Track debug items only + boolean changed = false; + synchronized (debugItems) { + if (debugItems.isEmpty() || ai != debugItems.getFirst()) { + debugItems.remove(ai); // Remove it if it's there + debugItems.addFirst(ai); + changed = true; + } + } + if (changed) { + computeItems(); + } + } + } + } + } static class AttachHistorySupport implements ActionListener {