Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Odd behavior if E4 application closed via 'X' button
Odd behavior if E4 application closed via 'X' button [message #1228237] Mon, 06 January 2014 18:45 Go to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
I am exploring developing an eclipse 4 RCP application, using JavaFX (efxclipse) as the renderer on a linux (CentOS 6.5) system. The app window consists of a main menu and single part stack that is initially empty. The user makes choices from the menu and the controller logic configures the part to be displayed in the part stack. One of the menu choices is used to exit the application and its handler simply closes the workbench.

I was testing the application and noticed that one time the application opened up with the parts already opened on the part stack. This was completely unexpected as I'm not doing anything to preserve any state as far as what was open when the application was exited. I did some experiments and noticed that if I exit the application via my exit menu (and command/handler), when it is run again, it comes up "empty" like I would expect. However, if I exit the application by just clicking the "X" button in the upper-right, the next time the application is run, it comes up with whatever parts I had open when it was last closed. Obviously there is some sort of preservation of state going on behind the scenes.

I'd like to know what's happening here and if it can be controlled - I may want to preserve the user's last "part configuration" so that it comes up the next time without their having to select the menu choices again. In the meantime, I'd like the application to come up in its initial empty state when it's run, regardless of how it was last shut down.
Re: Odd behavior if E4 application closed via 'X' button [message #1228296 is a reply to message #1228237] Mon, 06 January 2014 22:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 06.01.14 19:45, Joseph Gagnon wrote:
> I am exploring developing an eclipse 4 RCP application, using JavaFX
> (efxclipse) as the renderer on a linux (CentOS 6.5) system. The app
> window consists of a main menu and single part stack that is initially
> empty. The user makes choices from the menu and the controller logic
> configures the part to be displayed in the part stack. One of the menu
> choices is used to exit the application and its handler simply closes
> the workbench.
>
> I was testing the application and noticed that one time the application
> opened up with the parts already opened on the part stack. This was
> completely unexpected as I'm not doing anything to preserve any state as
> far as what was open when the application was exited. I did some
> experiments and noticed that if I exit the application via my exit menu
> (and command/handler), when it is run again, it comes up "empty" like I
> would expect. However, if I exit the application by just clicking the
> "X" button in the upper-right, the next time the application is run, it
> comes up with whatever parts I had open when it was last closed.
> Obviously there is some sort of preservation of state going on behind
> the scenes.
>
> I'd like to know what's happening here and if it can be controlled - I
> may want to preserve the user's last "part configuration" so that it
> comes up the next time without their having to select the menu choices
> again. In the meantime, I'd like the application to come up in its
> initial empty state when it's run, regardless of how it was last shut down.
>

Perserving the state is the default. If you always want it come up with
a clean state you can pass -clearPersistedState as a program argument or
set it to true using the product extension point.

How does your handler close the application? If the shutdown process is
running in its normal way it will *ALWAYS* save the state.

Tom
Re: Odd behavior if E4 application closed via 'X' button [message #1228555 is a reply to message #1228296] Tue, 07 January 2014 13:50 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
Ah. I did not have -clearPersistedState set as a run-time argument, so that explains that.

I have a command and handler set up to be activated from a menu choice. The handler is as follows:

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.workbench.IWorkbench;

public class ExitHandler {
  @Execute
  public void execute(IWorkbench workbench) {
    System.out.println("ExitHandler called");
    workbench.close();
  }
}


Is this the correct thing to do?

So, when I select exit from the menu the app closes and when I re-run it no state was preserved. However, if I just click the standard "X" button, state is preserved.

Is there a way to detect and handle the user clicking the "X" button?
Re: Odd behavior if E4 application closed via 'X' button [message #1228578 is a reply to message #1228555] Tue, 07 January 2014 14:29 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 07.01.14 14:50, Joseph Gagnon wrote:
> Ah. I did not have -clearPersistedState set as a run-time argument, so
> that explains that.
>
> I have a command and handler set up to be activated from a menu choice.
> The handler is as follows:
>
>
> import org.eclipse.e4.core.di.annotations.Execute;
> import org.eclipse.e4.ui.workbench.IWorkbench;
>
> public class ExitHandler {
> @Execute
> public void execute(IWorkbench workbench) {
> System.out.println("ExitHandler called");
> workbench.close();
> }
> }
>
>
> Is this the correct thing to do?
>


Yes! So the bug is the other way round. There's a bug in workbench.close
:-( Please file a bug against e(fx)clipse!

Tom
Re: Odd behavior if E4 application closed via 'X' button [message #1229522 is a reply to message #1228578] Thu, 09 January 2014 16:17 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
How do I file a bug report?
Re: Odd behavior if E4 application closed via 'X' button [message #1229527 is a reply to message #1229522] Thu, 09 January 2014 16:34 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Efxclipse
On 09.01.14 17:17, Joseph Gagnon wrote:
> How do I file a bug report?
Previous Topic:Issue with minimized PartStacks as replacement for FastViews
Next Topic:Add a Project Explorer in Eclipse 4 RCP Application
Goto Forum:
  


Current Time: Fri Apr 19 22:30:35 GMT 2024

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

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

Back to the top