PDA

View Full Version : Resize LayoutContainer after the child component collapsed



ishak1981
6 Dec 2010, 3:10 AM
Hello

i have a layoutcontainer with two layoutconatiner inside. In the second LayoutContainer i have a fieldset with to FormPanel inside. How can i resize the top layoutcontainer, if i collapse the fieldset.

isak

sven
6 Dec 2010, 3:10 AM
You need to add a Collapse event listener to the fieldset and do this manually. GXT layouts work from top to bottom, so the parent resizes the children.

ishak1981
6 Dec 2010, 3:19 AM
Hallo Sven,

i tried it, but i didn't know what i should do in the listener. i guess i should call a resize method for the top LayoutContainer like layout(). But i didn't work. i send the code. Thank you for your help.
public ContactEdit() {
setBorders(true);
setLayout(new RowLayout(Orientation.VERTICAL));


controller=new FileUploadController(this);


LayoutContainer lc1 = new LayoutContainer(new RowLayout(Orientation.HORIZONTAL));
RowLayout rowLayout = (RowLayout) lc1.getLayout();
rowLayout.setExtraStyle("test");


allgemeinPanel = new FormPanel();
allgemeinPanel.setTitleCollapse(true);
allgemeinPanel.setLabelWidth(80);
allgemeinPanel.setFieldWidth(60);
allgemeinPanel.setHeading("Allgemein");
allgemeinPanel.setIcon(Icon.ICONS.add24());
RowData rd_allgemeinPanel = new RowData(0.6,1);
rd_allgemeinPanel.setMargins(new Margins(5, 5, 5, 5));

TextField txtfldAnrede = new TextField();
allgemeinPanel.add(txtfldAnrede, new FormData("80%"));
txtfldAnrede.setFieldLabel("Anrede");

TextField txtfldName = new TextField();
allgemeinPanel.add(txtfldName, new FormData("65%"));
txtfldName.setFieldLabel("Name");

TextField txtfldVorname = new TextField();
allgemeinPanel.add(txtfldVorname, new FormData("65%"));
txtfldVorname.setFieldLabel("Vorname");

NumberField nmbrfldTelefon = new NumberField();
allgemeinPanel.add(nmbrfldTelefon, new FormData("65%"));
nmbrfldTelefon.setFieldLabel("Telefon");





NumberField nmbrfldFaxdiret = new NumberField();
allgemeinPanel.add(nmbrfldFaxdiret, new FormData("65%"));
nmbrfldFaxdiret.setFieldLabel("Fax-direkt");

TextField txtfldEmail = new TextField();
allgemeinPanel.add(txtfldEmail, new FormData("65%"));
txtfldEmail.setFieldLabel("E-Mail");

DateField dtfldGeburtstag = new DateField();
FormData fd_dtfldGeburtstag = new FormData("65%");
fd_dtfldGeburtstag.setMargins(new Margins(0, 0, 10, 0));
allgemeinPanel.add(dtfldGeburtstag, fd_dtfldGeburtstag);
dtfldGeburtstag.setFieldLabel("Geburtstag");

LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setHeight("100");
RowLayout rl_layoutContainer = new RowLayout(Orientation.HORIZONTAL);
rl_layoutContainer.setExtraStyle("padding:30px");
layoutContainer.setLayout(rl_layoutContainer);

LayoutContainer layoutContainer_1 = new LayoutContainer();
FormLayout fl_layoutContainer_1 = new FormLayout();
fl_layoutContainer_1.setLabelAlign(LabelAlign.TOP);
fl_layoutContainer_1.setLabelWidth(80);
layoutContainer_1.setLayout(fl_layoutContainer_1);
TextField txtfldOrganisation = new TextField();
layoutContainer_1.add(txtfldOrganisation, new FormData("80%"));
txtfldOrganisation.setLabelStyle("width:10px");
txtfldOrganisation.setFieldLabel("Organisation");

TextField txtfldAbteilung = new TextField();
layoutContainer_1.add(txtfldAbteilung, new FormData("100%"));
txtfldAbteilung.setFieldLabel("Abteilung");
layoutContainer.add(layoutContainer_1, new RowData(0.5, 1.0, new Margins(0, 10, 0, 0)));

LayoutContainer layoutContainer_2 = new LayoutContainer();
FormLayout fl_layoutContainer_2 = new FormLayout();
fl_layoutContainer_2.setLabelAlign(LabelAlign.TOP);
fl_layoutContainer_2.setLabelWidth(80);
layoutContainer_2.setLayout(fl_layoutContainer_2);



TextField txtfldJobTitle = new TextField();
layoutContainer_2.add(txtfldJobTitle, new FormData("80%"));
txtfldJobTitle.setFieldLabel("Job Title");

TextField txtfldJobRole = new TextField();
layoutContainer_2.add(txtfldJobRole, new FormData("100%"));
txtfldJobRole.setFieldLabel("Job Role");
layoutContainer.add(layoutContainer_2, new RowData(0.5, 1.0, new Margins()));
allgemeinPanel.add(layoutContainer, new FormData("100% "));
lc1.add(allgemeinPanel, rd_allgemeinPanel);

LayoutContainer lc1_1 = new LayoutContainer(new RowLayout(Orientation.VERTICAL));

thumbnail = new Image((String) null);
lc1_1.add(thumbnail, new RowData(260.0, 160.0, new Margins(5, 45, 5, 45)));
thumbnail.setSize("15", "100");

uploadForm = new FileUploadFormPanel();
uploadForm.setAction(GWT.getModuleBaseURL()+"fileUpload");
uploadForm.setEncoding(com.google.gwt.user.client.ui.FormPanel.ENCODING_MULTIPART);
uploadForm.setMethod(com.google.gwt.user.client.ui.FormPanel.METHOD_POST);
// Add an event handler to the form.
uploadForm.addSubmitHandler(new com.google.gwt.user.client.ui.FormPanel.SubmitHandler() {
public void onSubmit(com.google.gwt.user.client.ui.FormPanel.SubmitEvent event) {
// This event is fired just before the form is submitted. We can
// take this opportunity to perform validation.

}
});

uploadForm.addSubmitCompleteHandler(new com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler() {
public void onSubmitComplete(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent event) {
controller.uploadFertig(event.getResults());

}
});
upload=new UploadButton(controller,"ohneNamegehtesnicht");
uploadForm.add(upload);
upload.setWidth("273px");
lc1_1.add(uploadForm, new RowData(1.0, 25.0, new Margins(30, 0, 0, 0)));

deleteButton = new Button("L\u00F6schen");
deleteButton.setEnabled(false);
deleteButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
controller.fileEntfernen();
}
});
entferneBild();
lc1_1.add(deleteButton, new RowData(1.0, 45.0, new Margins(10, 0, 5, 0)));

