Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 23025

Summary: [Dialogs] SaveAsDialog should not assume what is being saved is an IFile
Product: [Eclipse Project] Platform Reporter: Bob Foster <bob>
Component: UIAssignee: Tod Creasey <Tod_Creasey>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: kai-uwe_maetzel
Version: 2.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Bug Depends on: 23066    
Bug Blocks:    
Attachments:
Description Flags
Add setDefaultName method for use with non-IFile resources none

Description Bob Foster CLA 2002-08-30 07:54:14 EDT
It is already possible to save an IStorage and no doubt other types will be
added in the future.

Currently, setOriginalFile() is used to: 1) determine the default path; 2)
determine the default file name (I know, part of the path but logically distinct
and distinct in the dialog); 3) determine the default extension.

If something other than a file is saved as, none of the three work. At a
minimum, there should be a way to specify a default file name as a String. This
would allow 2 and 3 to work in the dialog.

I would be happy to submit code for this if desired.
Comment 1 Tod Creasey CLA 2002-08-30 10:12:32 EDT
We would very much like to see your suggestions Bob - please attach them to 
this PR.
Comment 2 Bob Foster CLA 2002-08-31 05:24:03 EDT
Created attachment 1919 [details]
Add setDefaultName method for use with non-IFile resources
Comment 3 Bob Foster CLA 2002-08-31 05:32:11 EDT
Method is actually called setOriginalName().

Note package name in attachment changed for testing here.

To see it work, must be accompanied by fix to TextEditor (and others?). See bug
23066. With the new method, the relevant snippet in TextEditor performSaveAs()
should look like this:

		SaveAsDialog dialog = new SaveAsDialog(shell);

		IEditorInput input = getEditorInput();
		
		IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput)
input).getFile() : null;
		if (original != null)
			dialog.setOriginalFile(original);
		else
			dialog.setOriginalName(input.getName());
			
		dialog.create();
Comment 4 Tod Creasey CLA 2002-09-03 13:40:33 EDT
Fix to be considered when Text change in Bug 23066 is made.
Comment 5 Bob Foster CLA 2002-09-11 12:30:49 EDT
Is this fixed in Build > 20020910 as well?
Comment 6 Tod Creasey CLA 2002-09-11 13:58:30 EDT
No - Bug 23066 won't be in until 20020917 so this fix will not be addressed 
until then. Upping priority as this is ready to consider now.
Comment 7 Bob Foster CLA 2002-09-11 14:56:59 EDT
Ok, thanks. Reason I asked, resolution changed to FIXED. (I see it's cleared
now.) Must be an artifact of the dependency tree. Confusing.
Comment 8 Tod Creasey CLA 2002-09-11 15:01:19 EDT
Kai has fixed his part so now we can look at this -the PRs are different and 
you are cc'ed on each - I think that is what confused you.

Bob could you possibly resubmit your changes as a patch? There are some 
formatting differences that are making too many changes show up. Thanks - I am 
looking at this now.
Comment 9 Tod Creasey CLA 2002-09-11 15:30:12 EDT
Changes released into HEAD Stream. Will come into effect in build 20020917. 

Welcome to the list of Eclipse contributors!
Comment 10 Kai-Uwe Maetzel CLA 2002-09-12 08:16:39 EDT
Tod, I have difficulties to understand what the relation of the two PRs (this 
one and bug #23066) is. Both are mentioning the SaveAs dialog. What else?
Comment 11 Tod Creasey CLA 2002-09-17 07:41:26 EDT
If you look at Bobs suggested TextEditor code in this PR he suggests that the 
new API is also used by the TextEditor in performSaveAs():

SaveAsDialog dialog = new SaveAsDialog(shell);

		IEditorInput input = getEditorInput();
		
		IFile original = (input instanceof IFileEditorInput) ? 
((IFileEditorInput)
input).getFile() : null;
		if (original != null)
			dialog.setOriginalFile(original);
		else
			dialog.setOriginalName(input.getName());
			
		dialog.create();
Comment 12 Tod Creasey CLA 2005-05-10 14:55:58 EDT
Marking closed
Comment 13 Bob Foster CLA 2005-05-10 16:45:23 EDT
Is that anything like fixed?
Comment 14 Tod Creasey CLA 2005-05-11 07:54:33 EDT
It was marked fixed 2002-09-11 15:30:12 - I am closing it to tidy up. If you
think this is still an issue please reopen and let us know why.