if (dram == null) {
throw new IllegalArgumentException("Cannot be null: " +
"dram.");
}
ListPolicyValueModifier listPVM = null;
// Retrieve the policy type element.
Element policyTypeElement =
dram.getTypeDefinitionElement(policyName);
if (policyTypeElement != null) {
if (!policyTypeElement.getName().
equals(DeviceRepositorySchemaConstants.
POLICY_DEFINITION_TYPE_ELEMENT_NAME)) {
throw new IllegalStateException("The policy type " +
"element for " + policyName + " is " +
"named " + policyTypeElement.getName() +
". Expected " + DeviceRepositorySchemaConstants.
POLICY_DEFINITION_TYPE_ELEMENT_NAME);
}
SelectionDialog dialog = null;
Element unorderedSetElement = policyTypeElement.getChild(
DeviceRepositorySchemaConstants.
POLICY_DEFINITION_UNORDEREDSET_ELEMENT_NAME,
policyTypeElement.getNamespace());
// Retrieve the selection element for the named policy.
Element selectionElement = unorderedSetElement.getChild(
DeviceRepositorySchemaConstants.
POLICY_DEFINITION_SELECTION_ELEMENT_NAME,
unorderedSetElement.getNamespace());
if (selectionElement != null) {
// There are values to select so create the
// selection dialog with the selection element
// for the named policy.
dialog = new PolicyValueSelectionDialog(
parent.getShell(),
policyName,
selectionElement);
}
// Create the ListValueBuilder for unordered lists
// with the selection dialog, if any.
ListValueBuilder listVB =
new ListValueBuilder(parent,
false, dialog);
listPVM = new ListPolicyValueModifier(listVB, policyName, dram);
} else {
throw new IllegalStateException("The policy type " +
" element for " +
policyName + " is null.");
}