}
}
}
private DirtyableFlexTable addCharacteristic(final Characteristic characteristic) {
final DirtyableFlexTable cGrid = new DirtyableFlexTable();
cGrid.setBorderWidth(0);
cGrid.setCellPadding(1);
cGrid.setCellSpacing(1);
cGrid.setStyleName("rule-ListHeader");
Button btnAddAttribute = new Button("Add Attribute", new ClickHandler() {
public void onClick(ClickEvent event) {
addAttribute(cGrid, null);
}
});
Button btnRemoveCharacteristic = new Button("Remove Characteristic", new ClickHandler() {
public void onClick(ClickEvent event) {
removeCharacteristic(cGrid);
}
});
String selectedFact = "";
if (characteristic != null) {
selectedFact = characteristic.getFact();
if (selectedFact.lastIndexOf(".") > -1) {
selectedFact = selectedFact.substring(selectedFact.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(selectedFact,
new DropDownValueChanged() {
public void valueChanged(String newText, String newValue) {
String selectedField = "";
if (characteristic != null) {
selectedField = characteristic.getField();
selectedField = selectedField+" : "+characteristic.getDataType();
}
dropDownFields.setDropDownData(selectedField, DropDownData.create(getEligibleFields(newValue, typesForAttributes)));
//dropDownFields.setSelectedIndex(0);
}
}, DropDownData.create(sce.getFactTypes()));
DropDownData dropDownData = DropDownData.create(getEligibleFields(selectedFact, typesForAttributes));
dropDownFields.setDropDownData("", dropDownData);
cGrid.setWidget(0, 0, new Label("Name"));
final TextBox tbName = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_STRING);
cGrid.setWidget(0, 1, tbName);
cGrid.setWidget(0, 2, btnRemoveCharacteristic);
cGrid.setWidget(0, 3, btnAddAttribute);
cGrid.setWidget(1, 0, new Label("Fact"));
cGrid.setWidget(1, 1, new Label("Characteristic"));
cGrid.setWidget(1, 2, new Label("Baseline Score"));
cGrid.setWidget(1, 3, new Label("Reason Code"));
cGrid.setWidget(2, 0, dropDownFacts);
cGrid.setWidget(2, 1, dropDownFields);
TextBox tbBaseline = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);
boolean useReasonCodesValue = "true".equalsIgnoreCase(ddUseReasonCode.getValue(ddUseReasonCode.getSelectedIndex()));
tbBaseline.setEnabled(useReasonCodesValue);
cGrid.setWidget(2, 2, tbBaseline);
TextBox tbReasonCode = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_STRING);
tbReasonCode.setEnabled(useReasonCodesValue);
cGrid.setWidget(2, 3, tbReasonCode);
SimplePanel gapPanel = new SimplePanel();
gapPanel.add(new HTML("<br/>"));
VerticalPanel panel = new VerticalPanel();
panel.add(cGrid);
panel.add(addAttributeCellTable(cGrid, characteristic));
panel.setWidth("100%");
DecoratorPanel decoratorPanel = new DecoratorPanel();
decoratorPanel.add(panel);
characteristicsPanel.add(decoratorPanel);
characteristicsPanel.add(gapPanel);
characteristicsTables.add(cGrid);
cGrid.getColumnFormatter().setWidth(0, "150px");
cGrid.getColumnFormatter().setWidth(1, "250px");
cGrid.getColumnFormatter().setWidth(2, "150px");
cGrid.getColumnFormatter().setWidth(3, "150px");
if (characteristic != null) {
tbReasonCode.setValue(characteristic.getReasonCode());
tbBaseline.setValue("" + characteristic.getBaselineScore());