for (LicenseObject distribution : m_distributionRepository.get()) {
add(distribution);
}
}
public void handleEvent(org.osgi.service.event.Event event) {
LicenseObject distribution = (LicenseObject) event.getProperty(LicenseObject.EVENT_ENTITY);
String topic = (String) event.getProperty(EventConstants.EVENT_TOPIC);
if (LicenseObject.TOPIC_ADDED.equals(topic)) {
add(distribution);
}
if (LicenseObject.TOPIC_REMOVED.equals(topic)) {
remove(distribution);
}
if (LicenseObject.TOPIC_CHANGED.equals(topic)) {
change(distribution);
}
}
private void add(LicenseObject distribution) {
Item item = addItem(distribution.getName());
item.getItemProperty(OBJECT_NAME).setValue(distribution.getName());
item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
Button removeLinkButton = new RemoveLinkButton<LicenseObject>(distribution, m_featuresPanel, m_targetsPanel) {
@Override
protected void removeLinkFromLeft(LicenseObject object, RepositoryObject other) {
List<Group2LicenseAssociation> associations = object.getAssociationsWith((GroupObject) other);
for (Group2LicenseAssociation association : associations) {
m_group2LicenseAssociationRepository.remove(association);
}
m_associations.removeAssociatedItem(object);
m_table.requestRepaint();
}
@Override
protected void removeLinkFromRight(LicenseObject object, RepositoryObject other) {
List<License2GatewayAssociation> associations = object.getAssociationsWith((GatewayObject) other);
for (License2GatewayAssociation association : associations) {
m_license2GatewayAssociationRepository.remove(association);
}
m_associations.removeAssociatedItem(object);
m_table.requestRepaint();
}
};
HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(removeLinkButton);
buttons.addComponent(new RemoveItemButton<LicenseObject, LicenseRepository>(distribution, m_distributionRepository));
item.getItemProperty(ACTIONS).setValue(buttons);
}
private void change(LicenseObject distribution) {
Item item = getItem(distribution.getName());
item.getItemProperty(OBJECT_DESCRIPTION).setValue(distribution.getDescription());
}
private void remove(LicenseObject distribution) {
removeItem(distribution.getName());
}
};
}