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 158865

Summary: File editor tab disappears when file is deleted
Product: platform Reporter: pekarna <pekarna>
Component: TextAssignee: issues@editor <issues>
Status: NEW ---    
Severity: blocker CC: jtulach
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 158177    
Bug Blocks:    

Description pekarna 2009-02-19 23:54:24 UTC
When I open a file and this is later deleted, the editor tab disappears.
This is probably intentional, but it's not good feature.

I (and everyone else, I guess) would much rather have left the tab open, just e.g. filled with background color and a
note that the file does not exist any more; Upon focus gain, IDE would check whether the file exists, and if it did, it
would be opened normally again.

Use case: When you read file generated deeply in the /target directory and you rebuild the project, such files are all
closed and you have to open them all again. This is really tedious.

Thanks for considering.
Comment 1 Jaroslav Tulach 2009-02-20 11:04:14 UTC
I know this behaviour is OK when a file is deleted from Projects/Files/Favorites view. So one would need to 
distinguish the two cases. Maybe FileEvent.isExpected() could help...
Comment 2 mslama 2009-02-26 14:45:02 UTC
So you mean the case when file is deleted externally? (even during running build script ie. not when deleted explicitly
by user by delete action).
Comment 3 mslama 2009-03-06 15:56:30 UTC
CloneableOpenSupport has property change listener on data object. There is no way how to distinguish why/where file was
deleted (internal/external or expected/not expected). In addition I have to test what events are fired by file system.
It would require new API between loaders (DataObject) and window system (CloneableOpenSupport) If file is deleted and
then created again original dataobject is invalid and not reused. I must check if it would be possible to keep
DataEditorSupport and refresh it ie. to check if file with given path exists and if yes create new DataObject and reload
content to editor pane.

I assume if file is deleted and not recreated you mean user would close it manually? There would stay just pane with
message "File was deleted".

1.If file is deleted I could place dummy component with "File deleted".
2.If component is activated/focused refresh could be performed.

Change to RFE as current status is by design. In addition I am not sure if this behavior would be good for all users.
Comment 4 mslama 2009-03-09 13:42:44 UTC
This could be hopefully fixed by issue #158177 when automatic filesystem refresh would be switched off. Then external
changes would not cause automatic closing of editors.
Comment 5 pekarna 2009-03-10 23:22:06 UTC
Hi mslama, thanks for taking this.

Yes, I mean the case when the file is deleted externally.

You wrote:
> If file is deleted and then created again original dataobject is invalid and not reused.

But currently, sometimes it happens, that the IDE doesn't refresh the view (e.g. when the IDE window is inactive), and
when I get back to IDE and the file is already re-created, the editor content just redraws. So I thought this is already
solved somehow, and it's only a matter of not closing the window... Wrong guess?

Comment 6 mslama 2009-03-11 08:24:05 UTC
As said before: If there is automatic file system refresh which is propagated to view/UI then editor is closed when file
is deleted. So if automatic refresh could be switched off then this problem should be solved too. User would perform
manual refresh to get external changes at right moment. If file is already recreated it would be only reloaded as it
should have newer time stamp ie. external change is assumed but not file deletion.