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 03:54 Go to previous message
Angel Manica Raquel is currently offline Angel Manica Raquel
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
 
Read Message
Read Message
Previous Topic:How to disable/enable view toolbar menu/action in Eclipse Plugin Development
Next Topic:checkWakeLocks caught Exception
Goto Forum:
  


Current Time: Wed May 22 06:03:26 EDT 2013

Powered by FUDForum. Page generated in 0.02023 seconds