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 - File editor tab disappears when file is deleted
Summary: File editor tab disappears when file is deleted
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: issues@editor
Depends on: 158177
  Show dependency tree
Reported: 2009-02-19 23:54 UTC by pekarna
Modified: 2010-01-12 05:21 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
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.