radioGroupItem.setAlign(Alignment.LEFT);
radioGroupItem.setValueMap(radioGroupValues);
radioGroupItem.setValue(CREATE_TEMPLATE);
wizard.setCreateTemplate(true);
radioGroupItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
if (SELECT_TEMPLATE.equals(event.getValue()) && null == selectTemplateItem.getValue()) {
SC.say(MSG.view_drift_wizard_pinTemplate_infoStepSelectBlocked());
event.getItem().setValue(CREATE_TEMPLATE);
return;
}
wizard.setCreateTemplate(CREATE_TEMPLATE.equals(event.getValue()));
if (wizard.isCreateTemplate()) {
selectTemplateForm.hide();
wizard.getView().getNextButton().setTitle(MSG.common_button_next());
} else {
selectTemplateForm.show();
wizard.getView().getNextButton().setTitle(MSG.common_button_finish());
}
radioForm.markForRedraw();
}
});
formItems.add(radioGroupItem);
formItems.add(new SpacerItem());
radioForm.setItems(formItems.toArray(new FormItem[formItems.size()]));
canvas.addMember(radioForm);
selectTemplateForm = new DynamicForm();
selectTemplateForm.setNumCols(1);
selectTemplateForm.setIsGroup(true);
selectTemplateForm.setGroupTitle(MSG.view_drift_wizard_pinTemplate_infoStepSelectTitle());
selectTemplateForm.setPadding(10);
selectTemplateForm.hide();
formItems.clear();
StaticTextItem selectTemplateDescriptionItem = new StaticTextItem("Description",
MSG.common_title_description());
selectTemplateDescriptionItem.setTitleOrientation(TitleOrientation.TOP);
selectTemplateDescriptionItem.setAlign(Alignment.LEFT);
selectTemplateDescriptionItem.setWidth(300);
formItems.add(selectTemplateDescriptionItem);
SpacerItem spacerItem = new SpacerItem();
spacerItem.setHeight(10);
formItems.add(spacerItem);
selectTemplateItem.setTitleOrientation(TitleOrientation.TOP);
selectTemplateItem.setAlign(Alignment.LEFT);
selectTemplateItem.setWidth(300);
selectTemplateItem.setRequired(true);
FormUtility.addContextualHelp(selectTemplateItem, MSG.view_drift_wizard_pinTemplate_infoStepHelp());
Set<DriftDefinitionTemplate> templates = wizard.getResourceType().getDriftDefinitionTemplates();
if (null == templates || templates.isEmpty()) {
// there should be at least one template for any resource type that supports drift monitoring
throw new IllegalStateException(
"At least one drift definition template should exist for the resource type");
}
// Only use templates that have the same base dir and filters as the definition from which
// this snapshot is coming. Otherwise the file set does not map.
final HashMap<String, DriftDefinitionTemplate> templatesMap = new HashMap<String, DriftDefinitionTemplate>(
templates.size());
DriftDefinitionComparator ddc = new DriftDefinitionComparator(CompareMode.ONLY_DIRECTORY_SPECIFICATIONS);
for (DriftDefinitionTemplate template : templates) {
if (0 == ddc.compare(template.getTemplateDefinition(), wizard.getSnapshotDriftDef())) {
templatesMap.put(template.getName(), template);
}
}
Set<String> templatesMapKeySet = templatesMap.keySet();
String[] templatesMapKeySetArray = templatesMapKeySet.toArray(new String[templatesMap.size()]);
selectTemplateItem.setValueMap(templatesMapKeySetArray);
selectTemplateItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
if (null == event || "".equals(event.getValue())) {
return;
}