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

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

Introduction

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

Prototype

public FormLayout(ColumnSpec[] colSpecs, RowSpec[] rowSpecs) 

Source Link

Document

Constructs a FormLayout using the given column and row specifications.

Usage

From source file:com.isencia.passerelle.hmi.generic.ParameterFilterDialog.java

License:Open Source License

private int buildParameterFilter(CompositeActor model, int paramCount, List<Settable> parameters, NamedObj a,
        JXTaskPane cfgPanel, boolean collapsed) {
    FormLayout formLayout = new FormLayout("min(100dlu;pref),5dlu,pref,2dlu", ""); // add rows dynamically
    DefaultFormBuilder builder = new DefaultFormBuilder(formLayout);
    builder.setComponentFactory(HMIComponentFactory.getInstance());
    builder.setDefaultDialogBorder();/*from  ww  w .j  av  a  2s.c  o  m*/
    setBold(builder.appendTitle("Parameters"));
    setBold(builder.appendTitle("          Aliases for UI labels"));
    builder.appendSeparator();

    cfgPanel.setCollapsed(collapsed);
    if (model != a) {
        cfgPanel.setTitle(ModelUtils.getFullNameButWithoutModelName(model, a));
    } else {
        cfgPanel.setTitle("Model " + a.getName());
    }
    cfgPanel.setSpecial(true);
    cfgPanel.add(builder.getPanel());
    Model filterCfgModel = getModelParameterFilterConfig().getModel(model.getDisplayName());
    boolean filterCfgKnown = filterCfgModel != null;
    for (int i = 0; i < parameters.size(); i++, paramCount++) {
        Settable p = parameters.get(i);
        String stdName = p.getName();
        String alias = null;
        boolean checked = true;
        if (filterCfgKnown) {
            try {
                alias = filterCfgModel.getFieldMapping()
                        .getValueForKey(ModelUtils.getFullNameButWithoutModelName(model, p));
                checked = (alias != null);
                alias = stdName.equals(alias) ? null : alias;
            } catch (Exception e) {
                // just in case...
            }
        }

        CheckableComponent cComp = new CheckableComponent(new JTextField(alias, 20), p, checked);
        builder.append(p.getName(), cComp);
        filters.add(cComp);
    }
    return paramCount;
}

From source file:com.isencia.passerelle.hmi.specific.HMITest.java

License:Open Source License

private JPanel getButtonPanel() {
    addScanLineButton = new JButton("Add scan line");
    final AddRowCommand addRowCommand = new AddRowCommand(myTableModel);
    addScanLineButton.addActionListener(addRowCommand);
    ////from  w  w  w.  j  a  va 2s  .  com
    deleteScanLineButton = new JButton("Delete scan line");
    final DeleteRowCommand deleteRowCommand = new DeleteRowCommand(table, myTableModel);
    deleteScanLineButton.addActionListener(deleteRowCommand);
    //
    goButton = new JButton("GO");
    //
    loadScanButton = new JButton("Load sequence");
    // LoadSequenceCommand loadSequenceCommand = new
    // LoadSequenceCommand(contextData);
    // loadScanButton.addActionListener(loadSequenceCommand);
    //
    saveScanButton = new JButton("Save sequence");
    //
    // //SaveRockingCommand saveRockingCommand = new SaveRockingCommand();
    // saveScanButton.addActionListener(new ModelSaver());
    saveScanButton.setAction(new SaveAction(this));
    //
    saveScanAsButton = new JButton("Save sequence as");
    // SaveSequenceCommand saveSequenceCommand = new
    // SaveSequenceCommand(contextData);
    // saveScanAsButton.addActionListener(saveSequenceCommand);
    //
    //
    saveFileTextField = new JTextField(getCurrentModel().getName());
    //
    final FormLayout layout = new FormLayout("p, 3dlu, p, 3dlu, p", // cols
            "pref, 3dlu, p, 9dlu, p, 3dlu, p, 3dlu, p"); // rows

    // Specify that columns 1 & 5 as well as 3 & 7 have equal widths.
    layout.setColumnGroups(new int[][] { { 1, 3, 5 } });
    //
    // // Create a builder that assists in adding components to the
    // container.
    // // Wrap the panel with a standardized border.
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();

    // Obtain a reusable constraints object to place components in the grid.
    final CellConstraints cc = new CellConstraints();

    // Fill the grid with components; the builder offers to create
    // frequently used components, e.g. separators and labels.

    // Add a titled separator to cell (1, 1) that spans 7 columns.

    builder.addSeparator("Commands", cc.xyw(1, 1, 5));
    builder.add(addScanLineButton, cc.xyw(1, 3, 1));
    builder.add(deleteScanLineButton, cc.xyw(3, 3, 1));
    builder.add(goButton, cc.xyw(5, 3, 1));

    builder.addSeparator("File", cc.xyw(1, 5, 5));
    builder.add(loadScanButton, cc.xyw(1, 7, 1));
    builder.add(saveScanButton, cc.xyw(3, 7, 1));
    builder.add(saveScanAsButton, cc.xyw(5, 7, 1));
    builder.add(saveFileTextField, cc.xyw(1, 9, 5));

    return builder.getPanel();
}