RowData rd_lc1_1 = new RowData(0.4,290.0);
rd_lc1_1.setMargins(new Margins(5, 5, 5, 5));
lc1.add(lc1_1, rd_lc1_1);


final LayoutContainer lc2 = new LayoutContainer();
lc2.setLayout(new FitLayout());

final FieldSet fldstAddressBusiness = new FieldSet();


fldstAddressBusiness.setLayout(new RowLayout(Orientation.HORIZONTAL));

frmpnlBusiness = new FormPanel();
frmpnlBusiness.setHeading("Business");
frmpnlBusiness.setIcon(Icon.ICONS.postaladdress());
TextField txtfldStrae = new TextField();
frmpnlBusiness.add(txtfldStrae, new FormData("100%"));
txtfldStrae.setFieldLabel("Stra\u00DFe");

ComboBox cmbxLand = new ComboBox();
cmbxLand.setStore(new ListStore());
frmpnlBusiness.add(cmbxLand, new FormData("100%"));
cmbxLand.setFieldLabel("Land");

ComboBox cmbxPlz = new ComboBox();
cmbxPlz.setStore(new ListStore());
frmpnlBusiness.add(cmbxPlz, new FormData("100%"));
cmbxPlz.setFieldLabel("PLZ");

TextField txtfldOrt = new TextField();
frmpnlBusiness.add(txtfldOrt, new FormData("100%"));
txtfldOrt.setFieldLabel("Ort");

TextField txtfldBundesland = new TextField();
frmpnlBusiness.add(txtfldBundesland, new FormData("100%"));
txtfldBundesland.setFieldLabel("Bundesland");
fldstAddressBusiness.add(frmpnlBusiness, new RowData(0.5, 1.0, new Margins(0, 5, 0, 0)));

frmpnlHome = new FormPanel();
frmpnlHome.setIcon(Icon.ICONS.postaladdress());
frmpnlHome.setHeading("Home");
fldstAddressBusiness.add(frmpnlHome, new RowData(0.5, 1.0, new Margins()));

TextField txtfldStrasse = new TextField();
frmpnlHome.add(txtfldStrasse, new FormData("100%"));
txtfldStrasse.setFieldLabel("Strasse");

ComboBox cmbxLand_1 = new ComboBox();
cmbxLand_1.setStore(new ListStore());
frmpnlHome.add(cmbxLand_1, new FormData("100%"));
cmbxLand_1.setFieldLabel("Land");

ComboBox cmbxPlz_1 = new ComboBox();
cmbxPlz_1.setStore(new ListStore());
frmpnlHome.add(cmbxPlz_1, new FormData("100%"));
cmbxPlz_1.setFieldLabel("PLZ");

TextField txtfldOrt_1 = new TextField();
frmpnlHome.add(txtfldOrt_1, new FormData("100%"));
txtfldOrt_1.setFieldLabel("Ort");

TextField txtfldBundesland_1 = new TextField();
frmpnlHome.add(txtfldBundesland_1, new FormData("100%"));
txtfldBundesland_1.setFieldLabel("Bundesland");
lc2.add(fldstAddressBusiness, new FitData(0, 5, 0, 5));
fldstAddressBusiness.setHeading("Address Business / Home");
fldstAddressBusiness.setCollapsible(true);


fldstAddressBusiness.addListener(Events.Collapse, new Listener<ComponentEvent>() {
public void handleEvent(ComponentEvent e) {
recalculate();

}
});




add(lc1, new RowData(1,0.6));

add(lc2, new RowData(1,1.0));


}