Example usage for com.jgoodies.forms.layout FormLayout getRowCount

List of usage examples for com.jgoodies.forms.layout FormLayout getRowCount

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout FormLayout getRowCount.

Prototype

public int getRowCount() 

Source Link

Document

Returns the number of rows in this layout.

Usage

From source file:com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.SimpleContainsAssertion.java

License:EUPL

private void buildDialog() {
    XFormDialogBuilder builder = XFormFactory.createDialogBuilder("Contains Assertion");
    XForm mainForm = builder.createForm("Basic",
            new FormLayout("5px,left:pref,5px,fill:default:grow(1.0),5px"));
    JPanel mainFormPanel = ((SwingXFormImpl) mainForm).getPanel();
    FormLayout mainFormLayout = (FormLayout) mainFormPanel.getLayout();

    mainForm.addTextField(CONTENT, "Content to check for", XForm.FieldType.TEXTAREA).setWidth(40);

    mainFormLayout.setRowSpec(mainFormLayout.getRowCount(), new RowSpec("top:default:grow(1.0)"));
    mainFormPanel.add(mainFormPanel.getComponent(mainFormPanel.getComponents().length - 1),
            cc.xy(4, mainFormLayout.getRowCount(), "fill,fill"));

    mainForm.addCheckBox(IGNORE_CASE, "Ignore case in comparison");
    mainForm.addCheckBox(USE_REGEX, "Use token as Regular Expression");

    dialog = builder.buildDialog(builder.buildOkCancelHelpActions(HelpUrls.SIMPLE_CONTAINS_HELP_URL),
            "Specify options", UISupport.OPTIONS_ICON);
}

From source file:com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.SimpleNotContainsAssertion.java

License:EUPL

private void buildDialog() {
    XFormDialogBuilder builder = XFormFactory.createDialogBuilder("NotContains Assertion");
    XForm mainForm = builder.createForm("Basic",
            new FormLayout("5px,left:pref,5px,fill:default:grow(1.0),5px"));
    JPanel mainFormPanel = ((SwingXFormImpl) mainForm).getPanel();
    FormLayout mainFormLayout = (FormLayout) mainFormPanel.getLayout();

    mainForm.addTextField(CONTENT, "Content to check for", XForm.FieldType.TEXTAREA).setWidth(40);

    mainFormLayout.setRowSpec(mainFormLayout.getRowCount(), new RowSpec("top:default:grow(1.0)"));
    mainFormPanel.add(mainFormPanel.getComponent(mainFormPanel.getComponents().length - 1),
            cc.xy(4, mainFormLayout.getRowCount(), "fill,fill"));

    mainForm.addCheckBox(IGNORE_CASE, "Ignore case in comparison");
    mainForm.addCheckBox(USE_REGEX, "Use token as Regular Expression");

    dialog = builder.buildDialog(builder.buildOkCancelHelpActions(HelpUrls.SIMPLE_NOT_CONTAINS_HELP_URL),
            "Specify options", UISupport.OPTIONS_ICON);
}

From source file:com.intellij.uiDesigner.compiler.FormLayoutUtils.java

License:Apache License

public static String getEncodedRowSpecs(final FormLayout formLayout) {
    StringBuffer result = new StringBuffer();
    for (int i = 1; i <= formLayout.getRowCount(); i++) {
        if (result.length() > 0) {
            result.append(",");
        }//  w w  w .  ja  v  a2 s  .  c  o  m
        result.append(getEncodedSpec(formLayout.getRowSpec(i)));
    }
    return result.toString();
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

@Override
public void writeLayout(final XmlWriter writer, final RadContainer radContainer) {
    FormLayout layout = (FormLayout) radContainer.getLayout();
    for (int i = 1; i <= layout.getRowCount(); i++) {
        RowSpec rowSpec = layout.getRowSpec(i);
        writer.startElement(UIFormXmlConstants.ELEMENT_ROWSPEC);
        try {//  w  ww .j  a  v a2s .  c  o  m
            writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_VALUE, FormLayoutUtils.getEncodedSpec(rowSpec));
        } finally {
            writer.endElement();
        }
    }
    for (int i = 1; i <= layout.getColumnCount(); i++) {
        ColumnSpec columnSpec = layout.getColumnSpec(i);
        writer.startElement(UIFormXmlConstants.ELEMENT_COLSPEC);
        try {
            writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_VALUE, FormLayoutUtils.getEncodedSpec(columnSpec));
        } finally {
            writer.endElement();
        }
    }
    writeGroups(writer, UIFormXmlConstants.ELEMENT_ROWGROUP, layout.getRowGroups());
    writeGroups(writer, UIFormXmlConstants.ELEMENT_COLGROUP, layout.getColumnGroups());
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

