Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » IMemento usage
IMemento usage [message #522278] Mon, 22 March 2010 02:07 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Hi,
I'm trying to follow advice from Tom Schindl's tutorial on EMF Databinding.
I have a few problems due to the fact my setup isn't identical to his.

I have a real EditorPart actually:

public class WorldEditor extends FormEditor implements
IResourceChangeListener {

In some pages of this multipage editor I use master-detail.

Problems:

1) "Restoring view state information" section relies on the init(final
IViewSite site, IMemento memento) call; I have not been able to find an
equivalent for Editors: where is it?

2) I have not been able to limit the growth of some Text(SWT.MULTI) I
have; this results in very ugly layout: what should I override?

I do realize this post lacks a lot of information and I'm prepared to
give it, but I am unsure about what might be useful and I didn't want to
post a lot of useless data.

Any pointer *very* welcome.

Thanks in advance
Mauro
Re: IMemento usage [message #523330 is a reply to message #522278] Thu, 25 March 2010 22:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rjl.third-monday.com

I think you're just wondering how to use IMemento structure for editors, eh?

here's what I do:

1) Implement a org.eclipse.ui.IElementFactory class with:
public static final String ID_FACTORY = "ElementFactory";
public IAdaptable createElement(IMemento memento) {
IEditorInput element = null;
if (<object
classname>.equals(memento.getString(Persist.OBJECT_CLASS)))
{
try {
Long key =
Long.parseLong(memento.getString(Persist.OBJECT_KEY));
element = new EditorInput (<get object from model using
'key'>,
false);
} catch (Exception e) {
} finally {
}
}
return element;
}

2) Implement a org.eclipse.ui.IPersistableElement with:
public final static String OBJECT_KEY = "object.key";
public final static String OBJECT_CLASS = "object.class";
private <Object> object = null;

public Persist (<Object> d) {
object = d;
}

public String getFactoryId() {
return ElementFactory.ID_FACTORY;
}

public void saveState(IMemento memento) {
if (null != object) {
memento.putString(OBJECT_KEY, object.getKey().toString());
memento.putString(OBJECT_CLASS, <Object classname>);
}
}

In the plugin.xml:

<extension
point="org.eclipse.ui.elementFactories">
<factory
class="<IElementFactory class>"
id="ID_FACTORY from class"/>
</extension>

is that what you're after?

On 03/21/2010 09:07 PM, Mauro Condarelli wrote:
> Hi,
> I'm trying to follow advice from Tom Schindl's tutorial on EMF Databinding.
> I have a few problems due to the fact my setup isn't identical to his.
>
> I have a real EditorPart actually:
>
> public class WorldEditor extends FormEditor implements
> IResourceChangeListener {
>
> In some pages of this multipage editor I use master-detail.
>
> Problems:
>
> 1) "Restoring view state information" section relies on the init(final
> IViewSite site, IMemento memento) call; I have not been able to find an
> equivalent for Editors: where is it?
>
> 2) I have not been able to limit the growth of some Text(SWT.MULTI) I
> have; this results in very ugly layout: what should I override?
>
> I do realize this post lacks a lot of information and I'm prepared to
> give it, but I am unsure about what might be useful and I didn't want to
> post a lot of useless data.
>
> Any pointer *very* welcome.
>
> Thanks in advance
> Mauro
Re: IMemento usage [message #524340 is a reply to message #523330] Wed, 31 March 2010 10:04 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On top of that, you need to implement org.eclipse.ui.IPersistableEditor
to be notified of any saved IMemento on restart.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Build ID in product splash screen
Next Topic:How to get menumanager of Main menu in a treeviewer
Goto Forum:
  


Current Time: Fri Apr 19 20:10:35 GMT 2024

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

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

Back to the top