LabelListener labelListener = null;
try {
/* Add */
ILabel label = fFactory.createLabel(null, "Label Name");
final boolean labelEvents[] = new boolean[3];
final LabelReference labelReference[] = new LabelReference[1];
labelListener = new LabelListener() {
public void entitiesAdded(Set<LabelEvent> events) {
for (LabelEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
labelEvents[0] = true;
}
}
public void entitiesDeleted(Set<LabelEvent> events) {
for (LabelEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (labelReference[0].references(event.getEntity()))
labelEvents[1] = true;
}
}
public void entitiesUpdated(Set<LabelEvent> events) {
for (LabelEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
if (labelReference[0].references(event.getEntity()))
labelEvents[2] = true;
}
}
};
DynamicDAO.addEntityListener(ILabel.class, labelListener);
labelReference[0] = new LabelReference(DynamicDAO.save(label).getId());
/* Update */
label = labelReference[0].resolve();
label.setColor("255,255,128");
DynamicDAO.save(label);