[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: Editor doesn't recognizes model changes.

Hello Alex!

First of all: Thanks a lot for the effort you put into helping me and all the others here! :)

Now nearly everything is working. I can add, edit and delete vehicles and they`re shown in the right way.
What is still not working: The Listener, which should redraw the vehicles, when a new vehicle is added or a vehicle is removed or a attribute is changed.


I tried the following: Inside the setInput-method I add the "EMF Listener" which you suggested (took me some time to find out, that EMF listeners are also called Adapters) to the Location-Object (not the LocationEditPart).
When I remove this part of code you see below, everything works. When I add it, the editor starts to act...funny:
Sometimes I`m not abel to add or remove vehicles at all. Then suddenly other property-tabs, which do not have anything to do with my vehicle-tab, aren`t working.


And the listener is not even called when an attribute is changed, although I change attributes the same way I add and remove vehicles (I do this with an AbstractTransactionalCommand)

help!
Julia



thisLocation.eAdapters().add(new Adapter() {
private Notifier notifier;
					
@Override
public void setTarget(Notifier newTarget) {
	notifier = newTarget;
}
					
@Override
public Notifier getTarget() {
	return notifier;
}

@Override
public boolean isAdapterForType(Object arg0) {
	return false;
}

@Override
public void notifyChanged(Notification notification) {
						
if (notification.getEventType() == Notification.ADD) {
if (notification.getNewValue() instanceof VehicleImpl) {
	// called, when vehicle is added
	drawVehicles();
}
}
else if(notification.getEventType() == Notification.REMOVE) {
if (notification.getOldValue() instanceof VehicleImpl) {
	// called, when vehicle is removed
	drawVehicles();
}
}
else if(notification.getEventType() == Notification.SET) {
	// this is not called, when an attribute is changed
}
}
					
});