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 labelAdded(Set<LabelEvent> events) {
for (LabelEvent event : events) {
assertTrue("Expected this Event to be Root Event", event.isRoot());
labelEvents[0] = true;
}
}
public void labelDeleted(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 labelUpdated(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;
}
}
};
fModel.addLabelListener(labelListener);
labelReference[0] = new LabelReference(fDao.saveLabel(label).getId());
/* Update */
label = labelReference[0].resolve();
label.setColor("255,255,128");
fDao.saveLabel(label);