IStructuredSelection selection =
(IStructuredSelection) combo.getSelection();
String policyName = (String) selection.getFirstElement();
PolicyDescriptor descriptor = (PolicyDescriptor)
namesToDescriptors.get(policyName);
SelectionPolicyType policyType =
(SelectionPolicyType) descriptor.getPolicyType();
context.setCategoryValues(policyType.getKeywords());
BeanProxy model = (BeanProxy) context.getInteractionModel();
Proxy categorisationScheme = model.getPropertyProxy(
PolicyModel.CATEGORISATION_SCHEME);
if (!ObjectHelper.equals(policyName,
categorisationScheme.getModelObject())) {
Operation setSchemeOp = categorisationScheme
.prepareSetModelObjectOperation(policyName);
context.executeOperation(setSchemeOp);
}
}
});
BeanProxy model = (BeanProxy) context.getInteractionModel();
final Proxy categorisationScheme =
model.getPropertyProxy(PolicyModel.CATEGORISATION_SCHEME);
String selectedPolicy = (String) categorisationScheme.getModelObject();
if (selectedPolicy != null) {
combo.setSelection(new StructuredSelection(selectedPolicy));
PolicyDescriptor descriptor = (PolicyDescriptor)
namesToDescriptors.get(selectedPolicy);
SelectionPolicyType policyType =
(SelectionPolicyType) descriptor.getPolicyType();
context.setCategoryValues(policyType.getKeywords());
}
categorisationScheme.addListener(new InteractionEventListenerAdapter() {
protected void interactionEvent(InteractionEvent event) {
String selectedPolicy =
(String) categorisationScheme.getModelObject();
if (selectedPolicy != null) {
combo.setSelection(new StructuredSelection(selectedPolicy));
PolicyDescriptor descriptor = (PolicyDescriptor)
namesToDescriptors.get(selectedPolicy);
SelectionPolicyType policyType =
(SelectionPolicyType) descriptor.getPolicyType();
context.setCategoryValues(policyType.getKeywords());
}
}
}, false);
}