From source file:com.isencia.passerelle.hmi.specific.HMITest.java

License:Open Source License

private JPanel getRockingCurvePanel() {
    // Initialization
    rockingCurveTextField = new JTextField("100");
    registerBinding("rockingCurveField", rockingCurveTextField,
            (ParameterToWidgetBinder) new ParameterToTextFieldBinder());

    // Create panel
    final FormLayout layout = new FormLayout("p, 3dlu, p", // cols
            "pref, 3dlu, p"); // rows

    // Specify that columns 1 & 5 as well as 3 & 7 have equal widths.
    layout.setColumnGroups(new int[][] { { 1, 3 } });

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();/*from  w w  w  . java 2  s  . com*/

    // Obtain a reusable constraints object to place components in the grid.
    final CellConstraints cc = new CellConstraints();

    builder.addSeparator("Rocking curve", cc.xyw(1, 1, 3));
    builder.addLabel("Rocking curve (%)", cc.xy(1, 3));
    builder.add(rockingCurveTextField, cc.xy(3, 3));

    return builder.getPanel();
}

From source file:com.isencia.passerelle.hmi.specific.HMITest.java

License:Open Source License

private JPanel getTableScrollPane() {
    // Scan list table
    final String[] columnNames = { "Scan", "Position", "Sample name", "Scan name", "Number of scans",
            "Gain auto" };

    myTableModel = new MyTableModel(columnNames, 0);
    table = new JTable(myTableModel);
    table.setPreferredScrollableViewportSize(new Dimension(600, 200));
    tableScrollPane = new JScrollPane(table);

    registerBinding("scanPositionColumn", myTableModel,
            (ParameterToWidgetBinder) new ParameterToTableColumnBinder(1));

    // Create panel
    final FormLayout layout = new FormLayout("p", // cols
            "pref, 3dlu, p"); // rows

    // Specify that columns 1 & 5 as well as 3 & 7 have equal widths.
    // layout.setColumnGroups(new int[][]{{1, 3}});

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();/* ww  w  . j a v a  2  s  .  c o m*/

    // Obtain a reusable constraints object to place components in the grid.
    final CellConstraints cc = new CellConstraints();

    builder.addSeparator("Scan sequences", cc.xyw(1, 1, 1));
    builder.add(tableScrollPane, cc.xyw(1, 3, 1));

    return builder.getPanel();
}

From source file:com.isencia.passerelle.hmi.specific.HMITest.java

License:Open Source License