@NotNull
@Override/*from   w  ww.j  a  v  a  2  s.co  m*/
public ComponentDropLocation getDropLocation(@NotNull RadContainer container, @Nullable final Point location) {
    FormLayout formLayout = getFormLayout(container);
    if (formLayout.getRowCount() == 0 || formLayout.getColumnCount() == 0) {
        if (location != null) {
            Rectangle rc = new Rectangle(new Point(), container.getDelegee().getSize());
            return new FormFirstComponentInsertLocation(container, location, rc);
        }
    }
    final FormLayout.LayoutInfo layoutInfo = formLayout.getLayoutInfo(container.getDelegee());
    if (location != null && location.x > layoutInfo.getWidth()) {
        int row = findCell(layoutInfo.rowOrigins, location.y);
        if (row == -1) {
            return NoDropLocation.INSTANCE;
        }
        return new GridInsertLocation(container, row, getGridColumnCount(container) - 1,
                GridInsertMode.ColumnAfter);
    }
    if (location != null && location.y > layoutInfo.getHeight()) {
        int column = findCell(layoutInfo.columnOrigins, location.x);
        if (column == -1) {
            return NoDropLocation.INSTANCE;
        }
        return new GridInsertLocation(container, getGridRowCount(container) - 1, column,
                GridInsertMode.RowAfter);
    }

    if (container.getGridRowCount() == 1 && container.getGridColumnCount() == 1
            && getComponentAtGrid(container, 0, 0) == null) {
        final Rectangle rc = getGridCellRangeRect(container, 0, 0, 0, 0);
        if (location == null) {
            return new FormFirstComponentInsertLocation(container, rc, 0, 0);
        }
        return new FormFirstComponentInsertLocation(container, location, rc);
    }

    return super.getDropLocation(container, location);
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

private static void insertOrAppendRow(final FormLayout formLayout, final int index, final RowSpec rowSpec) {
    if (index == formLayout.getRowCount() + 1) {
        formLayout.appendRow(rowSpec);// ww  w.  j  av a2  s  . co m
    } else {
        formLayout.insertRow(index, rowSpec);
    }
}

From source file:com.intellij.uiDesigner.radComponents.RadFormLayoutManager.java

License:Apache License

@Override
public int deleteGridCells(final RadContainer grid, final int cellIndex, final boolean isRow) {
    int result = 1;
    FormLayout formLayout = (FormLayout) grid.getLayout();
    adjustDeletedCellOrigins(grid, cellIndex, isRow);
    if (isRow) {/*from w w  w .j a  va  2  s. c  om*/
        int[][] groupIndices = formLayout.getRowGroups();
        groupIndices = removeDeletedCell(groupIndices, cellIndex + 1);
        formLayout.setRowGroups(groupIndices);
        formLayout.removeRow(cellIndex + 1);
        updateGridConstraintsFromCellConstraints(grid);
        if (formLayout.getRowCount() > 0 && formLayout.getRowCount() % 2 == 0) {
            int gapRowIndex = (cellIndex >= grid.getGridRowCount()) ? cellIndex - 1 : cellIndex;
            if (GridChangeUtil.isRowEmpty(grid, gapRowIndex)) {
                formLayout.removeRow(gapRowIndex + 1);
                updateGridConstraintsFromCellConstraints(grid);
                result++;
            }
        }
    } else {
        int[][] groupIndices = formLayout.getColumnGroups();
        groupIndices = removeDeletedCell(groupIndices, cellIndex + 1);
        formLayout.setColumnGroups(groupIndices);
        formLayout.removeColumn(cellIndex + 1);
        updateGridConstraintsFromCellConstraints(grid);
        if (formLayout.getColumnCount() > 0 && formLayout.getColumnCount() % 2 == 0) {
            int gapColumnIndex = (cellIndex >= grid.getGridColumnCount()) ? cellIndex - 1 : cellIndex;
            if (GridChangeUtil.isColumnEmpty(grid, gapColumnIndex)) {
                formLayout.removeColumn(gapColumnIndex + 1);
                updateGridConstraintsFromCellConstraints(grid);
                result++;
            }
        }
    }
    return result;
}

From source file:com.jeta.swingbuilder.codegen.builder.PanelWriter.java

License:Open Source License

public MethodWriter createPanel(DeclarationManager decl_mgr, FormMemento fm) {
    decl_mgr.addImport("javax.swing.JPanel");
    decl_mgr.addImport("com.jgoodies.forms.layout.CellConstraints");
    decl_mgr.addImport("com.jgoodies.forms.layout.FormLayout");

    PropertiesMemento pm = fm.getPropertiesMemento();

    MethodWriter method_writer = new MethodWriter(decl_mgr, null,
            getSuggestedMethodName(pm.getComponentName()));
    BeanWriter form_bean_writer = new BeanWriter(method_writer, pm);
    method_writer.setReturnResult(form_bean_writer);

    LocalVariableDeclaration layout = new LocalVariableDeclaration(method_writer,
            com.jgoodies.forms.layout.FormLayout.class);
    layout.addParameter(new StringExpression(fm.getColumnSpecs()));
    layout.addParameter(new StringExpression(fm.getRowSpecs()));

    /** we need this to get the row/column count */
    FormLayout formlayout = new FormLayout(FormSpecAdapter.fixupSpecs(fm.getColumnSpecs()),
            FormSpecAdapter.fixupSpecs(fm.getRowSpecs()));

    method_writer.addStatements(form_bean_writer.getStatements());

    method_writer.addStatement(layout);/*from w ww .  java  2  s  . com*/

    /** set the column and row groups */
    setGroups(method_writer, layout.getVariable(), fm, true);
    setGroups(method_writer, layout.getVariable(), fm, false);

    LocalVariableDeclaration ccvar = new LocalVariableDeclaration(method_writer,
            com.jgoodies.forms.layout.CellConstraints.class, "cc");
    method_writer.addStatement(ccvar);

    /** add the panel declaration/ctor to the method */
    MethodStatement ss = new MethodStatement(form_bean_writer.getBeanVariable(), "setLayout");
    ss.addParameter(new BasicExpression(layout.getVariable()));
    method_writer.addStatement(ss);

    decl_mgr.addMethod(method_writer);

    /** puts a newline between beans */
    method_writer.addStatement(new BasicStatement(""));

    HashMap row_cache = new HashMap();
    HashMap col_cache = new HashMap();

    Iterator iter = fm.iterator();
    while (iter.hasNext()) {
        ComponentMemento cm = (ComponentMemento) iter.next();
        CellConstraintsMemento ccm = cm.getCellConstraintsMemento();
        CellConstraints cc = ccm.createCellConstraints();

        try {
            if (cm instanceof FormMemento) {
                FormMemento cfm = (FormMemento) cm;
                MethodWriter subpanel = createPanel(method_writer, cfm);
                method_writer.addStatement(createAddComponentStatement(form_bean_writer.getBeanVariable(),
                        subpanel.getMethodName() + "()", ccvar.getVariable(), cc));

            } else if (cm instanceof BeanMemento) {
                BeanMemento bm = (BeanMemento) cm;
                Integer icol = new Integer(cc.gridX);
                Integer irow = new Integer(cc.gridY);

                if (bm.getBeanClass() == null) {
                    /** found an empty component */
                    if (col_cache.get(icol) == null)
                        col_cache.put(icol, new FillMarker(bm, formlayout.getColumnSpec(icol.intValue())));

                    if (row_cache.get(irow) == null)
                        row_cache.put(irow, new FillMarker(bm, formlayout.getRowSpec(irow.intValue())));

                } else if (bm.getProperties() != null) {
                    String beanclass = bm.getBeanClass();
                    if (beanclass.indexOf("GridView") > 0 || beanclass.indexOf("JETALabel") > 0
                            || decl_mgr.isIncludeNonStandard() || beanclass.indexOf("com.jeta") < 0) {

                        BeanWriter bw = new BeanWriter(method_writer, bm.getProperties());
                        method_writer.addStatements(bw.getStatements());

                        method_writer
                                .addStatement(createAddComponentStatement(form_bean_writer.getBeanVariable(),
                                        bw.getResultVariable(), ccvar.getVariable(), cc));
                        /** puts a newline between beans */
                        method_writer.addStatement(new BasicStatement(""));

                        if (icol.intValue() == 1)
                            row_cache.put(irow, new FillMarker(bm, formlayout.getRowSpec(irow.intValue())));

                        if (irow.intValue() == 1)
                            col_cache.put(icol, new FillMarker(bm, formlayout.getColumnSpec(icol.intValue())));
                    }

                }
            } else {
                assert (false);
            }
        } catch (Exception e) {

        }
    }

    MethodStatement addseps = new MethodStatement("addFillComponents");
    addseps.addParameter(form_bean_writer.getBeanVariable());
    addseps.addParameter(createFillArray(col_cache, formlayout.getColumnCount()));
    addseps.addParameter(createFillArray(row_cache, formlayout.getRowCount()));
    method_writer.addStatement(addseps);

    return method_writer;
}

From source file:com.jeta.swingbuilder.gui.effects.ImageFillView.java

License:Open Source License

/**
 * ctor//from   w w w.ja va2s.  c om
 */
public ImageFillView(GridView preview, PaintProperty pp) {
    super("com/jeta/swingbuilder/gui/images/imageProperties.frm", null);
    FormPanel view = getView();
    Container form = view.getFormContainer();
    FormLayout layout = (FormLayout) form.getLayout();
    layout.appendRow(new RowSpec("2dlu"));
    layout.appendRow(new RowSpec("pref"));
    CellConstraints cc = new CellConstraints();

    JComboBox hbox = new JComboBox(new Object[] { "LEFT", "CENTER", "RIGHT" });
    hbox.setName(ImageFillNames.ID_HORIZONTAL_ALIGNMENT);
    form.add(new JLabel("Horizontal Alignment"), cc.xy(1, layout.getRowCount()));
    form.add(hbox, cc.xy(3, layout.getRowCount()));

    layout.appendRow(new RowSpec("2dlu"));
    layout.appendRow(new RowSpec("pref"));

    JComboBox vbox = new JComboBox(new Object[] { "TOP", "CENTER", "BOTTOM" });
    vbox.setName(ImageFillNames.ID_VERTICAL_ALIGNMENT);
    form.add(new JLabel("Vertical Alignment"), cc.xy(1, layout.getRowCount()));
    form.add(vbox, cc.xy(3, layout.getRowCount()));

    m_preview = preview;
    setController(new ImageFillController(this));
    if (pp != null) {
        setPaintProperty(pp);
    }
}

From source file:loci.ome.notes.editor.EnumWindow.java

License:Open Source License

private void addOption(String name) {
    remove(content);//from w  w  w.jav  a2s . c  o  m
    FormLayout layout = (FormLayout) content.getLayout();
    layout.insertRow(layout.getRowCount() - 2, new RowSpec("pref:grow"));
    layout.insertRow(layout.getRowCount() - 2, new RowSpec("pref"));
    JLabel label = new JLabel(name);
    JButton remove = new JButton("Remove");
    remove.setActionCommand("remove");
    remove.addActionListener(this);

    options.add(name);

    int last = layout.getRowCount() - 4;
    content.add(label, CC.xy(2, last));
    content.add(remove, CC.xywh(7, last, 2, 1));
    add(content);
    pack();
    parent.repaint();
}