void (final LwComponent component, final FormSourceCodeGenerator generator, final String variable, final String parentVariable) { if (!myHaveCc) { generator.append("com.jgoodies.forms.layout.CellConstraints cc = new com.jgoodies.forms.layout.CellConstraints();\n"); myHaveCc = true; } generator.startMethodCall(parentVariable, "add"); generator.pushVar(variable); CellConstraints cc = (CellConstraints) component.getCustomLayoutConstraints(); GridConstraints constraints = component.getConstraints(); final boolean haveInsets = !cc.insets.equals(new Insets(0, 0, 0, 0)); if (haveInsets) { generator.startConstructor(CellConstraints.class.getName()); } else { if (constraints.getColSpan() == 1 && constraints.getRowSpan() == 1) { generator.startMethodCall("cc", "xy"); } else if (constraints.getRowSpan() == 1) { generator.startMethodCall("cc", "xyw"); } else { generator.startMethodCall("cc", "xywh"); } } generator.push(constraints.getColumn()+1); generator.push(constraints.getRow()+1); if (constraints.getColSpan() > 1 || constraints.getRowSpan() > 1 || haveInsets) { generator.push(constraints.getColSpan()); } if (constraints.getRowSpan() > 1 || haveInsets) { generator.push(constraints.getRowSpan()); } if (cc.hAlign != CellConstraints.DEFAULT || cc.vAlign != CellConstraints.DEFAULT || haveInsets) { @NonNls String hAlign = (cc.hAlign == CellConstraints.DEFAULT) ? "DEFAULT" : FormLayoutCodeGenerator.HORZ_ALIGN_FIELDS [Utils.alignFromConstraints(constraints, true)]; @NonNls String vAlign = (cc.vAlign == CellConstraints.DEFAULT) ? "DEFAULT" : FormLayoutCodeGenerator.VERT_ALIGN_FIELDS [Utils.alignFromConstraints(constraints, false)]; generator.pushVar("com.jgoodies.forms.layout.CellConstraints." + hAlign); generator.pushVar("com.jgoodies.forms.layout.CellConstraints." + vAlign); } if (haveInsets) { generator.newInsets(cc.insets); } generator.endMethod(); generator.endMethod(); }