This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE 6.9 (Build 201006101454) Operating System = Windows Vista version 6.0 running on x86 Java; VM; Vendor = 1.6.0_20 Runtime = Java HotSpot(TM) Client VM 16.3-b01 In the Project Navigator window, it would be nice to be able to right-click on a project and have a "Close All Other Projects" option or some such. Also in the File menu.
This could also be an option in the New Project wizard.
No plans to implement any UI of this kind. Would be easy enough to implement as a plugin if there is sufficient interest.
Reopening the issue, because it is easy to implement this as a action. Could somebody with committer-rights please commit a action like the following? package closeotherprojects; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.netbeans.api.project.Project; import org.netbeans.api.project.ui.OpenProjects; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; import org.openide.util.NbBundle.Messages; @ActionID( category = "Project", id = "closeotherprojects.CloseOtherProjectsAction") @ActionRegistration( displayName = "#CTL_CloseOtherProjectsAction") @Messages("CTL_CloseOtherProjectsAction=Close other projects") @ActionReference(path = "Projects/Actions") public final class CloseOtherProjectsAction implements ActionListener { private final List<Project> selectedProjects; public CloseOtherProjectsAction(List<Project> context) { this.selectedProjects = context; } @Override public void actionPerformed(ActionEvent ev) { OpenProjects manager = OpenProjects.getDefault(); List<Project> openProjects = new ArrayList<Project>(Arrays.asList(manager.getOpenProjects())); openProjects.removeAll(selectedProjects); if (!openProjects.isEmpty()) { Project[] otherProjectsToBeClosed = openProjects.toArray(new Project[openProjects.size()]); System.out.println("closing " + otherProjectsToBeClosed); manager.close(otherProjectsToBeClosed); } } }
psomol: is this something we want to add to project popup?
Certainly there should not be any problem in adding such action among the list of available ones in action pool. So the only question is whether to have @ActionReference(path = "Projects/Actions") there by default or not, imho...
contrib/whichproject already has this functionality BTW.
So what would be the arguments for/against: for: - is demanded and is common elsewhere - we have it for editor tabs already against: - increased project menu clutter and height.. I am not sure but is not the menu extended by default for certain project types ? Then menu height could become an issue on the quite common 800pix high screens - accidental click on Close Other when one intended to click Close is really annoying - isn't it at least equally common that one needs to close all projects but two or three ? That situation would not be covered anyway, but is covered by the workaround below workaround: - select all projects, deselect the current one, right click the selection and choose Close XX Projects - as pointed by Jesse a contrib functionality also exists (contrib/whichproject) In view of the above I vote against the default inclusion of such action. When one is in doubt, then keeping the UI simpler is usually preferable. But this is not a strong objection so I would not mind being overridden.
Take a look at how contrib/whichproject does it - I wrote in the 4.0 timeframe and it's hard to live without. It adds a File menu item "Close Unreleated Files" / keyboard shortcut (ctrl-alt-p) - that's for files, not projects, and it just closes all files which are not in the same project as the one which is selected / open in the editor. I'd suggest doing the same thing for projects - just put it in the file menu, and don't worry about the popup.
FYI: I created a simple plugin for 7.0, 7.1, 7.2, 7.3 at http://plugins.netbeans.org/plugin/45122/?show=true
I used your code, Benno, to implement "Close Other Projects" Projects and "Close All Projects" at this time. Thanks. https://hg.netbeans.org/core-main/rev/83889bbd1b59
(In reply to Martin Kozeny from comment #10) > I used your code, Benno, to implement "Close Other Projects" Projects and > "Close All Projects" at this time. Thanks. > https://hg.netbeans.org/core-main/rev/83889bbd1b59 @Martin: Cool. Don't forget to update the target version.
(In reply to markiewb from comment #11) > (In reply to Martin Kozeny from comment #10) > > I used your code, Benno, to implement "Close Other Projects" Projects and > > "Close All Projects" at this time. Thanks. > > https://hg.netbeans.org/core-main/rev/83889bbd1b59 > > @Martin: Cool. Don't forget to update the target version. I did it for you.