formpanel already added to contentpanel but not showing
formpanel already added to contentpanel but not showing
formpanel already added to contentpanel but not showing. But buttons in the contentpanel are showing. Is there a force redrawing / recalculating of the contentpanel?
formpanel already added to contentpanel but not showing
formpanel already added to contentpanel but not showing
Hi,
Include 3 main player classes here - SynopWeb,CodedSynopPanel and SynopForm. SynopWeb implements entrypoint, here codedsynopanel and synopform is added to viewport, which is then added to the rootpanel. Upon launching, codedsynoppanel will be displayed first, when the decode button in the codedsynoppanel is pressed, the synopform (a contentpanel) appears, but only the added buttons are displayed, the formpanel does not show.
I need help, please help me, thank you.
//========= Class SynopWeb implementing Entrypoint ==================
public class CodedSynopPanel extends ContentPanel implements HasHandlers {
private SimpleEventBus eventBus;
FormPanel fp1;
public CodedSynopPanel (String initSynop) {
createSynopPanel (initSynop);
eventBus = new SimpleEventBus();
}
public void createSynopPanel (String initSynop) {
setHeading ("Coded Synop");
setLayout (new CenterLayout());
fp1 = new FormPanel ();
setScrollMode(Scroll.AUTO);
fp1.setHeaderVisible(false);
fp1.setBodyBorder(false);
fp1.setSize(1000,500);
fp1.setLabelAlign(LabelAlign.TOP);
fp1.setButtonAlign(Style.HorizontalAlignment.RIGHT);
add (fp1);
final TextArea codedSynop = new TextArea();
codedSynop.setFieldLabel("Coded Synop");
codedSynop.setValue(initSynop);
codedSynop.setAllowBlank(false);
fp1.add (codedSynop, new FormData (800,70));
final Button decodeButton = new Button ("Decode");
decodeButton.addSelectionListener(
new SelectionListener<ButtonEvent> () {
public void componentSelected(ButtonEvent ce) {
if (fp1.isValid()) {
Window.alert("decode pressed");
SynopFormEvent ev = new SynopFormEvent (codedSynop.getValue());
fireEvent (ev);
};
}});
fp1.add (decodeButton);
final TextArea encodedSynop = new TextArea();
encodedSynop.setFieldLabel("Encoded Synop Result");
fp1.add (encodedSynop, new FormData (800,70));
}
public void fireEvent(GwtEvent<?> event) {
eventBus.fireEvent(event);
}
public HandlerRegistration addSynopFormEventHandler(
SynopFormEventHandler handler) {
return eventBus.addHandler(SynopFormEvent.TYPE, handler);
}
final Button cancelButton = new Button ("Cancel");
getButtonBar().add (cancelButton);
final Button previewButton = new Button ("Show Preview");
getButtonBar().add (previewButton);
previewButton.addSelectionListener(
new SelectionListener<ButtonEvent> () {
public void componentSelected(ButtonEvent ce) {
//Info.display("Valid state", fp.isValid() ? "is valid" : "is not valid");
if (preview.isVisible()) {
preview.setVisible (false);
previewButton.setText ("Show Preview");
} else {
if (fp.isValid()) {
// create and encode a Synop
Synop synop = new Synop (getFields());
String codedSynop = synop.encode ();
preview.setVisible (true);
preview.removeAll();
preview.addText(codedSynop);
preview.layout();
previewButton.setText ("Hide Preview");
} else {
Info.display("Validity State", "is not valid");
}
}
}
});
final Button saveButton = new Button ("Save");
getButtonBar().add (saveButton);
saveButton.addSelectionListener(
new SelectionListener<ButtonEvent> () {
public void componentSelected(ButtonEvent ce) {
if (fp.isValid()) {
// Save the encoded Synop
Synop synop = new Synop (getFields());
SaveSynopEvent ev = new SaveSynopEvent (synop.encode ());
fireEvent (ev);
} else {
Info.display("Validity State", "is not valid");
}
}
});
cancelButton.addSelectionListener(
new SelectionListener<ButtonEvent> () {
public void componentSelected(ButtonEvent ce) {
CancelEvent ev = new CancelEvent ();
fireEvent (ev);
}
});
fp.layout();
}
public void fireEvent(GwtEvent<?> event) {
eventBus.fireEvent(event);
}
public HandlerRegistration addSaveSynopEventHandler(SaveSynopEventHandler handler) {
return eventBus.addHandler(SaveSynopEvent.TYPE, handler);
}
public HandlerRegistration addCancelEventHandler(CancelEventHandler handler) {
return eventBus.addHandler(CancelEvent.TYPE, handler);
}
section0Layout = new LayoutContainer ();
TableLayout tableLayout = new TableLayout (6);
tableLayout.setWidth ("100%");
tableLayout.setCellPadding(8);
TableData tableData = new TableData();
tableData.setWidth("16%");
tableData.setHeight("50");
tableData.setVerticalAlign(VerticalAlignment.BOTTOM);
TableData tableData2 = new TableData();
tableData2.setWidth("16%");
tableData2.setHeight("50");
tableData2.setVerticalAlign(VerticalAlignment.BOTTOM);
tableData2.setColspan(2);
section0Layout.setLayout (tableLayout);
section0Layout.setBorders(true); // temporary so we can see it
// Report ID
reportIdList = new LabelValueListBox();
reportIdList.addItem("FM 12 - Fixed Land Station", "AAXX");
reportIdList.addItem("FM 13 - Sea Station", "BBXX");
reportIdList.addItem("FM 14 - Mobile Land Station", "OOXX");
reportIdList.selectValue(synopFields.get("Section0Group0MiMiMjMj"));
reportIdList.setFieldLabel ("Report ID");
reportIdList.setAllowBlank(false);
section0Layout.add(addField ("Section0Group0MiMiMjMj", reportIdList, new FormData (100, 22)), tableData);
// Group D....D
// D....D - Ship's call sign consisting of three or more alphanumeric characters
CallSign = new TextField<String>();
CallSign.setFieldLabel("Ship's Call Sign");
CallSign.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String errMsg = null;
if (! value.matches("^[a-zA-Z0-9]+$")) {
errMsg = "Must be alphanumeric";
}
return errMsg;
}
});
section0Layout.add(addField ("Section0Group1D_D", CallSign, new FormData (100,22)), tableData);
// A1 - WMO Regional Association area in which buoy, drilling rig or oil-
// or gas production platform has been deployed
// bw - Sub-area belonging to the area indicated by A1
WMORAList = new LabelValueListBox();
WMORAList.addItem(" ", "");
WMORAList.addItem("11 - Region I", "11");
WMORAList.addItem("12 - Region I", "12");
WMORAList.addItem("13 - Region I", "13");
WMORAList.addItem("14 - Region I", "14");
WMORAList.addItem("71 - Region VII", "71");
WMORAList.addItem("72 - Region VII", "72");
WMORAList.addItem("73 - Region VII", "73");
WMORAList.addItem("74 - Region VII", "74");
WMORAList.setFieldLabel ("WMO Regional Association Area and Sub Area");
WMORAList.setMinListWidth(120);
WMORAList.selectValue(synopFields.get("Section0Group1A1bw"));
WMORAList.setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String errMsg = null;
if (reportIdList.getValue().getValuePart().matches("BBXX") || reportIdList.getValue().getValuePart().matches("OOXX")) {
if (value.matches(" ") && fields.get("Section0Group1A1bw").isEnabled() == true) {
errMsg = "This field is required";
} else {
errMsg = null;
}
}
return errMsg;
}
});
section0Layout.add(addField ("Section0Group1A1bw", WMORAList, new FormData (100, 22)), tableData);
fieldset.add (section0Layout);
return fieldset;
}
private LayoutContainer addField (String fieldTag, final Field<?> field, final FormData d) {
// Create a layoutContainer set to FormLayout. Without this, field labels
// will not appear.
LayoutContainer ret = new LayoutContainer ();
FormLayout f = new FormLayout ();
f.setLabelAlign(LabelAlign.TOP);
ret.setLayout (f);
ret.add (field, d);
// keep a reference to the field so that we can call it up from anywhere
// later.
fields.put (fieldTag, field);