for (final Capability capability : capabilities) {
// If we're interested in this capability (it matches our current filter).
if (capability.getComponentId() == component.getComponentId()
&& capability.getAttributeId() == attribute.getAttributeId()) {
// Create and populate a capability widget for this capability.
final EditCapabilityWidget widget = new EditCapabilityWidget(capability);
widget.addValueChangeHandler(new ValueChangeHandler<Capability>() {
@Override
public void onValueChange(ValueChangeEvent<Capability> event) {
if (event.getValue() == null) {
// Since the value is null, we'll just use the old value to grab the ID.
removeCapability(capability);
} else {
updateCapability(event.getValue());
widget.showSaved();
}
}
});
widget.setComponents(components);
widget.setAttributes(attributes);
widget.setLabelSuggestions(projectLabels);
if (isEditable) {
widget.makeEditable();
}
widgets.add(widget);
}
}