add(statefulTarget);
}
}
public void handleEvent(org.osgi.service.event.Event event) {
StatefulGatewayObject statefulTarget = (StatefulGatewayObject) event.getProperty(StatefulGatewayObject.EVENT_ENTITY);
String topic = (String) event.getProperty(EventConstants.EVENT_TOPIC);
if (StatefulGatewayObject.TOPIC_ADDED.equals(topic)) {
add(statefulTarget);
}
if (StatefulGatewayObject.TOPIC_REMOVED.equals(topic)) {
remove(statefulTarget);
}
if (StatefulGatewayObject.TOPIC_CHANGED.equals(topic)) {
change(statefulTarget);
}
}
private void add(StatefulGatewayObject statefulTarget) {
Item item = addItem(statefulTarget.getID());
item.getItemProperty(OBJECT_NAME).setValue(statefulTarget.getID());
item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
Button removeLinkButton = new RemoveLinkButton<StatefulGatewayObject>(statefulTarget, m_distributionsPanel, null) {
@Override
protected void removeLinkFromLeft(StatefulGatewayObject object, RepositoryObject other) {
List<License2GatewayAssociation> associations = object.getAssociationsWith((LicenseObject) other);
for (License2GatewayAssociation association : associations) {
m_license2GatewayAssociationRepository.remove(association);
}
m_associations.removeAssociatedItem(object);
m_table.requestRepaint();
}
@Override
protected void removeLinkFromRight(StatefulGatewayObject object, RepositoryObject other) {
}
};
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(removeLinkButton);
// next line commented out because removing stateful targets currently is not possible
//buttons.addComponent(new RemoveItemButton<StatefulGatewayObject, StatefulGatewayRepository>(statefulTarget, m_statefulTargetRepository));
item.getItemProperty(ACTIONS).setValue(buttons);
}
private void change(StatefulGatewayObject statefulTarget) {
Item item = getItem(statefulTarget.getID());
item.getItemProperty(OBJECT_DESCRIPTION).setValue("");
}
private void remove(StatefulGatewayObject statefulTarget) {
removeItem(statefulTarget.getID());
}
};
}