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 20910 - Add ability to veto Open actions
Summary: Add ability to veto Open actions
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: Sun SunOS
: P2 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords: API
Depends on:
Blocks: 21959
  Show dependency tree
 
Reported: 2002-02-26 23:48 UTC by David Weatherford
Modified: 2008-12-22 23:52 UTC (History)
2 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 David Weatherford 2002-02-26 23:48:34 UTC
When a file has been opened by an external editor, and the user selects
the Open action on a node in the Explorer that corresponds to that file,
the file gets opened again, rather than reusing the existing buffer.

If the Editor were to provide something like a "vetoable Open listener"
interface, an EditorKit could register an interest in Open actions and thus
get its OpenListener called on every Open action.  If the pathname matches
a file that the EditorKit is managing externally, it could return false,
which should abort the Open.  The EditorKit would then create a JEditorPane
for the external file and ask the Editor to display that instead.

The current behavior is particularly confusing when the external editor
has modified, but not written, the file in question -- you get two copies
of the file opened, one with your edits and one without.
Comment 1 Miloslav Metelka 2002-03-29 10:04:51 UTC
IMHO this is rather for openide.text than editor module itself.
Comment 2 Jan Zajicek 2002-04-03 08:57:07 UTC
Moving to openide.text ovner.
Comment 3 Peter Zavadsky 2002-04-03 12:49:13 UTC
To manage the opening, etc, things from editor seems to be too obscure
for me. I guess there should be another solution found.

But first I need exactly to know what you need.
 You means just nothing to be happened when the action is invoked, 
like if the action would be disabled? Do you need the similar
behaviour also for other actions?
Please, specify.

Yarda what do you think about it, I mean the vetoable listener?
Comment 4 Jaroslav Tulach 2002-04-03 15:22:46 UTC
"When a file has been opened by an external editor, and the user selects
the Open action on a node in the Explorer that corresponds to that file,
the file gets opened again, rather than reusing the existing buffer."

Unbelievable: How that can happen, I lived in ilussion that
CloneableEditorSupport remembers all references to the
CloneableEditors it creates and if open is called one of them is 
"requestFocused". Does the CES exist in memory or is it garbage
collected, etc.?


Comment 5 Melih Ovadya 2002-04-04 01:50:09 UTC
There seems to be some confusion here so let me try to clarify as 
much as I can:
1) When the user opens a file (/home/bar/foo.txt) inside external 
editor (e.g XEmacs), the IDE has no idea that this file is opened in 
XEmacs (except the external editor module). That's why it's normal 
that CloneableEditorSupport is unaware of this file.
2) Once opened, the user can edit the file content in XEmacs w/o 
saving the buffer.
3)If he then goes to the Explorer and double-clicks (opens) the 
foo.txt in /home/bar tree, IDE will open a new JEditorPane in the 
source editor window and populate it with the file content from the 
disk.
4) Subsequently this will cause two bugs to occur:
   i) XEmacs will open a new buffer with the content of JEditorPane 
the IDE has created 
   ii) the content of that new buffer doesn't match the content of the 
previously opened unsaved buffer.

Now to fix this we need two things from NB:
1) vetoable Open listener (see Dave's comments): 
  i) External editor kit will register to this listener. This way, in 
step 3 above, when the user tries to open the file, IDE will iterate 
over the listeners, and ExtEdKit will return false. Then the IDE will 
abort as if no OpenAction request has been processed.
  ii) At that point the externaleditor is responsible of creating a 
JEditorPane and populate it with the up-to-date content from the 
XEmacs buffer.

2) A new API to be able to add this JEditorPane to the IDE. 
Once the IDE has the pane, it can get the editor kit and the document 
from that pane and then does the some process (as in CloneableEditor, 
CloneableEditorSupport etc) to add it to the source editor window.
Comment 6 Peter Zavadsky 2002-04-05 09:30:35 UTC
I still think the API change you require is too big attack to current
state and too obscure. Yarda what do you think about it?

Also I think you don't need it.To the first points.
3) Why let you IDE open the JEditorPane with the original content of
the file, you are returning the custom component thru document showing
just the label, don't you (as you told us in #20647).
4) Why you open the new buffer with the original content if you don't
want to and have already the changed one, you can just show the
already changed buffer.

From my point I think that's sufficient, please clarify more what I'm
missing here?

Thanks.

Peter
Comment 7 Melih Ovadya 2002-04-05 22:55:04 UTC
Peter,

You are right, implementing NbDocument.CustomEditor for issue #20647 
might give me a handle to fix this problem too. When we filed this 
issue, I wasn't aware of that interface yet. I'll try it and let you 
know if it works. Thanx.  
Comment 8 Peter Zavadsky 2002-04-10 15:48:00 UTC
Melih, how it is with your try?
Comment 9 Melih Ovadya 2002-04-16 04:29:49 UTC
Peter,

I've been working on this bug, modifying a lot of my code 
as we discussed before and it looks like with those 
modifications I may not need a vetoable Open listener 
afterall. I need a few days more to verify that everything 
is working properly. Afterwards, you can go ahead and 
close this issue. Thanx.
Comment 10 Melih Ovadya 2002-04-17 00:13:24 UTC
I am closing this bug since my changes seem to work OK.
Comment 11 Jan Zajicek 2002-04-18 14:11:28 UTC
verified
Comment 12 Jaroslav Tulach 2004-01-28 13:49:35 UTC
*** Issue 19871 has been marked as a duplicate of this issue. ***