|
|
Re: GMF Properties Sheet View [message #224594 is a reply to message #224264] |
Tue, 07 April 2009 08:34 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Hello Jose,
Perhaps this article may help you:
http://www.eclipse.org/articles/Article-Tabbed-Properties/ta bbed_properties_view.html
Especially the part with the lifecycle and the following.
I have in my diagram a class "Location" with its "LocationEditPart". In
setInput() I get the EditPart from the input and the EMF class with
..getModel().getElement(). I save the EMF class in the variable thisLocation.
And in aboutToBeShown() I add a Adapter like this:
public void aboutToBeShown()
{
super.aboutToBeShown();
if(thisLocation != null)
{
thisLocation.eAdapters().add(listenToLocationChanges);
}
}
In aboutToBeHidden() the Adapter needs to be removed!
And the Adapter looks like this:
Adapter listenToLocationChanges = new Adapter()
{
private Notifier notifier;
@Override
public void setTarget(Notifier newTarget) {
notifier = newTarget;
}
@Override
public Notifier getTarget() {
return notifier;
}
@Override
public boolean isAdapterForType(Object object) {
return false;
}
@Override
public void notifyChanged(Notification notification)
{
// gets called whenever something is changed at location
}
}
In notifyChanged I check for different changes and when they happen I
call refresh().
Hope this helps.
Best wishes
Julia
José schrieb:
> Hi all,
> I'm developing a property view for a GMF eclipse application. I take the
> sheet package and I implement my own class extending
> AbstractPropertyClass. I can create all the control extending the method
> CreateControl. I extend the method setInput too to give to the property
> view the corresponding EditPart. Then, now I get a property view that
> loads the EMF class and its attributes but isn't synchronized with the
> EMF class in the EMF model.
> The problem that I have is I have my own fields elements, not the table
> standard view and I don't know what is the right way to synchronize my
> elements with the GMF diagram view and with the EMF model. Can anyone
> help me??
>
> Thank you
>
|
|
|
|
Re: GMF Properties Sheet View [message #224647 is a reply to message #224608] |
Tue, 07 April 2009 11:06 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
This is a multi-part message in MIME format.
--------------010305080304080902000508
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hello Jose,
that thing with the text-listener sounds good. That`s what I`m doing too.
In createCommand() I create a textfield for the attribute and add a
ModifyListener. Like I told you before I get thisLocation in setInput().
In refresh() I set the current attribute-value to the textfield with
".setText(thisLocation.getAttribute())". And in the listener I set the
attribute-value with thisLocation.setAttribute() inside of a command.
I`ll attach the ModifyListener with the Command in a text-file.
Choose the String at AbstractTransactionalCommand wisely (in my example
I wrote "set location attribute") because that`s what the user sees when
he chooses in the menu "Edit"->"Undo set location attribute". And then
everything what you did inside of the command is undone.
Hope this helps
Julia
Jos
|
|
|
Powered by
FUDForum. Page generated in 0.03234 seconds