|
Re: IMemento usage [message #523330 is a reply to message #522278] |
Thu, 25 March 2010 22:29 |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03121 seconds