Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Hot to programmatically tell the framework to clear the persisted state
Hot to programmatically tell the framework to clear the persisted state [message #1384815] Mon, 02 June 2014 09:51 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hello,

I am looking for a way to give the user the possibility to "reset" the ui to it's initial layout. My idea is to restart the application (using IWorkbench.restart()) and then have the framework clear the persisted state.

1) Using -clearPersistedState as a startup command is difficult, since I'm using IApplication.RESTART to do the restarting.

2) There is IApplication.RELAUNCH. I played with this, but didn't find the way to get it to work. Does that even work with e4 applications? Anyway ... the api is not realy intuitive.

Looking at the code I see that IWorkbench.CLEAR_PERSISTED_STATE is saved to the context before the application model is loaded. That's great Smile! I would like to reuse that and set the value during @PostcontextCreate. Unfortunately this is overwritten in loadApplicationModel. In @ProcessAdditions it is already to late, because the app-model hasbeen built be then.

So I am thinking about changing AbstractE4Application to check first if the value is already in the context before setting it. This could also make sense for IWorkbench.PERSIST_STATE, IWorkbench.XMI_URI_ARG and IWorkbench.MODEL_RESOURCE_HANDLER.

I'll do the work, but wanted to get some input first. Maybe I am missing something? Is there already a good way to do this?

Christoph

Re: Hot to programmatically tell the framework to clear the persisted state [message #1384817 is a reply to message #1384815] Mon, 02 June 2014 10:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Yes that sounds like the way to go and sounds like a nice new feature
and certainly the first important step!

An even improved version (and future step) would make this feature
available without having to deal with @PostContextCreate one idea might
to allow someone to store this information in the perferences and on
next start we make use of this preference value (and remove it
immediately afterwards).

Another reason to clear the state is that someone installed/uninstalled
plugins using p2 and now you want to start from a clean ui state!

Tom

On 02.06.14 11:51, Christoph Keimel wrote:
> Hello,
>
> I am looking for a way to give the user the possibility to "reset" the
> ui to it's initial layout. My idea is to restart the application (using
> IWorkbench.restart()) and then have the framework clear the persisted
> state.
>
> 1) Using -clearPersistedState as a startup command is difficult, since
> I'm using IApplication.RESTART to do the restarting.
>
> 2) There is IApplication.RELAUNCH. I played with this, but didn't find
> the way to get it to work. Does that even work with e4 applications?
> Anyway ... the api is not realy intuitive.
>
> Looking at the code I see that IWorkbench.CLEAR_PERSISTED_STATE is saved
> to the context before the application model is loaded. That's great :)!
> I would like to reuse that and set the value during @PostcontextCreate.
> Unfortunately this is overwritten in loadApplicationModel. In
> @ProcessAdditions it is already to late, because the app-model hasbeen
> built be then.
>
> So I am thinking about changing AbstractE4Application to check first if
> the value is already in the context before setting it. This could also
> make sense for IWorkbench.PERSIST_STATE, IWorkbench.XMI_URI_ARG and
> IWorkbench.MODEL_RESOURCE_HANDLER.
>
> I'll do the work, but wanted to get some input first. Maybe I am missing
> something? Is there already a good way to do this?
>
> Christoph
>
>
Re: Hot to programmatically tell the framework to clear the persisted state [message #1384824 is a reply to message #1384817] Mon, 02 June 2014 11:24 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
> Yes that sounds like the way to go and sounds like a nice new feature
> and certainly the first important step!

An implementation is up vor review:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436351

> An even improved version (and future step) would make this feature
> available without having to deal with @PostContextCreate one idea might
> to allow someone to store this information in the perferences and on
> next start we make use of this preference value (and remove it
> immediately afterwards).

That is the way I am handling it. The question would be where to put the API.
IWorkbench seems a good candidate: maybe IWorkbench.restartWithClearedPersistedState()
next to the already available IWorkbench.restart().

> Another reason to clear the state is that someone installed/uninstalled
> plugins using p2 and now you want to start from a clean ui state!

Yeah. I mark plug-ins with a special property in a p2.inf, so that I can
check weather the persisted state has to be cleared after an update.

Re: Hot to programmatically tell the framework to clear the persisted state [message #1384830 is a reply to message #1384824] Mon, 02 June 2014 11:56 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 02.06.14 13:24, Christoph Keimel wrote:
>> Yes that sounds like the way to go and sounds like a nice new feature
>> and certainly the first important step!
>
> An implementation is up vor review:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=436351
>
>> An even improved version (and future step) would make this feature
>> available without having to deal with @PostContextCreate one idea might
>> to allow someone to store this information in the perferences and on
>> next start we make use of this preference value (and remove it
>> immediately afterwards).
>
> That is the way I am handling it. The question would be where to put the
> API.
> IWorkbench seems a good candidate: maybe
> IWorkbench.restartWithClearedPersistedState()
> next to the already available IWorkbench.restart().

IWorkbench is defined by upstream, because restart() is there already it
makes sense to have such a method there as well.

The problem I see with IWorkbench is that you drag in too much things.

I would be in favor of a service definition which only exposes:
* restart(boolean clear)
* shutdown()

found in org.eclipse.fx.ui.services and in our E4Application we push a
service to the context which implements the semantics. Does that make
sense to you?

>
>> Another reason to clear the state is that someone installed/uninstalled
>> plugins using p2 and now you want to start from a clean ui state!
>
> Yeah. I mark plug-ins with a special property in a p2.inf, so that I can
> check weather the persisted state has to be cleared after an update.

Do you think we can generalize such a thing somehow? We already have a
(not yet maintained p2 install support in org.eclipse.fx.core.p2) - I'm
not sure about the quality of the code in there.

Something we yet miss completely is a p2 update UI (nothing as complex
as the IDE has)

Tom
Re: Hot to programmatically tell the framework to clear the persisted state [message #1384847 is a reply to message #1384830] Mon, 02 June 2014 13:57 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
> I would be in favor of a service definition which only exposes:
> * restart(boolean clear)
> * shutdown()

> found in org.eclipse.fx.ui.services and in our E4Application we push a
> service to the context which implements the semantics. Does that make
> sense to you?

Yeah. Let's have a bug to continue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436369

> Do you think we can generalize such a thing somehow? We already have a
> (not yet maintained p2 install support in org.eclipse.fx.core.p2) - I'm
> not sure about the quality of the code in there.

> Something we yet miss completely is a p2 update UI (nothing as complex
> as the IDE has)

I'll have a look at it when I migrate our e4-swt p2-update-stuff to e4-fx.
Previous Topic:Resize a Part in pixel
Next Topic:2 Parts shared the same model
Goto Forum:
  


Current Time: Fri Apr 19 08:17:11 GMT 2024

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

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

Back to the top