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 218695

Summary: Alternative algorithm for recent files
Product: utilities Reporter: pjdm
Component: Open FileAssignee: Jaroslav Havlin <jhavlin>
Status: RESOLVED FIXED    
Severity: normal CC: saubrecht
Priority: P2    
Version: 7.2   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description pjdm 2012-09-20 12:33:05 UTC
The algorithm currently used for the File -> Open Recent File list is as follows (see org.netbeans.modules.openfile.RecentFiles$WindowRegistryL.propertyChange()).

If a TopComponent is being closed, add its file to the list.
If a TopComponent is being opened, remove its file from the list.

This algorithm works well with persistent TopComponents. However, my application has multiple instances of TopComponents with persistenceType = TopComponent.PERSISTENCE_NEVER. When a user opens a TopComponent then closes the application, the PROP_TC_CLOSED property is not fired, so WindowRegistryL does not get an opportunity to record the TopComponent's file in the recent files list. This does not matter for a persistent TopComponent, because it is re-opened automatically when the application next runs. However, a non-persistent TopComponent is not automatically re-opened, so not being in the recent files list is a problem.

A suggested solution is to modify the algorithm in WindowRegistryL.propertyChange() as follows.

If a TopComponent is being closed, add its file to the list.
If a TopComponent is being opened:
    if getPersistenceType()==TopComponent.PERSISTENCE_NEVER:
        add its file to the list.
    else:
        remove its file from the list.

This algorithm will leave a file in the list when it is opened; I don't see this as a problem. (One low-priority solution to this might be to not display a file in the recent files menu if an open TopComponent has a DataObject that matches that file.)
Comment 1 Stanislav Aubrecht 2013-03-06 09:33:13 UTC
Recent files should listen to IDE exit events (or window system save events) and add all non-persistent opened documents to the list during that event.
I think it's better solution than  showing already opened documents in the list as suggested above.
Comment 2 Jaroslav Havlin 2013-03-06 09:55:04 UTC
(In reply to comment #1)
> Recent files should listen to IDE exit events (or window system save events)
> and add all non-persistent opened documents to the list during that event.
Thank you, Standa, I'll implement it that way.
Comment 3 Jaroslav Havlin 2013-03-11 10:49:38 UTC
http://hg.netbeans.org/core-main/rev/050efc23b3d1
Fixed. Thank you for reporting and commenting.
Comment 4 Quality Engineering 2013-03-12 02:06:11 UTC
Integrated into 'main-golden', will be available in build *201303112300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/050efc23b3d1
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #218695: Alternative algorithm for recent files