labelFileUploadDone.setVisible(false);
Button submitButton = new Button(c.Upload());
submitButton.setVisible(false);
final FileUpload fileUpload = new FileUpload();
fileUpload.setName(Settings.FORM_PARM_UPLOAD_FILE_BASE);
// The GWT calls this formPanel handler after the formPanel is submitted.
FormHandlerFile fileFormHandler = new FormHandlerFile(icing);
fileFormHandler.setFileUpload(fileUpload);
fileFormHandler.setLabelFileUploadDone(labelFileUploadDone);
fileFormHandler.setStatusMessage(statusMessage);
fileFormHandler.setSubmitButton(submitButton);
fileFormHandler.setNextButton(nextButton);
/** Invisible parameters to pass */
final iCingQuery cingQuerySave = new iCingQuery(icing);
cingQuerySave.action.setValue(Settings.FORM_ACTION_SAVE);
cingQuerySave.setFormHandler(fileFormHandler); // Override the default one.
cingQuerySave.formVerticalPanel.add(fileUpload); // will switch between these two.
cingQuerySave.formVerticalPanel.add(labelFileUploadDone);
flexTable.setWidget(currentRowIdx, fileIdx, cingQuerySave.formPanel);
flexTable.setWidget(currentRowIdx, submitIdx, submitButton);
final ListBox listBox_Program = new ListBox();
final ListBox listBox_Type = new ListBox();
final ListBox listBox_Subtype = new ListBox();
final ListBox listBox_Other = new ListBox();
final HTML egHtml = new HTML();
fileFormHandler.setListBox_Program(listBox_Program);
fileFormHandler.setListBox_Type(listBox_Type);
fileFormHandler.setListBox_Subtype(listBox_Subtype);
fileFormHandler.setListBox_Other(listBox_Other);
fileFormHandler.setEgHtml(egHtml);
/** Setup the 4 boxes */
flexTable.setWidget(currentRowIdx, programIdx, listBox_Program);
listBox_Program.setVisibleItemCount(1);
ArrayList<String> programList = Classification.getProgramList();
if (programList == null) { // impossible but modeled for consistency with below boxes.
listBox_Program.addItem(iCing.STRING_NA);
} else {
for (String item : programList) {
listBox_Program.addItem(item);
}
}
listBox_Program.setItemSelected(0, true);
if (listBox_Program.getItemCount() == 1) {
listBox_Program.setEnabled(false);
}
listBox_Program.setFocus(true);
flexTable.setWidget(currentRowIdx, typeIdx, listBox_Type);
listBox_Type.setVisibleItemCount(1);
String program = listBox_Program.getValue(listBox_Program.getSelectedIndex());
ArrayList<String> typeList = Classification.getTypeList(program);
if (typeList == null) { // impossible but modeled for consistency with below boxes.
listBox_Type.addItem(iCing.STRING_NA);
} else {
for (String item : typeList) {
listBox_Type.addItem(item);
}
}
listBox_Type.setItemSelected(0, true);
if (listBox_Type.getItemCount() == 1) {
listBox_Type.setEnabled(false);
}
flexTable.setWidget(currentRowIdx, subTypeIdx, listBox_Subtype);
listBox_Subtype.setVisibleItemCount(1);
String type = listBox_Type.getValue(listBox_Type.getSelectedIndex());
ArrayList<String> subTypeList = Classification.getSubTypeList(program, type);
if (subTypeList == null || subTypeList.size() == 0) {
listBox_Subtype.addItem(iCing.STRING_NA);
} else {
for (String item : subTypeList) {
if (item == null) {
item = iCing.STRING_NA;
}
listBox_Subtype.addItem(item);
}
}
listBox_Subtype.setItemSelected(0, true);
if (listBox_Subtype.getItemCount() == 1) {
listBox_Subtype.setEnabled(false);
}
flexTable.setWidget(currentRowIdx, otherIdx, listBox_Other);
listBox_Other.setVisibleItemCount(1);
String subType = listBox_Subtype.getValue(listBox_Subtype.getSelectedIndex());
ArrayList<String> otherList = Classification.getOtherList(program, type, subType);
if (otherList == null || otherList.size() == 0) {
listBox_Other.addItem(iCing.STRING_NA);
} else {
for (String item : otherList) {
if (item == null) {
item = iCing.STRING_NA;
}
listBox_Other.addItem(item);
}
}
listBox_Other.setItemSelected(0, true);
if (listBox_Other.getItemCount() == 1) {
listBox_Other.setEnabled(false);
}
// setup timer to refresh list automatically
Timer timer = new Timer() {
public void run() {
if (fileUpload.getFilename().length() == 0) {
return;
}
this.cancel();
cingQuerySave.formPanel.submit();
}