--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,1 @@ +org.netbeans.modules.project.ui.actions.BuildExecutionSupportImpl --- a/projectui/src/org/netbeans/modules/project/ui/actions/Actions.java Tue Oct 14 13:27:56 2008 +0200 +++ a/projectui/src/org/netbeans/modules/project/ui/actions/Actions.java Thu Oct 16 13:02:21 2008 +0200 @@ -340,4 +340,7 @@ return SystemAction.get(ActiveConfigAction.class); } + public static Action rebuildProjectAction() { + return new RunLastBuildAction(); + } } --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,119 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.project.ui.actions; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.modules.project.uiapi.BuildExecutionSupportImplementation; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport.Item; +import org.openide.util.Lookup; + +/** + * + * @author mkleint + */ +public class BuildExecutionSupportImpl implements BuildExecutionSupportImplementation { + + private final List listeners = new ArrayList(); + + private final List runningItems = new ArrayList(); + private BuildExecutionSupport.Item lastFinishedItem; + + public static BuildExecutionSupportImpl getInstance() { + BuildExecutionSupportImplementation im = Lookup.getDefault().lookup(BuildExecutionSupportImplementation.class); + return (BuildExecutionSupportImpl)im; + } + + public void registerFinishedItem(Item item) { + synchronized (runningItems) { + lastFinishedItem = item; + runningItems.remove(item); + } + fireChange(); + } + + public void registerRunningItem(Item item) { + synchronized (runningItems) { + runningItems.add(item); + } + fireChange(); + } + + public void addChangeListener(ChangeListener listener) { + synchronized (listeners) { + listeners.add(listener); + } + } + + public void removeChangeListener(ChangeListener listener) { + synchronized (listeners) { + listeners.remove(listener); + } + } + + BuildExecutionSupport.Item getLastItem() { + synchronized (runningItems) { + return lastFinishedItem; + } + } + + List getRunningItems() { + List items = new ArrayList(); + synchronized (runningItems) { + items.addAll(runningItems); + } + return items; + } + + private void fireChange() { + List lsts; + synchronized (listeners) { + lsts = new ArrayList(listeners); + } + ChangeEvent event = new ChangeEvent(this); + for (ChangeListener l : lsts) { + l.stateChanged(event); + } + } + +} --- a/projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties Tue Oct 14 13:27:56 2008 +0200 +++ a/projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties Thu Oct 16 13:02:21 2008 +0200 @@ -137,3 +137,21 @@ CustomizeProject.save_modified_title=Save modified files ERR_InvalidProject=The project is either not valid or deleted + +# RunLastBuildAction +LBL_RunLastBuildAction_general=Re&peat Build/Run +# {0} - display name of previous build +TIP_RunLastBuildAction_specific=Repeat Build/Run: {0} +# {0} - display name of previous build +LBL_RunLastBuildAction_specific=Re&peat Build/Run: {0} + +# StopBuildingAction +LBL_stop_building=&Stop Build/Run +# {0} - display name of previous build +LBL_stop_building_one=&Stop Build/Run: {0} +LBL_stop_building_many=&Stop Build/Run... +LBL_SBA_intro=Multiple build/run processes are running simultaneously. +LBL_SBA_select=&Select the processes to stop: +TITLE_SBA=Stop Build/Run +LBL_SBA_stop=Stop + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,141 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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.project.ui.actions; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JMenuItem; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.modules.project.uiapi.BuildExecutionSupportImplementation; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; +import org.openide.awt.Actions; +import org.openide.awt.DynamicMenuContent; +import org.openide.awt.Mnemonics; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; +import org.openide.util.WeakListeners; +import org.openide.util.actions.Presenter; + +/** + * An action to run the last Ant build. + * @see "#47925" + */ +public final class RunLastBuildAction extends AbstractAction implements ChangeListener, Presenter.Menu, Presenter.Toolbar { + + public RunLastBuildAction() { + super(NbBundle.getMessage(RunLastBuildAction.class, "LBL_RunLastBuildAction_general")/*, + new ImageIcon(Utilities.loadImage("org/apache/tools/ant/module/resources/AntIcon.gif", true))*/); + BuildExecutionSupportImpl.getInstance().addChangeListener(WeakListeners.change(this, BuildExecutionSupportImplementation.class)); + } + + @Override + public boolean isEnabled() { + return BuildExecutionSupportImpl.getInstance().getLastItem() != null; + } + + @Override + public Object getValue(String key) { + if (key.equals(Action.SHORT_DESCRIPTION)) { + BuildExecutionSupport.Item item = BuildExecutionSupportImpl.getInstance().getLastItem(); + if (item != null) { + String display = item.getDisplayName(); + return NbBundle.getMessage(RunLastBuildAction.class, "TIP_RunLastBuildAction_specific", display); + } else { + return null; + } + } else { + return super.getValue(key); + } + } + + public void actionPerformed(ActionEvent e) { + RequestProcessor.getDefault().post(new Runnable() { + public void run() { + BuildExecutionSupport.Item item = BuildExecutionSupportImpl.getInstance().getLastItem(); + if (item != null) { + item.repeatExecution(); + } + } + }); + } + + public void stateChanged(ChangeEvent e) { + firePropertyChange("enabled", null, Boolean.valueOf(isEnabled())); // NOI18N + firePropertyChange(Action.SHORT_DESCRIPTION, null, null); + } + + public JMenuItem getMenuPresenter() { + class SpecialMenuItem extends JMenuItem implements DynamicMenuContent { + public SpecialMenuItem() { + super(RunLastBuildAction.this); + } + public JComponent[] getMenuPresenters() { + String label; + BuildExecutionSupport.Item item = BuildExecutionSupportImpl.getInstance().getLastItem(); + if (item != null) { + String display = item.getDisplayName(); + label = NbBundle.getMessage(RunLastBuildAction.class, "LBL_RunLastBuildAction_specific", display); + } else { + label = (String) getValue(Action.NAME); + } + Mnemonics.setLocalizedText(this, label); + return new JComponent[] {this}; + } + public JComponent[] synchMenuPresenters(JComponent[] items) { + return getMenuPresenters(); + } + } + return new SpecialMenuItem(); + } + + public Component getToolbarPresenter() { + JButton button = new JButton(); + Actions.connect(button, this); + return button; + } + +} --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,149 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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.project.ui.actions; + +import java.util.List; +import javax.swing.JComponent; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.netbeans.modules.project.uiapi.BuildExecutionSupportImplementation; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; +import org.openide.awt.DynamicMenuContent; +import org.openide.awt.Mnemonics; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; +import org.openide.util.WeakListeners; +import org.openide.util.actions.CallableSystemAction; +import org.openide.util.actions.SystemAction; + +/** + * Action which stops the currently running Ant process. + * If there is more than one, a dialog appears asking you to select one. + * @author Jesse Glick + * @see "issue #43143" + */ +public final class StopBuildingAction extends CallableSystemAction implements ChangeListener { + + public StopBuildingAction() { + super(); + BuildExecutionSupportImpl.getInstance().addChangeListener(WeakListeners.change(this, BuildExecutionSupportImplementation.class)); + } + + @Override + public void performAction() { + List toStop = BuildExecutionSupportImpl.getInstance().getRunningItems(); + + if (toStop.size() > 1) { + // More than one, need to select one. + toStop = StopBuildingAlert.selectProcessToKill(toStop); + } + for (BuildExecutionSupport.Item t : toStop) { + if (t != null) { + t.stopRunning(); + } + } + } + + @Override + public String getName() { + return NbBundle.getMessage(StopBuildingAction.class, "LBL_stop_building"); + } + + @Override + public HelpCtx getHelpCtx() { + return null; + } + + @Override + protected void initialize() { + super.initialize(); + setEnabled(false); // no processes initially + } + + @Override + protected boolean asynchronous() { + return false; + } + + @Override + public JMenuItem getMenuPresenter() { + class SpecialMenuItem extends JMenuItem implements DynamicMenuContent { + public SpecialMenuItem() { + super(StopBuildingAction.this); + } + public JComponent[] getMenuPresenters() { + String label = NbBundle.getMessage(StopBuildingAction.class, "LBL_stop_building"); + List items = BuildExecutionSupportImpl.getInstance().getRunningItems(); + switch (items.size()) { + case 0: + label = NbBundle.getMessage(StopBuildingAction.class, "LBL_stop_building"); + break; + case 1: + label = NbBundle.getMessage(StopBuildingAction.class, "LBL_stop_building_one", + items.iterator().next().getDisplayName()); + break; + default: + label = NbBundle.getMessage(StopBuildingAction.class, "LBL_stop_building_many"); + } + Mnemonics.setLocalizedText(this, label); + return new JComponent[] {this}; + } + public JComponent[] synchMenuPresenters(JComponent[] items) { + return getMenuPresenters(); + } + } + return new SpecialMenuItem(); + } + + public void stateChanged(ChangeEvent e) { + final List items = BuildExecutionSupportImpl.getInstance().getRunningItems(); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + SystemAction.get(StopBuildingAction.class).setEnabled(items.size() > 0); + } + }); + } + +} --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,84 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,193 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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.project.ui.actions; + +import java.awt.Component; +import java.text.Collator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.NbBundle; + +/** + * Displays an alert asking user to pick a running build to stop. + * @author Jesse Glick + */ +final class StopBuildingAlert extends JPanel { + + static List selectProcessToKill(List toStop) { + // Add all threads, sorted by display name. + DefaultListModel model = new DefaultListModel(); + StopBuildingAlert alert = new StopBuildingAlert(); + final JList list = alert.buildsList; + Comparator comp = new Comparator() { + private final Collator coll = Collator.getInstance(); + public int compare(BuildExecutionSupport.Item t1, BuildExecutionSupport.Item t2) { + String n1 = t1.getDisplayName(); + String n2 = t2.getDisplayName(); + int r = coll.compare(n1, n2); + if (r != 0) { + return r; + } else { + // Arbitrary. XXX Note that there is no way to predict which is + // which if you have more than one build running. Ideally it + // would be subsorted by creation time, probably. + return System.identityHashCode(t1) - System.identityHashCode(t2); + } + } + }; + SortedSet items = new TreeSet(comp); + items.addAll(toStop); + + for (BuildExecutionSupport.Item t : items) { + model.addElement(t); + } + list.setModel(model); + list.setSelectedIndex(0); + // Make a dialog with buttons "Stop Building" and "Cancel". + DialogDescriptor dd = new DialogDescriptor(alert, NbBundle.getMessage(StopBuildingAlert.class, "TITLE_SBA")); + dd.setMessageType(NotifyDescriptor.PLAIN_MESSAGE); + final JButton stopButton = new JButton(NbBundle.getMessage(StopBuildingAlert.class, "LBL_SBA_stop")); + list.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { + stopButton.setEnabled(list.getSelectedValue() != null); + } + }); + dd.setOptions(new Object[] {stopButton, DialogDescriptor.CANCEL_OPTION}); + DialogDisplayer.getDefault().createDialog(dd).setVisible(true); + List toRet = new ArrayList(); + if (dd.getValue() == stopButton) { + Object[] selectedItems = list.getSelectedValues(); + for (Object o : selectedItems) { + toRet.add((BuildExecutionSupport.Item)o); + } + } + return toRet; + + } + + + private StopBuildingAlert() { + initComponents(); + buildsList.setCellRenderer(new ProcessCellRenderer()); + } + + // //GEN-BEGIN:initComponents + private void initComponents() { + + introLabel = new javax.swing.JLabel(); + buildsLabel = new javax.swing.JLabel(); + buildsScrollPane = new javax.swing.JScrollPane(); + buildsList = new javax.swing.JList(); + + org.openide.awt.Mnemonics.setLocalizedText(introLabel, org.openide.util.NbBundle.getMessage(StopBuildingAlert.class, "LBL_SBA_intro")); // NOI18N + + buildsLabel.setLabelFor(buildsList); + org.openide.awt.Mnemonics.setLocalizedText(buildsLabel, org.openide.util.NbBundle.getMessage(StopBuildingAlert.class, "LBL_SBA_select")); // NOI18N + + buildsScrollPane.setViewportView(buildsList); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(layout.createSequentialGroup() + .add(buildsScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) + .addContainerGap()) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(buildsLabel) + .add(introLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .add(28, 28, 28)))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(introLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(buildsLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(buildsScrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + public javax.swing.JLabel buildsLabel; + public javax.swing.JList buildsList; + public javax.swing.JScrollPane buildsScrollPane; + public javax.swing.JLabel introLabel; + // End of variables declaration//GEN-END:variables + + private final class ProcessCellRenderer extends DefaultListCellRenderer/**/ { + + public ProcessCellRenderer() {} + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + BuildExecutionSupport.Item t = (BuildExecutionSupport.Item) value; + String displayName = t.getDisplayName(); + return super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus); + } + + } + +} --- a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Tue Oct 14 13:27:56 2008 +0200 +++ a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml Thu Oct 16 13:02:21 2008 +0200 @@ -132,6 +132,12 @@ + + + + + + @@ -391,7 +397,13 @@ - + + + + + + + --- a/projectuiapi/apichanges.xml Tue Oct 14 13:27:56 2008 +0200 +++ a/projectuiapi/apichanges.xml Thu Oct 16 13:02:21 2008 +0200 @@ -105,6 +105,23 @@ + + + Pluggable Repeat/Stop build actions + + + + + +

