}));
}
//REVISIT: Nested TabLayoutPanel does not work, its content is truncated.
//TabLayoutPanel tPanel = new TabLayoutPanel(2, Unit.EM);
TabPanel tPanel = new TabPanel();
DirtyableFlexTable codeTable = new DirtyableFlexTable();
int codeTableRow = 0;
int codeTableCol = 0;
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>Init:</div>"));
final TextBox initField = new TextBox();
initField.setTitle("init code");
initField.setText(getFromAccumulatePattern().getInitCode());
initField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, initField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>Action:</div>"));
final TextBox actionField = new TextBox();
actionField.setTitle("action code");
actionField.setText(getFromAccumulatePattern().getActionCode());
actionField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, actionField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>Reverse:</div>"));
final TextBox reverseField = new TextBox();
reverseField.setTitle("reverse code.");
reverseField.setText(getFromAccumulatePattern().getReverseCode());
reverseField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, reverseField);
codeTable.setWidget(codeTableRow, codeTableCol++, new HTML("<div class='form-field'>Result:</div>"));
final TextBox resultField = new TextBox();
resultField.setTitle("result code");
resultField.setText(getFromAccumulatePattern().getResultCode());
resultField.setEnabled(!this.readOnly);
codeTable.setWidget(codeTableRow++, codeTableCol--, resultField);
//panel.setWidget(r++, 0, codeTable);
ScrollPanel codePanel = new ScrollPanel();
codePanel.add(codeTable);
tPanel.add(codePanel,"Custom Code");
DirtyableFlexTable functionTable = new DirtyableFlexTable();
functionTable.setWidget(0, 0, new HTML("<div class='form-field'>Function:</div>"));
final TextBox functionField = new TextBox();
functionField.setTitle("function code");
functionField.setText(getFromAccumulatePattern().getFunction());
functionField.setEnabled(!this.readOnly);
functionTable.setWidget(0, 1, functionField);
// panel.setWidget(r++, 0, functionTable);
ScrollPanel functionPanel = new ScrollPanel();
functionPanel.add(functionTable);
tPanel.add(functionPanel,"Function");
ChangeHandler changehandler = new ChangeHandler() {
public void onChange(ChangeEvent event) {
Widget sender = (Widget)event.getSource();
TextBox senderTB = (TextBox) event.getSource();
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.addChangeHandler(changehandler);
actionField.addChangeHandler(changehandler);
reverseField.addChangeHandler(changehandler);
resultField.addChangeHandler(changehandler);
functionField.addChangeHandler(changehandler);
boolean useFunction = getFromAccumulatePattern().useFunctionOrCode().equals(FromAccumulateCompositeFactPattern.USE_FUNCTION);
tPanel.selectTab(useFunction?1:0);
panel.setWidget(r++, 0, tPanel);
return panel;
}