Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » partService.hidePart(part, true) does not respect MDirtyable
partService.hidePart(part, true) does not respect MDirtyable [message #1060584] Mon, 27 May 2013 07:50 Go to next message
Oliver Kolling is currently offline Oliver KollingFriend
Messages: 24
Registered: April 2010
Junior Member
Hello,

when I'm using
@Inject
private MDirtyable dirtyState;

to control the state of my part, it works for closing the tab through the ui. But when I use partService.hidePart(part, true) to close the part, the MDirtyable is not respected. Did I miss something here or does the service not check for the state.... ?
Re: partService.hidePart(part, true) does not respect MDirtyable [message #1060609 is a reply to message #1060584] Mon, 27 May 2013 10:07 Go to previous messageGo to next message
Andrzej Szczepanski is currently offline Andrzej SzczepanskiFriend
Messages: 16
Registered: May 2013
Junior Member
I understand, you mean that the confirmation dialog does not pup up when you close (or more precisely - hide) part programmatically.

If that's the case, why not do that yourself. For example:
if(part.isDirty())
   partService.savePart(part, true);
ps.hidePart(part);


(The above will end up hiding the part regardless if it was saved or not)

You can also obtain ISaveHandler instance from the part's/window's context and call it directly:
if(part.isDirty()){
	ISaveHandler handler = part.getContext().get(ISaveHandler.class);
	ISaveHandler.Save userDecision = handler.promptToSave(part);
	switch(userDecision){
		case YES : 
			partService.savePart(part, false);
			partService.hidePart(part, true);
			break;
		case NO :
			partService.hidePart(part,true);
			break;
		case CANCEL :
			break;
	}
			}


Re: partService.hidePart(part, true) does not respect MDirtyable [message #1060617 is a reply to message #1060609] Mon, 27 May 2013 10:44 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I wonder if we should not have an API in EPartService which can be
instructed to check the dirty state.

Tom

On 27.05.13 12:07, Andrzej Szczepanski wrote:
> I understand, you mean that the confirmation dialog does not pup up when
> you close (or more precisely - hide) part programmatically.
>
> If that's the case, why not do that yourself. For example:
>
> if(part.isDirty())
> partService.savePart(part, true);
> ps.hidePart(part);
>
>
> (The above will end up hiding the part regardless if it was saved or not)
>
> You can also obtain ISaveHandler instance from the part's/window's
> context and call it directly:
>
> if(part.isDirty()){
> ISaveHandler handler = part.getContext().get(ISaveHandler.class);
> ISaveHandler.Save userDecision = handler.promptToSave(part);
> switch(userDecision){
> case YES : partService.savePart(part, false);
> partService.hidePart(part, true);
> break;
> case NO :
> partService.hidePart(part,true);
> break;
> case CANCEL :
> break;
> }
> }
>
>
>
Re: partService.hidePart(part, true) does not respect MDirtyable [message #1060623 is a reply to message #1060617] Mon, 27 May 2013 11:21 Go to previous messageGo to next message
Oliver Kolling is currently offline Oliver KollingFriend
Messages: 24
Registered: April 2010
Junior Member
@Andrzej Szczepanski: Thank's for the workaround. Especially the second one I did not think about the ISaveHandler. But my original intention was to rise the discussion for the extension of the EPartService - API as Tom suggested. I think that will be the cleaner approach. But in the meanwhile I will use your workaround ... Wink Thanks.
Re: partService.hidePart(part, true) does not respect MDirtyable [message #1060629 is a reply to message #1060623] Mon, 27 May 2013 11:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please file a bug so that we can maybe add this API in Luna (=4.4).

Tom

On 27.05.13 13:21, Oliver Kolling wrote:
> @Andrzej Szczepanski: Thank's for the workaround. Especially the second
> one I did not think about the ISaveHandler. But my original intention
> was to rise the discussion for the extension of the EPartService - API
> as Tom suggested. I think that will be the cleaner approach. But in the
> meanwhile I will use your workaround ... ;) Thanks.
Re: partService.hidePart(part, true) does not respect MDirtyable [message #1060659 is a reply to message #1060629] Mon, 27 May 2013 14:43 Go to previous message
Oliver Kolling is currently offline Oliver KollingFriend
Messages: 24
Registered: April 2010
Junior Member
Done,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=409149
Previous Topic:Prevent part from closing
Next Topic:Eclipse 4.2 (Helios) taking long time to open in Fedora 18
Goto Forum:
  


Current Time: Thu Apr 25 11:13:11 GMT 2024

Powered by FUDForum. Page generated in 0.03072 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top