Hi Mickael,
the ItemProviders are generated from the EMF metamodel. However,
it is possible to modify these classes but you need to remove the “@generated”
tag from the method or to change it to something like “@generated NOT” or
your changes will be overwritten the next time the model edit code is
automatically generated. The problem with this solution is, that changes in the
automatically managed code can affect future alterations in the metamodel as
possibly more handwritten code has to be manually adapted to the new situation.
Another possibility would be to intercept the property change in the editpart
of this model element (notifiychanged method), however this only works if the
model element is currently displayed in the graphical editor.
Regards,
Christian
Von: jwt-dev-bounces@xxxxxxxxxxx
[mailto:jwt-dev-bounces@xxxxxxxxxxx] Im Auftrag von Mickael Istria
Gesendet: Freitag, 20. Juni 2008 14:35
An: Java Workflow Toolbox
Betreff: Re: [jwt-dev] How to add some code that is run when a property
is changed?
Hello,
After some investigation, I succeded to do what I want.
However, I an not sure whether this change affects EMF metamodel logic (bad) or
of the application logic (good)
Instead of a long explication, I'll show you what I changed.
The modified class is
org.eclipse.jwt.model.application.provider.WebServiceApplicationItemProvider
(part of the model, or part of the application?)
@Override
public void notifyChanged(Notification notification)
{
updateChildren(notification);
switch
(notification.getFeatureID(WebServiceApplication.class))
{
case
ApplicationPackage.WEB_SERVICE_APPLICATION__INTERFACE:
case
ApplicationPackage.WEB_SERVICE_APPLICATION__OPERATION:
fireNotifyChanged(new ViewerNotification(notification, notification
.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
was replaced by
@Override
public void notifyChanged(Notification notification)
{
updateChildren(notification);
switch
(notification.getFeatureID(WebServiceApplication.class))
{
case
ApplicationPackage.WEB_SERVICE_APPLICATION__INTERFACE:
fireNotifyChanged(new ViewerNotification(notification, notification
.getNotifier(), false, true));
//
Should generate a notification instead of hardcode value change
try
{
this.setPropertyValue(
notification.getNotifier(),
PluginProperties.model_feature_name(ApplicationPackage.Literals.APPLICATION__JAVA_CLASS),
WSDL2JavaName.getClassName(((WebServiceApplication)notification.getNotifier()).getInterface()));
}
catch (Exception ex) {
System.err.println("Could not find class name from WSDL
File");
ex.printStackTrace();
}
return;
case
ApplicationPackage.WEB_SERVICE_APPLICATION__OPERATION:
fireNotifyChanged(new ViewerNotification(notification, notification
.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
Thanks in advance for your answers!
Mickael
Mickael Istria a écrit :
Hello,
The title of the mail is maybe clear enough, but I will give you a concrete
example of what I wish to do:
I want that when someone set the property "Interface" of the
WebServiceApplication (I assumed that this interface is the location of wsdl
file, this is just a "proof of concept"), JWT tries to get the Java
interface that matches this WSDL, and then set the value of JavaClass property
to this result.
However, I did not find how to to this, except by changing the implementation
of WebServiceApplication in the metamodel (but this is - in my opinion - a very
bad solution to get what I want). I saw a system of notifications, but I did
not understood it enough to know if it is the good way.
Do you have any clue about how to implement this (kind of) feature?
Thanks in advance
Mickael
_______________________________________________
jwt-dev mailing list
jwt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jwt-dev