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 253371

Summary: Optionally disable CloseProject action for RCP applications
Product: projects Reporter: heithecker <heithecker>
Component: Generic Projects UIAssignee: Tomas Stupka <tstupka>
Status: NEW ---    
Severity: normal    
Priority: P4    
Version: 8.0.2   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description heithecker 2015-07-08 18:49:25 UTC
Contrary to all other project sensitive actions, by default org.netbeans.modules.project.ui.actions.CloseProject is always enabled, i.e. it does not check for the project action command "close" to be present. 

In a netbeans RCP application not related to programming we use the project api to group files and nodes thematically. Some projects are "build-in" projects, which are ensured to be open after start up and should never be closed. For simplicity the correspondig project folders reside inside the config file system. If the user, however, inadvertently closes a project, he or she either has to restart the application or navigate with the open project action to the config file system, which is not desirable because difficult to communicate. 

This approach could be appropriate for other netbeans RCP applications too, so I propose to make closing of projects conditional, i.e. optionally require an explicit close command. In fact, this would only mean changing a few lines of code in class org.netbeans.modules.project.ui.actions.CloseProject (as far as I understand):

static boolean requireCloseCommand = Boolean.valueOf(System.getProperty("require.project.close.action", "false"));
....
    @Override
    protected void actionPerformed( final Lookup context ) {
.......
String cmd = requireCloseCommand ? "close" : null;
        Project[] projects = ActionsUtil.getProjectsFromLookup( context, cmd );        
.....
    }
    
    @Override
    public void refresh(Lookup context, boolean immediate) {
        
        super.refresh(context, immediate);

        String cmd = requireCloseCommand ? "close" : null;
        Project[] projects = ActionsUtil.getProjectsFromLookup( context, cmd );
 .....      
    }

For now, we override CloseProject and also its registry (ProjectActions) but this means that we need an implementation dependency, which is not preferrable.

Boris