@Override
public void handleEvent(Event event) {
Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
if (changedObj instanceof MPartStack) {
MPartStack parent = (MPartStack) changedObj;
if (BaseStackRenderer.this == parent.getRenderer()) {
String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
if (UIEvents.EventTypes.ADD.equals(eventType)) {
MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
handleChildAddition(parent, (MStackElement) element);
} else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
handleChildRemove(parent, (MStackElement) element);
}
}
}
}
});
eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {
@Override
public void handleEvent(Event event) {
Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
if (changedObj instanceof MPartStack) {
MPartStack parent = (MPartStack) changedObj;
if (BaseStackRenderer.this == parent.getRenderer()) {
String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
if (UIEvents.EventTypes.SET.equals(eventType)) {
MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
handleSelectedElement(parent, (MStackElement) oldValue, (MStackElement) newValue);
}
}
}
}
});
eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {
@Override
public void handleEvent(Event event) {
MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
if( changedObj.isToBeRendered() ) {
MUIElement parent = changedObj.getParent();
if( parent != null ) {
if( BaseStackRenderer.this == parent.getRenderer() ) {
MPartStack stack = (MPartStack) parent;
String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
if (UIEvents.EventTypes.SET.equals(eventType)) {
Boolean newValue = (Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
if( newValue.booleanValue() ) {
//TODO Is childRendered not dangerous to call here??