}
}
}));
}
TabPanel tPanel = new TabPanel();
DirtyableFlexTable codeTable = new DirtyableFlexTable();
int codeTableRow = 0;
int codeTableCol = 0;
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='x-form-field'>Init:</div>"));
final TextBox initField = new TextBox();
initField.setTitle("init code");
initField.setText(getFromAccumulatePattern().getInitCode());
codeTable.setWidget(codeTableRow++, codeTableCol--, initField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='x-form-field'>Action:</div>"));
final TextBox actionField = new TextBox();
actionField.setTitle("action code");
actionField.setText(getFromAccumulatePattern().getActionCode());
codeTable.setWidget(codeTableRow++, codeTableCol--, actionField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='x-form-field'>Reverse:</div>"));
final TextBox reverseField = new TextBox();
reverseField.setTitle("reverse code.");
reverseField.setText(getFromAccumulatePattern().getReverseCode());
codeTable.setWidget(codeTableRow++, codeTableCol--, reverseField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='x-form-field'>Result:</div>"));
final TextBox resultField = new TextBox();
resultField.setTitle("result code");
resultField.setText(getFromAccumulatePattern().getResultCode());
codeTable.setWidget(codeTableRow++, codeTableCol--, resultField);
//panel.setWidget(r++, 0, codeTable);
Panel codePanel = new Panel();
codePanel.setAutoWidth(true);
codePanel.setClosable(false);
codePanel.setTitle("Custom Code");
codePanel.setAutoHeight(true);
codePanel.add(codeTable);
codePanel.setDisabled(this.readOnly);
tPanel.add(codePanel);
DirtyableFlexTable functionTable = new DirtyableFlexTable();
functionTable.setWidget(0, 0, new HTML("<div class='x-form-field'>Function:</div>"));
final TextBox functionField = new TextBox();
functionField.setTitle("function code");
functionField.setText(getFromAccumulatePattern().getFunction());
functionTable.setWidget(0, 1, functionField);
// panel.setWidget(r++, 0, functionTable);
Panel functionPanel = new Panel();
functionPanel.setAutoWidth(true);
functionPanel.setClosable(false);
functionPanel.setTitle("Function");
functionPanel.setAutoHeight(true);
functionPanel.add(functionTable);
functionPanel.setDisabled(this.readOnly);
tPanel.add(functionPanel);
ChangeListener changeListener = new ChangeListener() {
public void onChange(Widget sender) {
TextBox senderTB = (TextBox) sender;
String code = senderTB.getText();
setModified(true);
if (sender == initField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setInitCode(code);
} else if (sender == actionField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setActionCode(code);
} else if (sender == reverseField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setReverseCode(code);
} else if (sender == resultField) {
getFromAccumulatePattern().setFunction(null);
functionField.setText("");
getFromAccumulatePattern().setResultCode(code);
} else if (sender == functionField) {
getFromAccumulatePattern().clearCodeFields();
initField.setText("");
actionField.setText("");
reverseField.setText("");
resultField.setText("");
getFromAccumulatePattern().setFunction(code);
}
}
};
initField.addChangeListener(changeListener);
actionField.addChangeListener(changeListener);
reverseField.addChangeListener(changeListener);
resultField.addChangeListener(changeListener);
functionField.addChangeListener(changeListener);
boolean useFunction = getFromAccumulatePattern().useFunctionOrCode().equals(FromAccumulateCompositeFactPattern.USE_FUNCTION);
tPanel.setActiveTab(useFunction?1:0);
tPanel.setBorder(false);
tPanel.setBodyBorder(false);
tPanel.setWidth(200);
tPanel.setDisabled(this.readOnly);
// functionTable.setVisible(useFunction);
// codeTable.setVisible(!useFunction);
panel.setWidget(r++, 0, tPanel);