void (final LwContainer container, final FormSourceCodeGenerator generator, final String variable) { if (container.isXY()) { if (container.getComponentCount() != 0) { throw new IllegalStateException("only empty xys are accepted"); } // no layout needed } else { if (container.isGrid()) { final GridLayoutManager layout = (GridLayoutManager)container.getLayout(); generator.startMethodCall(variable, "setLayout"); generator.startConstructor(GridLayoutManager.class.getName()); generator.push(layout.getRowCount()); generator.push(layout.getColumnCount()); generator.newInsets(layout.getMargin()); generator.push(layout.getHGap()); generator.push(layout.getVGap()); if (layout.isSameSizeHorizontally() || layout.isSameSizeVertically()) { // values differ from the defaults - use appropriate constructor generator.push(layout.isSameSizeHorizontally()); generator.push(layout.isSameSizeVertically()); } generator.endConstructor(); // GridLayoutManager generator.endMethod(); } else { throw new IllegalArgumentException("unknown layout: " + container.getLayout()); } } }