public Widget asWidget() { if (widget == null) { northData.setMargins(new Margins(5)); westData.setMargins(new Margins(0, 5, 0, 5)); westData.setCollapsible(true); westData.setSplit(true); eastData.setMargins(new Margins(0, 5, 0, 5)); southData.setMargins(new Margins(5)); widget = uiBinder.createAndBindUi(this); for (int i = 0; i < LayoutRegion.values().length; i++) { final LayoutRegion r = LayoutRegion.values()[i]; if (r == LayoutRegion.CENTER) { continue; } SelectHandler handler = new SelectHandler() { @Override public void onSelect(SelectEvent event) { TextButton btn = (TextButton) event.getSource(); String txt = btn.getText(); if (txt.equals("Expand")) { con.expand(r); } else if (txt.equals("Collapse")) { con.collapse(r); } else if (txt.equals("Show")) { con.show(r); } else { con.hide(r); } } }; table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>"); table.setWidget(i, 1, new TextButton("Expand", handler)); table.setWidget(i, 2, new TextButton("Collapse", handler)); table.setWidget(i, 3, new TextButton("Show", handler)); table.setWidget(i, 4, new TextButton("Hide", handler)); } } return widget; }
@UiFactory public FlexTable createFlexTable() { FlexTable table = new FlexTable(); table.getElement().getStyle().setProperty("margin", "10px"); table.setCellSpacing(8); table.setCellPadding(4); for (int i = 0; i < LayoutRegion.values().length; i++) { final LayoutRegion r = LayoutRegion.values()[i]; if (r == LayoutRegion.CENTER) { continue; } SelectHandler handler = new SelectHandler() { @Override public void onSelect(SelectEvent event) { TextButton btn = (TextButton) event.getSource(); String txt = btn.getText(); if (txt.equals("Expand")) { con.expand(r); } else if (txt.equals("Collapse")) { con.collapse(r); } else if (txt.equals("Show")) { con.show(r); } else { con.hide(r); } } }; table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>"); table.setWidget(i, 1, new TextButton("Expand", handler)); table.setWidget(i, 2, new TextButton("Collapse", handler)); table.setWidget(i, 3, new TextButton("Show", handler)); table.setWidget(i, 4, new TextButton("Hide", handler)); } return table; }