Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » ECLIPSE JUNO RCP application.e4xmi eventBroker(on part close.)
ECLIPSE JUNO RCP application.e4xmi eventBroker [message #977397] Fri, 09 November 2012 08:54 Go to next message
Angel Manica Raquel is currently offline Angel Manica RaquelFriend
Messages: 1
Registered: November 2012
Junior Member
Hi there everyone! we're trying to figure out where to call the

"Do you want to save the changes you made to *insert file here*?" question when a user closes a file which is an opened part on the PartStack for opened files.

At the moment, what I did was to place it on a disposeListener() on my fileViewer class. However, the user can only have two options which is to either Save the changes or not because I can't place there a cancel button which would just close the dialog and return to his file because it has already been disposed.

So, I wanted to edit it in such a way that the user can have the option to:

a. Save - Close File and Save Changes
b. not save - close file and not save changes
c. cancel- do not close the file and just return to what the user was doing.

My teammate researched on the event broker handler:

 private EventHandler testHandler;
       @PostConstruct
       public void pc(IEventBroker eventBroker)
       {
               testHandler = new EventHandler() {
                       
                       @Override
                       public void handleEvent(Event event) {
                               Object part = event.getProperty(UIEvents.EventTags.ELEMENT);
                               boolean tbr =(Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
                               
                               System.out.println(event.getTopic().toString());
                               if (part instanceof MPart){
                                       System.out.println("Part "+((MPart)part).getElementId()+" is "+(!tbr?"NOT":"")+" visible");
                                       if(MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirmation", "Do you really want to close? ")){
                                               System.out.println("exit!");
                                       }
                                       else{
                                       }
                               }
                       }
               };
               eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, testHandler);
       }


Here we saw the confirmation Message appear before the part containing the file was disposed, but still, we can't figure out how to keep the file from disposing after the confirmationDialog closes. Embarrassed

So where should I place the confirmationDialog?

Your advice would be greatly appreciated! Thank you! Very Happy
Re: ECLIPSE JUNO RCP application.e4xmi eventBroker [message #977731 is a reply to message #977397] Fri, 09 November 2012 14:23 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Better ask the eclipse.e4 newsgroup.

Tom

Am 09.11.12 14:36, schrieb Angel Manica Raquel:
> Hi there everyone! we're trying to figure out where to call the
> "Do you want to save the changes you made to *insert file here*?"
> question when a user closes a file which is an opened part on the
> PartStack for opened files.
>
> At the moment, what I did was to place it on a disposeListener() on my
> fileViewer class. However, the user can only have two options which is
> to either Save the changes or not because I can't place there a cancel
> button which would just close the dialog and return to his file because
> it has already been disposed.
> So, I wanted to edit it in such a way that the user can have the option to:
>
> a. Save - Close File and Save Changes
> b. not save - close file and not save changes
> c. cancel- do not close the file and just return to what the user was
> doing.
>
> My teammate researched on the event broker handler:
>
>
> private EventHandler testHandler;
> @PostConstruct
> public void pc(IEventBroker eventBroker)
> {
> testHandler = new EventHandler() {
> @Override
> public void handleEvent(Event event) {
> Object part =
> event.getProperty(UIEvents.EventTags.ELEMENT);
> boolean tbr =(Boolean)
> event.getProperty(UIEvents.EventTags.NEW_VALUE);
>
> System.out.println(event.getTopic().toString());
> if (part instanceof MPart){
> System.out.println("Part
> "+((MPart)part).getElementId()+" is "+(!tbr?"NOT":"")+" visible");
>
> if(MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
> "Confirmation", "Do you really want to close? ")){
> System.out.println("exit!");
> }
> else{
> }
> }
> }
> };
>
> eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, testHandler);
> }
>
> Here we saw the confirmation Message appear before the part containing
> the file was disposed, but still, we can't figure out how to keep the
> file from disposing after the confirmationDialog closes. :blush:
> So where should I place the confirmationDialog?
>
> Your advice would be greatly appreciated! Thank you! :d
Previous Topic:How to disable/enable view toolbar menu/action in Eclipse Plugin Development
Next Topic:checkWakeLocks caught Exception
Goto Forum:
  


Current Time: Tue Dec 23 04:34:23 GMT 2014

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

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