Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 99793 - same file open in 2 editors, no Save resource dialog when close a dirty editor
Summary: same file open in 2 editors, no Save resource dialog when close a dirty editor
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.sse (show other bugs)
Version: 0.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: David Williams CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 107033 (view as bug list)
Depends on: 106620
Blocks:
  Show dependency tree
 
Reported: 2005-06-13 15:21 EDT by Amy Wu CLA
Modified: 2006-11-28 15:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Wu CLA 2005-06-13 15:21:09 EDT
6/13/05 w/ eclipse RC2

1. Open an xml file using XML Source Page editor
2. dirty it
3. Window->New Editor
4. now you have 2 editors open on the same file, both dirty
5. close 1 editor
6. editor closes without informing you file was modified and ask you if you 
want to save

If you perform the same type of operation on Text editor, you will get Save 
resource dialog.
Comment 1 Amy Wu CLA 2005-06-13 15:38:03 EDT
This is because in StructuredTextEditor#isSaveOnCloseNeeded it checks to see 
if the current StructuredModel is shared for edit, if it is still shared by 
another, it will not ask to save.

Besides source editor not following the same behaviour as Text editor, it 
seems safer to ask the user if they want to save before closing the main 
editor, regardless of whether or not more editors on the file are open.  What 
if the second editor is hidden somewhere (like embedded in a hidden view)?  Or 
what if the other editor never saves on close?
Comment 2 David Williams CLA 2005-06-15 01:23:18 EDT
Changed Version field given new release numbering.
Comment 3 Amy Wu CLA 2005-08-16 12:12:33 EDT
also found issues with if other parts of the editor, like xml design page, has 
modelforedit.  when editor is closed, first thing it does is check if save on 
close is needed.  then it proceeds to close editor.  so if another client is 
using model for edit, it won't have a chance to release before save on close 
is checked.
Comment 4 Amy Wu CLA 2005-08-16 12:14:50 EDT
fix is in isSaveOnCloseNeeded:
Original:
public boolean isSaveOnCloseNeeded() {
	if (getInternalModel() == null)
		return false;
==>	getInternalModel().isSaveNeeded();
}

Fix:
public boolean isSaveOnCloseNeeded() {
	if (getInternalModel() == null)
		return false;
==>	// BUG99793 - always prompt for save if dirty (even if others have
==>	// model for edit)
==>	return getInternalModel().isDirty();
}
Comment 5 Amy Wu CLA 2005-08-16 12:42:58 EDT
adding dependency to bug 106620 because this bug fix is included in that bug's 
fix.
Comment 6 Amy Wu CLA 2005-08-16 12:45:02 EDT
David, please mark this bug as fixed when you apply patches for bug 106620.
Comment 7 Nitin Dahyabhai CLA 2005-08-16 17:46:33 EDT
Amy, how about removing that method altogether?
Comment 8 Amy Wu CLA 2005-08-16 18:14:37 EDT
Nitin, I thought about that too but I didnt dig deep enough to see if
if (getInternalModel() == null)
	return false;
return getInternalModel().isDirty();

Is equivalent to
IDocumentProvider p= getDocumentProvider();
return p == null ? false : p.canSaveDocument(getEditorInput());

if you can vouch that it is, I can update the patch.
Comment 9 Nitin Dahyabhai CLA 2005-08-24 13:06:57 EDT
They should be the same at this point, and the error handling for bug 106620
implies that we have to make it the same.  When we don't have a structured
model, the document provider is the only one who knows if a save is needed.
Comment 10 Nitin Dahyabhai CLA 2005-08-24 13:18:10 EDT
Fixed, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=106620#c8
Comment 11 Amy Wu CLA 2005-09-01 11:01:09 EDT
*** Bug 107033 has been marked as a duplicate of this bug. ***
Comment 12 Amy Wu CLA 2006-01-09 15:59:53 EST
verified in WTP 1.0
Comment 13 John Lanuti CLA 2006-11-28 15:37:36 EST
This is part of a mass update to close out all stale WTP defects already verified by the reporter but awaiting closure by the assignee.  If you feel this defect was closed inappropriately, please reopen.

Thanks, John Lanuti