if (sce == null) {
sce = SuggestionCompletionCache.getInstance().getEngineFromCache(asset.getMetaData().getModuleName());
sceModelFields = sce.getModelFields();
}
final ScorecardModel scorecardModel = (ScorecardModel) asset.getContent();
scorecardPropertiesGrid = new Grid(4, 4);
scorecardPropertiesGrid.setCellSpacing(5);
scorecardPropertiesGrid.setCellPadding(5);
tbInitialScore = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);
tbInitialScore.setText(Double.toString(scorecardModel.getInitialScore()));
String factName = scorecardModel.getFactName();
if (factName.lastIndexOf(".") > -1){
// if fact is a fully qualified className, strip off the packageName
factName = factName.substring(factName.lastIndexOf(".")+1);
}
final EnumDropDown dropDownFields = new EnumDropDown("",
new DropDownValueChanged() {
public void valueChanged(String newText,
String newValue) {
//do nothing
}
}, DropDownData.create(new String[]{}));
EnumDropDown dropDownFacts = new EnumDropDown(factName,
new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
String selectedField = scorecardModel.getFieldName();
selectedField = selectedField+" : double";
dropDownFields.setDropDownData(selectedField, DropDownData.create(getEligibleFields(newValue, typesForScore)));
}
}, DropDownData.create(sce.getFactTypes()));
ddReasonCodeField = new EnumDropDown("",
new DropDownValueChanged() {
public void valueChanged(String newText,
String newValue) {
//do nothing
}
}, DropDownData.create(new String[]{}));
String rcField = scorecardModel.getReasonCodeField() +" : List";
ddReasonCodeField.setDropDownData(rcField,DropDownData.create(getEligibleFields(factName,typesForRC)));
boolean useReasonCodes = scorecardModel.isUseReasonCodes();
String reasonCodesAlgo = scorecardModel.getReasonCodesAlgorithm();
if (reasonCodesAlgo == null || reasonCodesAlgo.trim().length() == 0) {
reasonCodesAlgo = "none";
}
ddUseReasonCode = booleanEditor(Boolean.toString(useReasonCodes));
ddReasonCodeAlgo = dropDownEditor(DropDownData.create(REASON_CODE_ALGORITHMS), reasonCodesAlgo);
tbBaselineScore = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);
scorecardPropertiesGrid.setText(0, 0, "Facts");
scorecardPropertiesGrid.setText(0, 1, "Resultant Score Field");
scorecardPropertiesGrid.setText(0, 2, "Initial Score");
scorecardPropertiesGrid.setWidget(1, 0, dropDownFacts);
scorecardPropertiesGrid.setWidget(1, 1, dropDownFields);
scorecardPropertiesGrid.setWidget(1, 2, tbInitialScore);
scorecardPropertiesGrid.setText(2, 0, "Use Reason Codes");
scorecardPropertiesGrid.setText(2, 1, "Resultant Reason Codes Field");
scorecardPropertiesGrid.setText(2, 2, "Reason Codes Algorithm");
scorecardPropertiesGrid.setText(2, 3, "Baseline Score");
scorecardPropertiesGrid.setWidget(3, 0, ddUseReasonCode);
scorecardPropertiesGrid.setWidget(3, 1, ddReasonCodeField);
scorecardPropertiesGrid.setWidget(3, 2, ddReasonCodeAlgo);
scorecardPropertiesGrid.setWidget(3, 3, tbBaselineScore);
/* TODO : Remove this explicitly Disabled Reasoncode support field*/
ddUseReasonCode.setEnabled(false);
tbBaselineScore.setText(Double.toString(scorecardModel.getBaselineScore()));
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 0, "200px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 1, "250px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 2, "200px");
scorecardPropertiesGrid.getCellFormatter().setWidth(0, 3, "200px");
int index = Arrays.asList(sce.getFactTypes()).indexOf(factName);
dropDownFacts.setSelectedIndex(index);
dropDownFields.setDropDownData(scorecardModel.getFieldName()+" : double", DropDownData.create(getEligibleFields(factName, typesForScore)));
return scorecardPropertiesGrid;
}