Community
Participate
Working Groups
This feature request was open in response to bugzilla bug 10234 I created a view that contains an editor, so I currently have my view implement ISaveablePart so that when a Save is performed in my view, I save inside my embedded editor rather than save the current active editor. As of 3.0 M3, ISaveablePart is still marked as "experimental API" Could this ISaveablePart stop being "experiemental" and start being real? Or can there be a better way to override the save action? I cannot change my view into an editor because my view works off selection from the active editor. So if I turn my view into an editor, I'd have 2 active editors, which isn't possible.
Could you please provide more details on what you have in both the view and editor? Note that in R3.0, the Synchronize view no longer needs to implement ISaveablePart since it now shows changes in a compare editor.
My view is basically used for script editing. The view contains a sashform with 2 panels/parts. When a user selects objects in the active editor, my view will display a list of scriptable objects in one panel. Then when the user selects a scriptable object, the appropriate editor for that object will appear in the other panel of my view. That editor is basically an IEditorPart (with additional info) and it should have the same functionality as a typical IEditorPart. So if the user is editing script in my view, then hits Ctrl+S, the contents of the editor in my view should save rather than just the contents of the active editor.
The "experimental API" comments on ISaveablePart have been removed. It would be better if there was more explicit support for your scenario, e.g. allowing multiple parts to participate in a save, rather than requiring each of the parts to implement doSave and delegate to the other parts (if visible).
I'm interested in seeing ISaveablePart be included in the "Save All" functionality of the workbench, including when the workbench is closed and some ISaveablePart instances are dirty.
So Save All would unconditionally save all dirty editors and views that implement ISaveablePart? And, on exit, if there were views implementing ISaveablePart that were dirty, then they would also show up in the prompt to save dialog? For the latter, it would only be able to show the view title, since views have no notion of input element. Would this suffice?
See also bug 72114.
In regards to comment #3, yes, some sort of save participant would be real nice. So then when a user performs a Save on the active editor, my view can also participate and maybe touch some code up in my embedded editor, then save the file in my embedded if it's different than the file in the active editor. This way I dont have to have a special or different behavior depending on if the user triggered a Save action in the active editor or in my view. This would then also take care of the Save All action for me because when the active editor is saved, my view will also be triggered to save. And as for the save dialog prompt, ideally it would be nice to have the view specify what to put in the dialog, but for me, I could work around it by at least making my view title a little more descriptive.
Amy, could you accomplish that -without- your view implementing ISaveablePart, but having a handshaking protocol between the editor and view? E.g. view lets editor know about its presence. When the editor is told to doSave(), it also delegated to the view if present?
Yes, I think that would almost work. Except for the Save action is only enabled if the editor isDirty. So I guess the view would also need to have a say in whether the editor is really dirty or not, which can be somewhat confusing to the user if they see that the editor is marked dirty even though it really is not.
See also bug 43464.
Consider for 3.1. Should take out the fix72114 preference, making it be the default behaviour. Should also address bug 43464 (prompt on shutdown).
I've taken out the fix72114 preference check from Perspective.canCloseView(). So the code is now: public boolean canCloseView(IViewPart view) { if (view instanceof ISaveablePart) { ISaveablePart saveable = (ISaveablePart)view; if (saveable.isSaveOnCloseNeeded()) { IWorkbenchWindow window = view.getSite().getWorkbenchWindow(); return SaveableHelper.savePart(saveable, view, window, true); } } return true; } If the view doesn't want the prompt to save when dirty, it can return false for isSaveOnCloseNeeded(). For coordination between the view and editor, I recommend setting it up so that they share the same underlying document model, where both the view and editor respond to dirty state changes on the model. This is how the shared document model in text editors works. No further workbench support should be needed for this. For customizing the appearance of the save on close prompt, see bug 76768. For Save All support, and other ISaveablePart issues, see bug 84406.
Verified in I20040215-2300.