add(artifact);
}
}
public void handleEvent(org.osgi.service.event.Event event) {
ArtifactObject artifact = (ArtifactObject) event.getProperty(ArtifactObject.EVENT_ENTITY);
String topic = (String) event.getProperty(EventConstants.EVENT_TOPIC);
if (ArtifactObject.TOPIC_ADDED.equals(topic)) {
add(artifact);
}
if (ArtifactObject.TOPIC_REMOVED.equals(topic)) {
remove(artifact);
}
if (ArtifactObject.TOPIC_CHANGED.equals(topic)) {
change(artifact);
}
}
private void add(ArtifactObject artifact) {
String resourceProcessorPID = artifact.getAttribute(BundleHelper.KEY_RESOURCE_PROCESSOR_PID);
if (resourceProcessorPID != null) {
// if it's a resource processor we don't add it to our list, as resource processors don't
// show up there (you can query for them separately)
return;
}
Item item = addItem(artifact.getName());
item.getItemProperty(OBJECT_NAME).setValue(artifact.getName());
item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
HorizontalLayout buttons = new HorizontalLayout();
Button removeLinkButton = new RemoveLinkButton<ArtifactObject>(artifact, null, m_featuresPanel) {
@Override
protected void removeLinkFromLeft(ArtifactObject object, RepositoryObject other) {}
@Override
protected void removeLinkFromRight(ArtifactObject object, RepositoryObject other) {
List<Artifact2GroupAssociation> associations = object.getAssociationsWith((GroupObject) other);
for (Artifact2GroupAssociation association : associations) {
m_artifact2GroupAssociationRepository.remove(association);
}
m_associations.removeAssociatedItem(object);
m_table.requestRepaint();
}
};
buttons.addComponent(removeLinkButton);
buttons.addComponent(new RemoveItemButton<ArtifactObject, ArtifactRepository>(artifact, m_artifactRepository));
item.getItemProperty(ACTIONS).setValue(buttons);
}
private void change(ArtifactObject artifact) {
Item item = getItem(artifact.getName());
item.getItemProperty(OBJECT_DESCRIPTION).setValue(artifact.getDescription());
}
private void remove(ArtifactObject artifact) {
removeItem(artifact.getName());
}
};
}