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.

Bug 190839 - Close Other Projects functionality
Summary: Close Other Projects functionality
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Projects UI (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Martin Kozeny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-07 19:26 UTC by ekenschaft
Modified: 2014-02-15 15:41 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ekenschaft 2010-10-07 19:26:49 UTC
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.
Comment 1 ekenschaft 2010-10-08 20:42:16 UTC
This could also be an option in the New Project wizard.
Comment 2 Jesse Glick 2010-10-14 11:35:00 UTC
No plans to implement any UI of this kind. Would be easy enough to implement as a plugin if there is sufficient interest.
Comment 3 markiewb 2012-08-24 22:50:47 UTC
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);
        }


    }
}
Comment 4 Milos Kleint 2012-08-30 19:12:52 UTC
psomol: is this something we want to add to project popup?
Comment 5 Jaroslav Tulach 2012-08-31 06:59:18 UTC
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...
Comment 6 Jesse Glick 2012-09-04 17:15:49 UTC
contrib/whichproject already has this functionality BTW.
Comment 7 Petr Somol 2012-09-06 10:16:21 UTC
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.
Comment 8 _ tboudreau 2012-09-06 13:28:49 UTC
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.
Comment 9 markiewb 2012-11-01 22:43:04 UTC
FYI: I created a simple plugin for 7.0, 7.1, 7.2, 7.3 at http://plugins.netbeans.org/plugin/45122/?show=true
Comment 10 Martin Kozeny 2013-10-03 14:25:43 UTC
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
Comment 11 markiewb 2013-10-20 16:38:33 UTC
(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.
Comment 12 markiewb 2014-02-15 15:41:05 UTC
(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.