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

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

Introduction

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

Prototype

public void insertColumn(int columnIndex, ColumnSpec columnSpec) 

Source Link

Document

Inserts the specified column at the specified position.

Usage

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

License:Apache License

private static void insertOrAppendColumn(final FormLayout formLayout, final int index,
        final ColumnSpec columnSpec) {
    if (index == formLayout.getColumnCount() + 1) {
        formLayout.appendColumn(columnSpec);
    } else {//from  w  w  w . java  2s .  c  o  m
        formLayout.insertColumn(index, columnSpec);
    }
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java

License:Open Source License

/**
 * Main function for building the merge entry JPanel
 *///from w  w  w  .ja  va 2  s.c o  m
private void initialize() {

    joint = new TreeSet<>(one.getFieldNames());
    joint.addAll(two.getFieldNames());

    // Remove field starting with __
    TreeSet<String> toberemoved = new TreeSet<>();
    for (String field : joint) {
        if (field.startsWith("__")) {
            toberemoved.add(field);
        }
    }

    for (String field : toberemoved) {
        joint.remove(field);
    }

    // Create storage arrays
    rb = new JRadioButton[3][joint.size() + 1];
    ButtonGroup[] rbg = new ButtonGroup[joint.size() + 1];
    identical = new Boolean[joint.size() + 1];
    jointStrings = new String[joint.size()];

    // Create main layout
    String colSpecMain = "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
    String colSpecMerge = "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
    String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
    StringBuilder rowBuilder = new StringBuilder("");
    for (int i = 0; i < joint.size(); i++) {
        rowBuilder.append("pref, ");
    }
    rowBuilder.append("pref");

    FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
    FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
    mainPanel.setLayout(mainLayout);
    mergePanel.setLayout(mergeLayout);

    JLabel label = new JLabel(Localization.lang("Use"));
    Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));

    mainPanel.add(label, cc.xyw(4, 1, 7, "center, bottom"));

    // Set headings
    JLabel[] headingLabels = new JLabel[6];
    for (int i = 0; i < 6; i++) {
        headingLabels[i] = new JLabel(columnHeadings[i]);
        font = headingLabels[i].getFont();
        headingLabels[i].setFont(font.deriveFont(font.getStyle() | Font.BOLD));
        mainPanel.add(headingLabels[i], cc.xy(1 + (i * 2), 2));

    }

    mainPanel.add(new JSeparator(), cc.xyw(1, 3, 11));

    // Start with entry type
    String type1 = one.getType();
    String type2 = two.getType();

    mergedEntry.setType(type1);
    label = new JLabel(Localization.lang("Entry type"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mergePanel.add(label, cc.xy(1, 1));

    JTextArea type1ta = new JTextArea(type1);
    type1ta.setEditable(false);
    mergePanel.add(type1ta, cc.xy(3, 1));
    if (type1.compareTo(type2) == 0) {
        identical[0] = true;
    } else {
        identical[0] = false;
        rbg[0] = new ButtonGroup();
        for (int k = 0; k < 3; k += 2) {
            rb[k][0] = new JRadioButton();
            rbg[0].add(rb[k][0]);
            mergePanel.add(rb[k][0], cc.xy(5 + (k * 2), 1));
            rb[k][0].addChangeListener(e -> updateAll());
        }
        rb[0][0].setSelected(true);
    }
    JTextArea type2ta = new JTextArea(type2);
    type2ta.setEditable(false);
    mergePanel.add(type2ta, cc.xy(11, 1));

    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    int tmpLabelWidth = 0;
    for (String field : joint) {
        jointStrings[row - 2] = field;
        label = new JLabel(CaseChangers.UPPER_FIRST.format(field));
        font = label.getFont();
        label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
        mergePanel.add(label, cc.xy(1, row));
        String string1 = one.getField(field);
        String string2 = two.getField(field);
        identical[row - 1] = false;
        if ((string1 != null) && (string2 != null) && (string1.equals(string2))) {
            identical[row - 1] = true;
        }

        tmpLabelWidth = label.getPreferredSize().width;
        if (tmpLabelWidth > maxLabelWidth) {
            maxLabelWidth = tmpLabelWidth;
        }

        if ("abstract".equals(field) || "review".equals(field)) {
            // Treat the abstract and review fields special
            JTextArea tf = new JTextArea();
            tf.setLineWrap(true);
            tf.setEditable(false);
            JScrollPane jsptf = new JScrollPane(tf);

            mergeLayout.setRowSpec(row, RowSpec.decode("center:2cm:grow"));
            mergePanel.add(jsptf, cc.xy(3, row, "f, f"));
            tf.setText(string1);
            tf.setCaretPosition(0);

        } else {
            JTextArea tf = new JTextArea(string1);
            mergePanel.add(tf, cc.xy(3, row));
            tf.setCaretPosition(0);
            tf.setEditable(false);
        }

        // Add radio buttons if the two entries do not have identical fields
        if (identical[row - 1]) {
            mergedEntry.setField(field, string1);
        } else {
            rbg[row - 1] = new ButtonGroup();
            for (int k = 0; k < 3; k++) {
                rb[k][row - 1] = new JRadioButton();
                rbg[row - 1].add(rb[k][row - 1]);
                mergePanel.add(rb[k][row - 1], cc.xy(5 + (k * 2), row));
                rb[k][row - 1].addChangeListener(e -> updateAll());
            }
            if (string1 == null) {
                rb[0][row - 1].setEnabled(false);
                mergedEntry.setField(field, string2);
                rb[2][row - 1].setSelected(true);
            } else {
                mergedEntry.setField(field, string1);
                rb[0][row - 1].setSelected(true);
                if (string2 == null) {
                    rb[2][row - 1].setEnabled(false);
                }
            }
        }

        if ("abstract".equals(field) || "review".equals(field)) {
            // Again, treat abstract and review special
            JTextArea tf = new JTextArea();
            tf.setLineWrap(true);
            tf.setEditable(false);
            JScrollPane jsptf = new JScrollPane(tf);

            mergePanel.add(jsptf, cc.xy(11, row, "f, f"));
            tf.setText(string2);
            tf.setCaretPosition(0);

        } else {
            JTextArea tf = new JTextArea(string2);
            mergePanel.add(tf, cc.xy(11, row));
            tf.setCaretPosition(0);
            tf.setEditable(false);
        }

        row++;
    }

    JScrollPane scrollPane = new JScrollPane(mergePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    mainPanel.add(scrollPane, cc.xyw(1, 4, 11));
    mainPanel.add(new JSeparator(), cc.xyw(1, 5, 11));

    // Synchronize column widths
    String[] rbAlign = { "right", "center", "left" };
    mainLayout.setColumnSpec(1, ColumnSpec.decode(Integer.toString(maxLabelWidth) + "px"));
    Integer maxRBWidth = -1;
    Integer tmpRBWidth;
    for (int k = 0; k < 3; k++) {
        tmpRBWidth = headingLabels[k + 2].getPreferredSize().width;
        if (tmpRBWidth > maxRBWidth) {
            maxRBWidth = tmpRBWidth;
        }
    }
    for (int k = 0; k < 3; k++) {
        mergeLayout.setColumnSpec(5 + (k * 2), ColumnSpec.decode(rbAlign[k] + ":" + maxRBWidth + "px"));
    }

    // Setup a PreviewPanel and a Bibtex source box for the merged entry
    label = new JLabel(Localization.lang("Merged entry"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(1, 6, 6));

    String layoutString = Globals.prefs.get(JabRefPreferences.PREVIEW_0);
    pp = new PreviewPanel(null, mergedEntry, null, new MetaData(), layoutString);
    // JScrollPane jsppp = new JScrollPane(pp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    mainPanel.add(pp, cc.xyw(1, 8, 6));

    label = new JLabel(Localization.lang("Merged BibTeX source code"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(8, 6, 4));

    jta = new JTextArea();
    jta.setLineWrap(true);
    JScrollPane jspta = new JScrollPane(jta);
    mainPanel.add(jspta, cc.xyw(8, 8, 4));
    jta.setEditable(false);
    StringWriter sw = new StringWriter();
    try {
        new BibEntryWriter(new LatexFieldFormatter(), false).write(mergedEntry, sw, type);
    } catch (IOException ex) {
        LOGGER.error("Error in entry" + ": " + ex.getMessage(), ex);
    }
    jta.setText(sw.getBuffer().toString());
    jta.setCaretPosition(0);

    // Add some margin around the layout
    mainLayout.appendRow(RowSpec.decode(MARGIN));
    mainLayout.appendColumn(ColumnSpec.decode(MARGIN));
    mainLayout.insertRow(1, RowSpec.decode(MARGIN));
    mainLayout.insertColumn(1, ColumnSpec.decode(MARGIN));

    if (mainPanel.getHeight() > DIM.height) {
        mainPanel.setSize(new Dimension(mergePanel.getWidth(), DIM.height));
    }
    if (mainPanel.getWidth() > DIM.width) {
        mainPanel.setSize(new Dimension(DIM.width, mergePanel.getHeight()));
    }

    // Everything done, allow any action to actually update the merged entry
    doneBuilding = true;

    // Show what we've got
    mainPanel.setVisible(true);
    javax.swing.SwingUtilities.invokeLater(() -> scrollPane.getVerticalScrollBar().setValue(0));
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntriesDialog.java

License:Open Source License

/**
 * Sets up the dialog// w  w w  .ja  va 2  s .c om
 *
 * @param selected Selected BibtexEntries
 */
private void init(List<BibEntry> selected) {

    // Check if there are two entries selected
    if (selected.size() != 2) { // None selected. Inform the user to select entries first.
        JOptionPane.showMessageDialog(panel.frame(),
                Localization.lang("You have to choose exactly two entries to merge."), MERGE_ENTRIES,
                JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
        return;
    }

    // Store the two entries
    BibEntry one = selected.get(0);
    BibEntry two = selected.get(1);

    MergeEntries mergeEntries = new MergeEntries(one, two, panel.getBibDatabaseContext().getMode());

    // Create undo-compound
    NamedCompound ce = new NamedCompound(MERGE_ENTRIES);

    FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
    this.setLayout(layout);

    this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
    this.add(new JSeparator(), cc.xy(1, 3));

    // Create buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton cancel = new JButton(Localization.lang("Cancel"));
    cancel.setActionCommand("cancel");
    cancel.addActionListener(e -> {
        panel.output(Localization.lang("Cancelled merging entries"));
        dispose();
    });

    JButton replaceentries = new JButton(MERGE_ENTRIES);
    replaceentries.setActionCommand("replace");
    replaceentries.addActionListener(e -> {
        // Create a new entry and add it to the undo stack
        // Remove the other two entries and add them to the undo stack (which is not working...)
        BibEntry mergedEntry = mergeEntries.getMergeEntry();
        panel.insertEntry(mergedEntry);
        ce.addEdit(new UndoableInsertEntry(panel.database(), mergedEntry, panel));
        ce.addEdit(new UndoableRemoveEntry(panel.database(), one, panel));
        panel.database().removeEntry(one);
        ce.addEdit(new UndoableRemoveEntry(panel.database(), two, panel));
        panel.database().removeEntry(two);
        ce.end();
        panel.undoManager.addEdit(ce);
        panel.output(Localization.lang("Merged entries"));
        dispose();
    });

    bb.addButton(new JButton[] { replaceentries, cancel });
    this.add(bb.getPanel(), cc.xy(1, 5));

    // Add some margin around the layout
    layout.appendRow(RowSpec.decode(MARGIN));
    layout.appendColumn(ColumnSpec.decode(MARGIN));
    layout.insertRow(1, RowSpec.decode(MARGIN));
    layout.insertColumn(1, ColumnSpec.decode(MARGIN));

    // Set up a ComponentListener that saves the last size and position of the dialog
    this.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            // Save dialog position
            pw.storeWindowPosition();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            // Save dialog position
            pw.storeWindowPosition();
        }
    });

    pw = new PositionWindow(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y,
            JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
    pw.setWindowPosition();

    // Show what we've got
    setVisible(true);
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntryDOIDialog.java

License:Open Source License

/**
 * Sets up the dialog/* w ww.ja va 2 s. c o  m*/
 */
private void init() {
    mergeEntries = new MergeEntries(this.originalEntry, this.doiEntry, Localization.lang("Original entry"),
            Localization.lang("Entry from DOI"), panel.getBibDatabaseContext().getMode());

    // Create undo-compound
    ce = new NamedCompound(Localization.lang("Merge from DOI"));

    FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
    // layout.setColumnGroups(new int[][] {{3, 11}});
    this.setLayout(layout);

    this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
    this.add(new JSeparator(), cc.xy(1, 3));

    // Create buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton cancel = new JButton(Localization.lang("Cancel"));
    cancel.setActionCommand("cancel");
    cancel.addActionListener(e -> buttonPressed(e.getActionCommand()));

    JButton replaceentry = new JButton(Localization.lang("Replace original entry"));
    replaceentry.setActionCommand("done");
    replaceentry.addActionListener(e -> buttonPressed(e.getActionCommand()));

    bb.addButton(new JButton[] { replaceentry, cancel });
    this.add(bb.getPanel(), cc.xy(1, 5));

    // Add some margin around the layout
    layout.appendRow(RowSpec.decode(MARGIN));
    layout.appendColumn(ColumnSpec.decode(MARGIN));
    layout.insertRow(1, RowSpec.decode(MARGIN));
    layout.insertColumn(1, ColumnSpec.decode(MARGIN));

    pw = new PositionWindow(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y,
            JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
    pw.setWindowPosition();

    // Set up a ComponentListener that saves the last size and position of the dialog
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            // Save dialog position
            pw.storeWindowPosition();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            // Save dialog position
            pw.storeWindowPosition();
        }
    });

    // Show what we've got
    setVisible(true);

}

From source file:net.sf.jabref.gui.MergeEntriesDialog.java

License:Open Source License

private void init(BibtexEntry[] selected) {

    // Check if there are two entries selected
    if (selected.length != 2) { // None selected. Inform the user to select entries first.
        JOptionPane.showMessageDialog(frame, Globals.lang("You have to choose exactly two entries to merge."),
                Globals.lang("Merge entries"), JOptionPane.INFORMATION_MESSAGE);
        this.dispose();
        return;// w w w  . j  a v a2 s .c  om
    }

    // Store the two entries
    one = selected[0];
    two = selected[1];

    // Create undo-compound
    ce = new NamedCompound(Globals.lang("Merge entries"));

    joint = new TreeSet<String>(one.getAllFields());
    joint.addAll(two.getAllFields());

    // Remove field starting with __
    Set<String> toberemoved = new TreeSet<String>();
    for (String field : joint) {
        if (field.startsWith("__")) {
            toberemoved.add(field);
        }
    }

    for (String field : toberemoved) {
        joint.remove(field);
    }

    // Create storage arrays
    rb = new JRadioButton[3][joint.size() + 1];
    ButtonGroup[] rbg = new ButtonGroup[joint.size() + 1];
    identical = new Boolean[joint.size() + 1];
    jointStrings = new String[joint.size()];

    // Create layout
    String colSpec = "left:pref, 5px, fill:4cm:grow, 5px, right:pref, 3px, center:pref, 3px, left:pref, 5px, fill:4cm:grow";
    StringBuilder rowBuilder = new StringBuilder("pref, 10px, pref, ");
    for (int i = 0; i < joint.size(); i++) {
        rowBuilder.append("pref, ");
    }
    rowBuilder.append("10px, top:4cm:grow, 10px, pref");

    FormLayout layout = new FormLayout(colSpec, rowBuilder.toString());
    // layout.setColumnGroups(new int[][] {{3, 11}});
    this.setLayout(layout);

    // Set headings
    for (int i = 0; i < 6; i++) {
        JLabel label = new JLabel(columnHeadings[i]);
        Font font = label.getFont();
        label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
        this.add(label, cc.xy(1 + (i * 2), 1));

    }

    this.add(new JSeparator(), cc.xyw(1, 2, 11));

    // Start with entry type
    BibtexEntryType type1 = one.getType();
    BibtexEntryType type2 = two.getType();

    mergedEntry.setType(type1);
    JLabel label = new JLabel(Globals.lang("Entry type"));
    Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    this.add(label, cc.xy(1, 3));

    JTextArea type1ta = new JTextArea(type1.getName());
    type1ta.setEditable(false);
    this.add(type1ta, cc.xy(3, 3));
    if (type1.compareTo(type2) != 0) {
        identical[0] = false;
        rbg[0] = new ButtonGroup();
        for (int k = 0; k < 3; k += 2) {
            rb[k][0] = new JRadioButton();
            rbg[0].add(rb[k][0]);
            this.add(rb[k][0], cc.xy(5 + (k * 2), 3));
            rb[k][0].addChangeListener(new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    updateAll();
                }
            });
        }
        rb[0][0].setSelected(true);
    } else {
        identical[0] = true;
    }
    JTextArea type2ta = new JTextArea(type2.getName());
    type2ta.setEditable(false);
    this.add(type2ta, cc.xy(11, 3));

    // For all fields in joint add a row and possibly radio buttons
    int row = 4;
    for (String field : joint) {
        jointStrings[row - 4] = field;
        label = new JLabel(StringUtil.toUpperFirstLetter(field));
        font = label.getFont();
        label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
        this.add(label, cc.xy(1, row));
        String string1 = one.getField(field);
        String string2 = two.getField(field);
        identical[row - 3] = false;
        if ((string1 != null) && (string2 != null)) {
            if (string1.equals(string2)) {
                identical[row - 3] = true;
            }
        }

        if (field.equals("abstract")) {
            // Treat the abstract field special, maybe more fields? Review? Note?
            JTextArea tf = new JTextArea();
            tf.setLineWrap(true);
            tf.setEditable(false);
            JScrollPane jsptf = new JScrollPane(tf);

            layout.setRowSpec(row, RowSpec.decode("center:2cm:grow"));
            this.add(jsptf, cc.xy(3, row, "f, f"));
            tf.setText(string1);
            tf.setCaretPosition(0);

        } else {
            JTextArea tf = new JTextArea(string1);
            this.add(tf, cc.xy(3, row));
            tf.setCaretPosition(0);
            tf.setEditable(false);
        }

        // Add radio buttons if the two entries do not have identical fields
        if (!identical[row - 3]) {
            rbg[row - 3] = new ButtonGroup();
            for (int k = 0; k < 3; k++) {
                rb[k][row - 3] = new JRadioButton();
                rbg[row - 3].add(rb[k][row - 3]);
                this.add(rb[k][row - 3], cc.xy(5 + (k * 2), row));
                rb[k][row - 3].addChangeListener(new ChangeListener() {

                    @Override
                    public void stateChanged(ChangeEvent e) {
                        updateAll();
                    }
                });
            }
            if (string1 != null) {
                mergedEntry.setField(field, string1);
                rb[0][row - 3].setSelected(true);
            } else {
                mergedEntry.setField(field, string2);
                rb[2][row - 3].setSelected(true);
            }
        } else {
            mergedEntry.setField(field, string1);
        }
        if (field.equals("abstract")) {
            // Again, treat abstract special
            JTextArea tf = new JTextArea();
            tf.setLineWrap(true);
            tf.setEditable(false);
            JScrollPane jsptf = new JScrollPane(tf);

            this.add(jsptf, cc.xy(11, row, "f, f"));
            tf.setText(string2);
            tf.setCaretPosition(0);

        } else {
            JTextArea tf = new JTextArea(string2);
            this.add(tf, cc.xy(11, row));
            tf.setCaretPosition(0);
            tf.setEditable(false);
        }

        row++;
    }

    this.add(new JSeparator(), cc.xyw(1, row, 11));
    row++;

    // Setup a PreviewPanel and a Bibtex source box for the merged entry
    label = new JLabel(Globals.lang("Merged entry"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    this.add(label, cc.xy(1, row));

    String layoutString = Globals.prefs.get(JabRefPreferences.PREVIEW_0);
    pp = new PreviewPanel(null, mergedEntry, null, new MetaData(), layoutString);
    // JScrollPane jsppp = new JScrollPane(pp);
    this.add(pp, cc.xyw(3, row, 3));

    jta = new JTextArea();
    jta.setLineWrap(true);
    JScrollPane jspta = new JScrollPane(jta);
    this.add(jspta, cc.xyw(9, row, 3));
    jta.setEditable(false);
    StringWriter sw = new StringWriter();
    try {
        mergedEntry.write(sw, new LatexFieldFormatter(), false);
    } catch (IOException ex) {
        System.err.println(Globals.lang("Error in entry" + ": " + ex.getMessage()));
    }
    jta.setText(sw.getBuffer().toString());
    jta.setCaretPosition(0);
    row++;
    this.add(new JSeparator(), cc.xyw(1, row, 11));
    row++;

    // Create buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton cancel = new JButton(Globals.lang("Cancel"));
    cancel.setActionCommand("cancel");
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            buttonPressed(e.getActionCommand());
        }
    });

    JButton newentry = new JButton(Globals.lang("Add new entry and keep both old entries"));
    newentry.setActionCommand("newentry");
    newentry.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            buttonPressed(e.getActionCommand());
        }
    });

    JButton replaceentries = new JButton(Globals.lang("Replace old entries with new entry"));
    replaceentries.setActionCommand("replace");
    replaceentries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            buttonPressed(e.getActionCommand());
        }
    });

    bb.addButton(new JButton[] { replaceentries, newentry, cancel });
    this.add(bb.getPanel(), cc.xyw(1, row, 11));

    // Add some margin around the layout
    layout.appendRow(RowSpec.decode("10px"));
    layout.appendColumn(ColumnSpec.decode("10px"));
    layout.insertRow(1, RowSpec.decode("10px"));
    layout.insertColumn(1, ColumnSpec.decode("10px"));

    pack();

    if (getHeight() > DIM.height) {
        setSize(new Dimension(getWidth(), DIM.height));
    }
    if (getWidth() > DIM.width) {
        setSize(new Dimension(DIM.width, getHeight()));
    }

    // Everything done, allow any action to actually update the merged entry
    doneBuilding = true;

    // Show what we've got
    setVisible(true);

}

