Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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


Back to the top