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 14:10  |
Eclipse User |
|
|
|
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 02:54   |
Eclipse User |
|
|
|
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 09:56   |
Eclipse User |
|
|
|
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 10:26   |
Eclipse User |
|
|
|
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 #437831 is a reply to message #437817] |
Wed, 05 October 2005 11:40   |
Eclipse User |
|
|
|
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 #437839 is a reply to message #437829] |
Wed, 05 October 2005 13:24  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Wed May 14 15:18:33 EDT 2025
Powered by FUDForum. Page generated in 0.05471 seconds
|