Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: AW: AW: [jwt-dev] How to add some code that is run when a property is changed?

Hi,

That is exactly what I was looking for. You also answered a question I was going to send about widgets to open dialog in properties field.
Thanks a lot!

Regards,
Mickael


Florian Lautenbacher a écrit :
Hi Mickael, hi Chris,

maybe a better place to put your changes into, would be the class
org.eclipse.jwt.we.editors.properties.CustomAdapterFactoryContentProvider.
Here, you'll find a method createPropertySource that is called each time a
specific property is selected. As you can see everything is normally handled
by EMF here, except of the field NamedElement.Icon,  which opens a new file
dialog box. So, here you could create a new else clause which opens a window
where you might also select an already existing WSDL-file. See below a short
example:

protected IPropertyDescriptor createPropertyDescriptor(
					IItemPropertyDescriptor
itemPropertyDescriptor)
			{
				if
(itemPropertyDescriptor.getDisplayName(object).equals(icon_name))
				{
					return new
CustomIconPropertyDescriptor(object, itemPropertyDescriptor);
				}
				//***********
				else if
(itemPropertyDescriptor.getDisplayName(object).equals(
	
PluginProperties.model_feature_name(ApplicationPackage.Literals.WEBSERVICEAP
PLICATION__INTERFACE))
					return new MickaelsMethod(); ;-)
				}
				//***********
				else
				{
					return
super.createPropertyDescriptor(itemPropertyDescriptor);
				}
			}


Hope that helps a little bit.

Best regards,

Florian


-----Ursprüngliche Nachricht-----
Von: jwt-dev-bounces@xxxxxxxxxxx [mailto:jwt-dev-bounces@xxxxxxxxxxx] Im
Auftrag von Mickael Istria
Gesendet: 20 June 2008 15:14
An: Java Workflow Toolbox
Betreff: Re: AW: [jwt-dev] How to add some code that is run when a
propertyis changed?

Hello Christian,

thank you for your answer.
Since my work is currently a "proof of concept" (and also a way to get used
to EMF), I think this implementation is ok for the moment. Moreover, as we discussed in last mails, metamodel will have to be modified
one day to better handle abstract applications. I'll go one implementing
these features that way, and I think about adding them to JWT when the
metamodel get modified (especially the WebServiceApplication).

Regards
Mickael

Christian Saad a écrit :
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.WebServiceApplicationItemPr
ovider (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.APPLIC ATION__JAVA_CLASS), WSDL2JavaName.getClassName(((WebServiceApplication)notification.getNot
ifier()).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 <mailto:jwt-dev@xxxxxxxxxxx> https://dev.eclipse.org/mailman/listinfo/jwt-dev

----------------------------------------------------------------------
--

_______________________________________________
jwt-dev mailing list
jwt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jwt-dev

_______________________________________________
jwt-dev mailing list
jwt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jwt-dev

_______________________________________________
jwt-dev mailing list
jwt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jwt-dev



Back to the top