From source file:org.siberia.editor.ValidationEditor.java

License:Open Source License

/** set the interval in pixels between button
 *  @param interval a positive integer/* www.  java2s. c o  m*/
 */
public void setButtonsInterval(int interval) {
    if (interval < 0)
        throw new IllegalArgumentException("interval have to be positive");

    this.buttonInterval = interval;

    if (this.validationPanel != null) {
        FormLayout layout = (FormLayout) this.validationPanel.getLayout();
        layout.removeColumn(3);
        layout.insertColumn(3, new ColumnSpec(this.buttonInterval + "px"));

        this.validationPanel.revalidate();
    }
}

From source file:uk.ac.ebi.mnb.dialog.tools.curate.MetaboliteCurator.java

License:Open Source License

@Override
public JPanel getNavigation() {

    JPanel navigation = super.getNavigation();

    FormLayout layout = (FormLayout) navigation.getLayout();

    layout.insertColumn(1, new ColumnSpec(ColumnSpec.LEFT, Sizes.MINIMUM, ColumnSpec.NO_GROW));
    layout.insertColumn(2, new ColumnSpec(ColumnSpec.LEFT, Sizes.PREFERRED, ColumnSpec.DEFAULT_GROW));

    navigation.add(new JButton(new AbstractAction("Skip All") {

        public void actionPerformed(ActionEvent e) {
            skipall = true;/*from   w w w.j  a  v  a 2  s . co  m*/
            setVisible(false);
        }
    }), cc.xy(1, 1));

    return navigation;

}

From source file:uk.ac.ebi.mnb.importer.xls.wizzard.ExcelImportDialog.java

License:Open Source License

@Override
public JPanel getNavigation() {
    JPanel panel = super.getNavigation();

    FormLayout navLayout = (FormLayout) panel.getLayout();

    navLayout.insertColumn(1, new ColumnSpec(Sizes.MINIMUM));
    navLayout.insertColumn(2, new ColumnSpec(Sizes.DLUX2));
    navLayout.insertColumn(3, new ColumnSpec(Sizes.MINIMUM));

    panel.add(new JButton(new PrevPanel()), cc.xy(1, 1));
    panel.add(new JButton(new NextPanel()), cc.xy(3, 1));

    return panel;
}