Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Possible to control how IMementos are stored?
Possible to control how IMementos are stored? [message #437737] Mon, 03 October 2005 18:10 Go to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
I wonder if there is some kind of extension point, or way, to control how
IMementos are stored. Instead of placing them as XML files to the disk, I would
like to store and load them inside a database for instance.

Ben
Re: Possible to control how IMementos are stored? [message #437740 is a reply to message #437737] Mon, 03 October 2005 19:32 Go to previous messageGo to next message
Ben Brown is currently offline Ben BrownFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Ben,

I assume that you're talking about how Eclipsee uses IMementos to store
the layout for the workspace. I've been having a problem similar to
this (see
http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07130.html
and
http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07292.html)
centering around layouts. I've been able to save the IMemento off as a
string in a DB and then bring it back and create the main window using
the API defined in IPageLayout, however if you wish to have detached
views this isn't going to help much.

I'm working right now on being able to recreate the IMemento but am
having a few troubles because of our database freaking out around "\r\n"
being in the string and then the IMemento not liking those characters
absence on the other end. If you do get the IMemento reconstructed
correctly it should be as simple as calling

PerspectiveHelper.restoreState(IMemento)

If this is totally not what you were referring to with IMementos let me
know.

--Ben Brown

Benjamin Pasero wrote:
> I wonder if there is some kind of extension point, or way, to control
> how IMementos are stored. Instead of placing them as XML files to the
> disk, I would like to store and load them inside a database for instance.
>
> Ben
Re: Possible to control how IMementos are stored? [message #437750 is a reply to message #437740] Tue, 04 October 2005 06:54 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Hi Ben ( :) ),

yes I am referring to the IMemento which is passed into the init() Method
of a View for example. Not only I wanted to store layout related in there
but maybe other settings as well. But since I am using a Database for
persistance, I wanted to have IMemento in there as well, to be completly
independant of a filesystem (workspace).

So, did you manage to intercept the way Eclipse automatically stores the
IMemento to the workspace and use a database instead?

Sure, I could re-use the IMemento manually and maintain it via a Database,
but I would like to let Eclipse decide when to save/load the IMemento. I
only want to define how the IMemento is accessed (via DB instead of File).

Ben

> Hi Ben,
>
> I assume that you're talking about how Eclipsee uses IMementos to store
> the layout for the workspace. I've been having a problem similar to
> this (see
> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07130.html
> and
> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07292.html)
> centering around layouts. I've been able to save the IMemento off as a
> string in a DB and then bring it back and create the main window using
> the API defined in IPageLayout, however if you wish to have detached
> views this isn't going to help much.
>
> I'm working right now on being able to recreate the IMemento but am
> having a few troubles because of our database freaking out around "\r\n"
> being in the string and then the IMemento not liking those characters
> absence on the other end. If you do get the IMemento reconstructed
> correctly it should be as simple as calling
>
> PerspectiveHelper.restoreState(IMemento)
>
> If this is totally not what you were referring to with IMementos let me
> know.
>
> --Ben Brown
>
> Benjamin Pasero wrote:
>
>> I wonder if there is some kind of extension point, or way, to control
>> how IMementos are stored. Instead of placing them as XML files to the
>> disk, I would like to store and load them inside a database for instance.
>>
>> Ben
Re: Possible to control how IMementos are stored? [message #437765 is a reply to message #437750] Tue, 04 October 2005 13:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Benjamin Pasero wrote:
> Hi Ben ( :) ),
>
> yes I am referring to the IMemento which is passed into the init() Method
> of a View for example. Not only I wanted to store layout related in there
> but maybe other settings as well. But since I am using a Database for
> persistance, I wanted to have IMemento in there as well, to be completly
> independant of a filesystem (workspace).
>
> So, did you manage to intercept the way Eclipse automatically stores the
> IMemento to the workspace and use a database instead?
>
> Sure, I could re-use the IMemento manually and maintain it via a Database,
> but I would like to let Eclipse decide when to save/load the IMemento. I
> only want to define how the IMemento is accessed (via DB instead of File).
>
> Ben
>
>> Hi Ben,
>>
>> I assume that you're talking about how Eclipsee uses IMementos to
>> store the layout for the workspace. I've been having a problem
>> similar to this (see
>> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07130.html
>> and
>> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07292.html)
>> centering around layouts. I've been able to save the IMemento off as
>> a string in a DB and then bring it back and create the main window
>> using the API defined in IPageLayout, however if you wish to have
>> detached views this isn't going to help much.
>>
>> I'm working right now on being able to recreate the IMemento but am
>> having a few troubles because of our database freaking out around
>> "\r\n" being in the string and then the IMemento not liking those
>> characters absence on the other end. If you do get the IMemento
>> reconstructed correctly it should be as simple as calling
>>
>> PerspectiveHelper.restoreState(IMemento)
>>
>> If this is totally not what you were referring to with IMementos let
>> me know.
>>
>> --Ben Brown
>>
>> Benjamin Pasero wrote:
>>
>>> I wonder if there is some kind of extension point, or way, to control
>>> how IMementos are stored. Instead of placing them as XML files to the
>>> disk, I would like to store and load them inside a database for
>>> instance.
>>>
>>> Ben


Why are you trying to do this? IMemento should have only disposeable
information. It shouldn't be any valuable data. Blowing away all the
IMemento data can sometimes be necessary if things get screwed up.
should be ok to be on filesystem. Curious about your reasons.


CL
Re: Possible to control how IMementos are stored? [message #437769 is a reply to message #437765] Tue, 04 October 2005 14:26 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
CL [dnoyeb] Gilbert wrote:
> Benjamin Pasero wrote:
>
>> Hi Ben ( :) ),
>>
>> yes I am referring to the IMemento which is passed into the init() Method
>> of a View for example. Not only I wanted to store layout related in there
>> but maybe other settings as well. But since I am using a Database for
>> persistance, I wanted to have IMemento in there as well, to be completly
>> independant of a filesystem (workspace).
>>
>> So, did you manage to intercept the way Eclipse automatically stores the
>> IMemento to the workspace and use a database instead?
>>
>> Sure, I could re-use the IMemento manually and maintain it via a
>> Database,
>> but I would like to let Eclipse decide when to save/load the IMemento. I
>> only want to define how the IMemento is accessed (via DB instead of
>> File).
>>
>> Ben
>>
>>> Hi Ben,
>>>
>>> I assume that you're talking about how Eclipsee uses IMementos to
>>> store the layout for the workspace. I've been having a problem
>>> similar to this (see
>>> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07130.html
>>> and
>>> http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg07292.html)
>>> centering around layouts. I've been able to save the IMemento off as
>>> a string in a DB and then bring it back and create the main window
>>> using the API defined in IPageLayout, however if you wish to have
>>> detached views this isn't going to help much.
>>>
>>> I'm working right now on being able to recreate the IMemento but am
>>> having a few troubles because of our database freaking out around
>>> "\r\n" being in the string and then the IMemento not liking those
>>> characters absence on the other end. If you do get the IMemento
>>> reconstructed correctly it should be as simple as calling
>>>
>>> PerspectiveHelper.restoreState(IMemento)
>>>
>>> If this is totally not what you were referring to with IMementos let
>>> me know.
>>>
>>> --Ben Brown
>>>
>>> Benjamin Pasero wrote:
>>>
>>>> I wonder if there is some kind of extension point, or way, to
>>>> control how IMementos are stored. Instead of placing them as XML
>>>> files to the disk, I would like to store and load them inside a
>>>> database for instance.
>>>>
>>>> Ben
>
>
>
> Why are you trying to do this? IMemento should have only disposeable
> information. It shouldn't be any valuable data. Blowing away all the
> IMemento data can sometimes be necessary if things get screwed up.
> should be ok to be on filesystem. Curious about your reasons.

For a simple reason. I am going to store some settings in a database anyways,
so that it makes no difference from which computer a user logs in to use the
application. It would be nice to also have IMemento stored settings in the
database as well, to have same settings on any machine the application is
running.

Ben

>
>
> CL
Re: Possible to control how IMementos are stored? [message #437773 is a reply to message #437769] Tue, 04 October 2005 20:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Benjamin Pasero wrote:
>>
>>
>> Why are you trying to do this? IMemento should have only disposeable
>> information. It shouldn't be any valuable data. Blowing away all the
>> IMemento data can sometimes be necessary if things get screwed up.
>> should be ok to be on filesystem. Curious about your reasons.
>
>
> For a simple reason. I am going to store some settings in a database
> anyways,
> so that it makes no difference from which computer a user logs in to use
> the
> application. It would be nice to also have IMemento stored settings in the
> database as well, to have same settings on any machine the application is
> running.
>
> Ben
>
>>
>>
>> CL

But mementos don't store settings. Settings are stored in the project
or some other file. mementos are just view data. Anything that the
user can directly recall should be stored in a property somewhere right?


CL
Re: Possible to control how IMementos are stored? [message #437775 is a reply to message #437773] Tue, 04 October 2005 21:37 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
CL [dnoyeb] Gilbert wrote:
> Benjamin Pasero wrote:
>
>>>
>>>
>>> Why are you trying to do this? IMemento should have only disposeable
>>> information. It shouldn't be any valuable data. Blowing away all
>>> the IMemento data can sometimes be necessary if things get screwed
>>> up. should be ok to be on filesystem. Curious about your reasons.
>>
>>
>>
>> For a simple reason. I am going to store some settings in a database
>> anyways,
>> so that it makes no difference from which computer a user logs in to
>> use the
>> application. It would be nice to also have IMemento stored settings in
>> the
>> database as well, to have same settings on any machine the application is
>> running.
>>
>> Ben
>>
>>>
>>>
>>> CL
>
>
> But mementos don't store settings. Settings are stored in the project
> or some other file. mementos are just view data. Anything that the
> user can directly recall should be stored in a property somewhere right?

So, View data are not settings? If I look into the view settings saved for
my eclipse I am seeing a lot of stuff that I would call a setting, for example
the package explorer saving filters, selected element and others in
dialog_settings.xml which comes from a IMemento.

Ben

>
>
> CL
Re: Possible to control how IMementos are stored? [message #437809 is a reply to message #437775] Wed, 05 October 2005 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ujjwal_oracle.yahoo.com

Hi everyone,
I think Eclipse currently lets you store in other file system through the
XMLMemento !!!

But I think its important to let the user control the UI layout specific
settings through the Preferences which can be persisted in the DB..

Achieve what Eclipse does behind the scenes when persisting the state of
UI components in the workbench.xml.

eg..
<info part="org.eclipse.ui.internal.ViewStack@adcd81"
relative="bottomRight" relationship="2" ratioLeft="241" ratioRight="504"
ratio="0.32348993" folder="true">

However the requirement is that I persist such info for UI layout
temporarily in the memory (as some data structre) & finally when the
workbench is about to be closed I serialize it in the Backend DB..

I found that when you do the following ..

layout.addView(LabsView.ID, IPageLayout.TOP, new Float(0.60).floatValue(),
IPageLayout.ID_EDITOR_AREA);

Eclipse uses classes within org.eclipse.core.internal package to do the
behind the scene job..

Eg. It adds the view inside the ViewStack folder etc..

Is there any API / helper classes available to achieve the above mentioned
job..

My application would ultimately use preferences to restore the UI state.
Re: Possible to control how IMementos are stored? [message #437811 is a reply to message #437740] Wed, 05 October 2005 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ujjwal_oracle.yahoo.com

Hi Ben,
How are you able to receive the following events in the IViewPart ??

void init(IViewSite site, IMemento memento)
void saveState(IMemento memento)

Do you place your Plugin within the <plugins> folder itself -- coz' thats
the only time the workbench invokes these API's passing the memento object
created out of workbench.xml

Consider this scenario..
I have a Application where I contribute my own Plugins for
Perspective,Views etc.
The workbench passes a NULL memento upon init & it doesn't fire saveState
atall.

Any idea why this difference in behaviour ?
Re: Possible to control how IMementos are stored? [message #437816 is a reply to message #437811] Wed, 05 October 2005 13:18 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The mementos were originally intended to save session state. The
saveState() and restoreState()/init(site, memento) are only called on
workbench shutdown and startup respectively.

ex: If a view is open on startup, it can get its init(...) called with a
memento (if there was one saved on shutdown). If you close the view
(from all perspectives) and open it using Window>Show View, the
init(...) is called with no memento or a memento of null.

Later,
PW


Re: Possible to control how IMementos are stored? [message #437817 is a reply to message #437816] Wed, 05 October 2005 13:38 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Paul Webster wrote:
> The mementos were originally intended to save session state. The
> saveState() and restoreState()/init(site, memento) are only called on
> workbench shutdown and startup respectively.
>
> ex: If a view is open on startup, it can get its init(...) called with a
> memento (if there was one saved on shutdown). If you close the view
> (from all perspectives) and open it using Window>Show View, the
> init(...) is called with no memento or a memento of null.

Ok I am now understanding your point. The IMemento passed into the init
Method is not very usefull for my case, because it stops working when
closing / opening Views in a running session.

I think for that reason the Package Explorer is using Dialog-Settings to
force save of settings on dispose and reloads from there on open.

I will implement some kind of DBMemento then, that connects to a DB.

Thanks for making this clear to me!

Ben

>
> Later,
> PW
Re: Possible to control how IMementos are stored? [message #437827 is a reply to message #437775] Wed, 05 October 2005 15:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Benjamin Pasero wrote:
> CL [dnoyeb] Gilbert wrote:
>
>> Benjamin Pasero wrote:
>>
>>>>
>>>>
>>>> Why are you trying to do this? IMemento should have only
>>>> disposeable information. It shouldn't be any valuable data.
>>>> Blowing away all the IMemento data can sometimes be necessary if
>>>> things get screwed up. should be ok to be on filesystem. Curious
>>>> about your reasons.
>>>
>>>
>>>
>>>
>>> For a simple reason. I am going to store some settings in a database
>>> anyways,
>>> so that it makes no difference from which computer a user logs in to
>>> use the
>>> application. It would be nice to also have IMemento stored settings
>>> in the
>>> database as well, to have same settings on any machine the
>>> application is
>>> running.
>>>
>>> Ben
>>>
>>>>
>>>>
>>>> CL
>>
>>
>>
>> But mementos don't store settings. Settings are stored in the project
>> or some other file. mementos are just view data. Anything that the
>> user can directly recall should be stored in a property somewhere right?
>
>
> So, View data are not settings? If I look into the view settings saved for
> my eclipse I am seeing a lot of stuff that I would call a setting, for
> example
> the package explorer saving filters, selected element and others in
> dialog_settings.xml which comes from a IMemento.
>
> Ben
>
>>
>>
>> CL


If they do, then its a bad thing. When I go from one workbench to the
next I like to think I can export my settings and import them. Mementos
are not exported so those settings will not be transferred. Things like
this should be controlled by preferences and other settings that you can
export.

View data would be which filter to use, but the filter itself should be
defined in something more permanently persisted I think.

Not saying this is some kind of rule, but I think its a sound strategy
and I try to follow it myself.


CL
Re: Possible to control how IMementos are stored? [message #437829 is a reply to message #437816] Wed, 05 October 2005 15:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ujjwal_oracle.yahoo.com

Hi Paul,
Is there any API / helper classes available for capturing the Bounds of
the View/Editor etc. instead of relying on the Workbench internals.
So that when the init() on the WorkbenchPart is invoked , I can read the
preferences from the store & restore the UI layout..

That way one can mange one's own preference store per plugin level..

Cheers,
Ujjwal
Re: Possible to control how IMementos are stored? [message #437831 is a reply to message #437817] Wed, 05 October 2005 15:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Benjamin Pasero wrote:
> Paul Webster wrote:
>
>> The mementos were originally intended to save session state. The
>> saveState() and restoreState()/init(site, memento) are only called on
>> workbench shutdown and startup respectively.
>>
>> ex: If a view is open on startup, it can get its init(...) called with
>> a memento (if there was one saved on shutdown). If you close the view
>> (from all perspectives) and open it using Window>Show View, the
>> init(...) is called with no memento or a memento of null.
>
>
> Ok I am now understanding your point. The IMemento passed into the init
> Method is not very usefull for my case, because it stops working when
> closing / opening Views in a running session.
>
> I think for that reason the Package Explorer is using Dialog-Settings to
> force save of settings on dispose and reloads from there on open.
>
> I will implement some kind of DBMemento then, that connects to a DB.
>
> Thanks for making this clear to me!
>
> Ben
>
>>
>> Later,
>> PW


Also note that he said 'session' state. This implies mementos are
dumped. I think this is what mementos were meant to be, and are.

Consider if you have saved session state, but somebody else has changed
the actual models in the database. Now you open your workbench and it
hands you a memento that suggest certain items should be displayed. Yet
those items actually don't exist anymore. You should simply ignore that
part of the memento and keep going.

So memento can contain view state that is not valid for the actual model
anymore.

Another example of memento would be closing a workbench with certain
files open. Next time you open the workbench it will try to open those
files again. They may not be there. You will get an exception in the
log, but the user wont know about it and those files will simply not e
opened.

CL
Re: Possible to control how IMementos are stored? [message #437832 is a reply to message #437829] Wed, 05 October 2005 15:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The short answer is no ... there's no public API for that except what is
exposed in IPageLayout and perspective factories.

If you have specific examples/use cases you can open an enhancement in
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform against
Platform/UI

Later,
PW


Re: Possible to control how IMementos are stored? [message #437839 is a reply to message #437829] Wed, 05 October 2005 17:24 Go to previous message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Ujjwal Sinha wrote:
> Hi Paul,
> Is there any API / helper classes available for capturing the Bounds of
> the View/Editor etc. instead of relying on the Workbench internals.
> So that when the init() on the WorkbenchPart is invoked , I can read the
> preferences from the store & restore the UI layout..
>
> That way one can mange one's own preference store per plugin level..
>
> Cheers,
> Ujjwal
>

the purpose of the memento pattern is to allow one to store an objects
state without knowing much about that object. If you have an api, it
defeats the purpose of the memento patern. In other words, this is the
wrong place for this type of functionality.

How I would suggest you do this is let them lay out the windows as they
want. This layout will automatically be stored in a memento when the
bench is closed. And automatically restored when the bench is opened.
Thats what memento is for.

If you want to store a particular layout more permanently, add a button
to the workbench somewhere thats for storing the layout. When that
button is pressed, you ask user for a name, and store the layout in a
more permanent place, using the API.

That is how it works now, and they are called perspectives.


Hope this helps,


CL
Previous Topic:webstart, RCP, and linux
Next Topic:How to catch the event of perspective switch???
Goto Forum:
  


Current Time: Thu Dec 26 14:45:03 GMT 2024

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

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

Back to the top