Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Stop part from closing?
Stop part from closing? [message #987177] Fri, 23 November 2012 22:22 Go to next message
Mike Shreek is currently offline Mike Shreek
Messages: 16
Registered: September 2012
Junior Member
Hi, Is there anyway you can stop a part from closing?

Like for example when a data inside a table was modified it will promp a save (yes no cancel) and when hit cancel the part will not be closed. Thank you!


Re: Stop part from closing? [message #987178 is a reply to message #987177] Sat, 24 November 2012 02:20 Go to previous messageGo to next message
Mike Shreek is currently offline Mike Shreek
Messages: 16
Registered: September 2012
Junior Member
Dear Mike,

I think you got it wrong. In your MParts, there is a thing called "setDirty" which tells the eclipse that the part is modify and needs to trigger a save dialog when closing. This will help you to manipulate parts that are going to be saved.

For example, when part is modified
part.setDirty(true);


then include the following in your class (MPart's class)
@Persist
public static void savePart(MPart part){
// In this area, parts that are set to be saved is here, so you can get the part and do whatever data saving you want
part.setDirty(false); //don't forget to mark this as false again!
} 

@PersistState
public static void beforeDisposePart(MPart part){
//Optional: in this area, if you still want to get the parts that are set NOT to be saved 

if(part.isDirty()){
//Do something here
}

}


Also, when creating a new part, don't forget to tag your part EPartService.REMOVE_ON_HIDE_TAG
part.getTags().add(EPartService.REMOVE_ON_HIDE_TAG );


Cheers!
Re: Stop part from closing? [message #987179 is a reply to message #987178] Sat, 24 November 2012 02:27 Go to previous messageGo to next message
Mike Shreek is currently offline Mike Shreek
Messages: 16
Registered: September 2012
Junior Member
Dear Mike,

Why THANK you so much!! It's been like 5 days of figuring on how to do this!! Thank you Thank you!

But anyway I'd like to see some answers on how to stop parts from closing. This is for anyone who needs to stop their parts from being destroy if there are other reasons...

Cheers!
Re: Stop part from closing? [message #987185 is a reply to message #987179] Sat, 24 November 2012 05:16 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5259
Registered: July 2009
Senior Member
If it is not closeable then mark it that way in the e4xmi.

Tom

Am 24.11.12 08:27, schrieb Mike Shreek:
> Dear Mike,
>
> Why THANK you so much!! It's been like 5 days of figuring on how to do
> this!! Thank you Thank you!
>
> But anyway I'd like to see some answers on how to stop parts from
> closing. This is for anyone who needs to stop their parts from being
> destroy if there are other reasons...
>
> Cheers!
Re: Stop part from closing? [message #987285 is a reply to message #987185] Sun, 25 November 2012 12:22 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 596
Registered: December 2010
Senior Member

Take a look at the e4xmi editor in the e4 tools. There are some part properties that you can set/unset there.

To install paste this http://download.eclipse.org/e4/downloads/drops/I20121122-2200/repository into the update site box.
Re: Stop part from closing? [message #987320 is a reply to message #987185] Sun, 25 November 2012 23:08 Go to previous messageGo to next message
Mike Shreek is currently offline Mike Shreek
Messages: 16
Registered: September 2012
Junior Member
Obviously that would be the solution... But technically there are loads of parts that are need of checking/validation before closing...

- Mike
Re: Stop part from closing? [message #987321 is a reply to message #987285] Mon, 26 November 2012 00:26 Go to previous messageGo to next message
Mike Shreek is currently offline Mike Shreek
Messages: 16
Registered: September 2012
Junior Member
Sopot Cela wrote on Sun, 25 November 2012 12:22
Take a look at the e4xmi editor in the e4 tools. There are some part properties that you can set/unset there.

To install paste this http://download.eclipse.org/e4/downloads/drops/I20121122-2200/repository into the update site box.


Is this new release? What does it do?
Re: Stop part from closing? [message #987409 is a reply to message #987321] Mon, 26 November 2012 09:04 Go to previous message
Sopot Cela is currently offline Sopot Cela
Messages: 596
Registered: December 2010
Senior Member

Latet version of the e4 tools. It gives you the possibility to edit the e4xmi with a nice editor.
Previous Topic:How to use IPartListener
Next Topic:How to tell and convert to pure e4
Goto Forum:
  


Current Time: Fri Aug 01 00:00:29 EDT 2014

Powered by FUDForum. Page generated in 0.04237 seconds