+ Added spi for plugging into the Repeat Build/Run and Stop Build/Run + actions that were previsouly accessible to ant based projects only. +

+
+ + +
+ Project root nodes automatically badged --- a/projectuiapi/nbproject/project.properties Tue Oct 14 13:27:56 2008 +0200 +++ a/projectuiapi/nbproject/project.properties Thu Oct 16 13:02:21 2008 +0200 @@ -39,7 +39,7 @@ javac.compilerargs=-Xlint -Xlint:-serial javac.source=1.5 -spec.version.base=1.31.0 +spec.version.base=1.32.0 is.autoload=true javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.project.uiapi; + +import javax.swing.event.ChangeListener; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; + +/** + * + * @author mkleint + */ +public interface BuildExecutionSupportImplementation { + + void registerFinishedItem(BuildExecutionSupport.Item item); + + void registerRunningItem(BuildExecutionSupport.Item item); + + void addChangeListener(ChangeListener listener); + + void removeChangeListener(ChangeListener listener); + +} --- a/projectuiapi/src/org/netbeans/modules/project/uiapi/Utilities.java Tue Oct 14 13:27:56 2008 +0200 +++ a/projectuiapi/src/org/netbeans/modules/project/uiapi/Utilities.java Thu Oct 16 13:02:21 2008 +0200 @@ -63,6 +63,14 @@ assert instance != null : "Need to have " + ActionsFactory.class.getName() + " instance in the default lookup"; return instance; } + + /** Gets BuildSupportImpl from the global Lookup. + */ + public static BuildExecutionSupportImplementation getBuildExecutionSupportImplementation() { + BuildExecutionSupportImplementation instance = Lookup.getDefault().lookup(BuildExecutionSupportImplementation.class); + assert instance != null : "Need to have " + BuildExecutionSupportImplementation.class.getName() + " instance in the default lookup"; + return instance; + } /** Gets the projectChooser factory from the global Lookup */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ f0e47b0d1a84 Thu Oct 16 13:02:21 2008 +0200 @@ -0,0 +1,103 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.spi.project.ui.support; + +import org.netbeans.modules.project.uiapi.Utilities; + +/** + * Register running and finished build/run/debug tasks for use + * by generic project UI, like "Repeat Build" action or "Stop Build" action + * in main menu. + * + * @author mkleint + * @since org.netbeans.modules.projectuiapi/1 1.32 + */ +public final class BuildExecutionSupport { + + private BuildExecutionSupport() { + + } + /** + * Notify that the build job was started and pass a reference to it. + * It is assumed that the given job instance is registered only once. + * @param item + */ + public static void registerRunningItem(BuildExecutionSupport.Item item) { + Utilities.getBuildExecutionSupportImplementation().registerRunningItem(item); + } + + /** + * Notify that the build job finished. The instance passed shall be the same + * (or at least equal) to the one passed to registerRunningItem(). + * It is assumed that the given job instance is registered only once and only after the + * registerRunningItem() method was called. + * @param item + */ + public static void registerFinishedItem(BuildExecutionSupport.Item item) { + Utilities.getBuildExecutionSupportImplementation().registerFinishedItem(item); + } + + /** + * Wrapper for the build job used by BuildExecutionSupport + */ + public static interface Item { + /** + * Display name of the build job + * @return + */ + String getDisplayName(); + /** + * Trigger re-execution of the build job. + */ + void repeatExecution(); + + /** + * Check wheather the build job has finished or not. + * @return + */ + boolean isRunning(); + + /** + * Request to stop the execution of the build job. + */ + void stopRunning(); + + } +}