private JPanel getTemperaturePanel() {

    final String[] columnNames = { "Step", "Temperature" };

    myTableModelTemperature = new MyTableModel(columnNames, 0);
    temperatureTable = new JTable(myTableModelTemperature);
    temperatureTable.setPreferredScrollableViewportSize(new Dimension(200, 200));

    temperatureTableScrollPane = new JScrollPane(temperatureTable);

    // Create buttons
    addTemperatureButton = new JButton("Add temperature");
    final AddRowCommand addRowCommand = new AddRowCommand(myTableModelTemperature);
    addTemperatureButton.addActionListener(addRowCommand);

    deleteTemperatureButton = new JButton("Delete temperature");
    final DeleteRowCommand deleteRowCommand = new DeleteRowCommand(temperatureTable, myTableModelTemperature);
    deleteTemperatureButton.addActionListener(deleteRowCommand);

    // Create panel
    final FormLayout layout = new FormLayout("p, 3dlu, p", // cols
            "pref, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, 30dlu"); // rows

    // Specify that columns 1 & 5 as well as 3 & 7 have equal widths.
    // layout.setColumnGroups(new int[][]{{1, 3}});

    // Create a builder that assists in adding components to the container.
    // Wrap the panel with a standardized border.
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();//from w ww . j  a v a2s  .  c om

    // Obtain a reusable constraints object to place components in the grid.
    final CellConstraints cc = new CellConstraints();

    builder.addSeparator("Temperature settings", cc.xyw(1, 1, 3));
    builder.add(temperatureTableScrollPane, cc.xywh(1, 3, 1, 7));
    builder.add(addTemperatureButton, cc.xyw(3, 3, 1));
    builder.add(deleteTemperatureButton, cc.xyw(3, 5, 1));

    return builder.getPanel();
}

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  w w  .  j a v  a2  s . c o  m*/

    /** 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.codegen.gui.editor.SourceView.java

License:Open Source License

public JPanel createPanel(Component editor) {
    JPanel jpanel1 = new JPanel();
    FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE",
            "CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE");
    CellConstraints cc = new CellConstraints();
    jpanel1.setLayout(formlayout1);/*from  w  w w  .j  a  v  a2s. c  o  m*/

    jpanel1.add(createPanel1(), cc.xy(2, 2));

    jpanel1.add(editor, cc.xy(2, 3));

    addFillComponents(jpanel1, new int[] { 1, 2, 3 }, new int[] { 1, 2, 3, 4 });
    return jpanel1;
}

From source file:com.jeta.swingbuilder.codegen.gui.editor.SourceView.java

License:Open Source License

public JPanel createPanel1() {
    JPanel jpanel1 = new JPanel();
    jpanel1.setOpaque(false);/*from ww w.  j a  v  a  2s  . c o m*/
    FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE",
            "CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
    CellConstraints cc = new CellConstraints();
    jpanel1.setLayout(formlayout1);

    m_codegen_label.setFont(new Font("Dialog", Font.BOLD, 12));
    m_codegen_label.setAntiAliased(true);
    m_codegen_label.setName("codegen.label");
    m_codegen_label.setText("Code Generation");
    jpanel1.add(m_codegen_label, cc.xy(1, 1));

    m_options_btn.setText(I18N.getLocalizedMessage("Options..."));
    m_options_btn.setName("options.btn");
    jpanel1.add(m_options_btn, cc.xy(3, 1));

    addFillComponents(jpanel1, new int[] { 2 }, new int[0]);
    return jpanel1;
}

From source file:com.jeta.swingbuilder.gui.components.GridSizePanel.java

License:Open Source License

/**
 * ctor//from  w w w  . j  av  a2s . co  m
 */
public GridSizePanel() {
    FormLayout layout = new FormLayout("12px,pref,4dlu,pref,32px", "12px,pref,2dlu,pref,24px");
    setLayout(layout);
    CellConstraints cc = new CellConstraints();

    JTextField tf = new JTextField(5);
    tf.setDocument(new IntegerDocument(false));
    tf.setName(ID_COLS_FIELD);
    add(new JLabel(I18N.getLocalizedMessage("Columns")), cc.xy(2, 2));
    add(tf, cc.xy(4, 2));

    tf = new JTextField(5);
    tf.setDocument(new IntegerDocument(false));
    tf.setName(ID_ROWS_FIELD);
    add(new JLabel(I18N.getLocalizedMessage("Rows")), cc.xy(2, 4));
    add(tf, cc.xy(4, 4));
    setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
}

From source file:com.jeta.swingbuilder.gui.editor.FormEditor.java

License:Open Source License

/**
 * Creates the status bar for this editor
 *///from  ww  w .ja v  a 2s. c  om
private JETAPanel createStatusBar() {
    if (FormDesignerUtils.isDebug()) {
        JETAPanel panel = new JETAPanel(new FormLayout("pref:grow", "pref,pref"));
        CellConstraints cc = new CellConstraints();

        panel.add(createStandardStatusBar(), cc.xy(1, 1));
        panel.add(createDebugStatusBar(), cc.xy(1, 2));
        return panel;
    } else {
        return createStandardStatusBar();
    }
}