Example usage for com.jgoodies.forms.builder DefaultFormBuilder append

List of usage examples for com.jgoodies.forms.builder DefaultFormBuilder append

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder DefaultFormBuilder append.

Prototype

public JLabel append(String textWithMnemonic) 

Source Link

Document

Adds a text label to the panel and proceeds to the next column.

Usage

From source file:net.sf.jabref.gui.preftabs.ExternalTab.java

License:Open Source License

public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPreferences prefs) {
    this.prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    fileDir = new JTextField(25);
    bibLocationAsFileDir = new JCheckBox(
            Localization.lang("Allow file links relative to each bib file's location"));
    bibLocAsPrimaryDir = new JCheckBox(
            Localization.lang("Use the bib file location as primary file directory"));
    bibLocAsPrimaryDir.setToolTipText(Localization.lang("When downloading files, or moving linked files to the "
            + "file directory, prefer the bib file location rather than the file directory set above"));
    bibLocationAsFileDir/* w ww . ja va2s . co  m*/
            .addChangeListener(e -> bibLocAsPrimaryDir.setEnabled(bibLocationAsFileDir.isSelected()));
    JButton editFileTypes = new JButton(Localization.lang("Manage external file types"));
    runAutoFileSearch = new JCheckBox(
            Localization.lang("When opening file link, search for matching file if no link is defined"));
    allowFileAutoOpenBrowse = new JCheckBox(
            Localization.lang("Automatically open browse dialog when creating new file link"));
    citeCommand = new JTextField(25);
    regExpTextField = new JTextField(25);
    useRegExpComboBox = new JRadioButton(Localization.lang("Use Regular Expression Search"));
    ItemListener regExpListener = e -> regExpTextField.setEditable(useRegExpComboBox.isSelected());
    useRegExpComboBox.addItemListener(regExpListener);

    editFileTypes.addActionListener(ExternalFileTypeEditor.getAction(prefsDiag));

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(matchExactKeyOnly);
    buttonGroup.add(matchStartsWithKey);
    buttonGroup.add(useRegExpComboBox);

    BrowseAction browse;

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref", "");

    DefaultFormBuilder builder = new DefaultFormBuilder(layout);

    builder.appendSeparator(Localization.lang("External file links"));
    JPanel pan = new JPanel();
    builder.append(pan);
    /**
     * Fix for [ 1749613 ] About translation
     *
     * https://sourceforge.net/tracker/index.php?func=detail&aid=1749613&group_id=92314&atid=600306
     *
     * Cannot really use %0 to refer to the file type, since this ruins translation.
     */
    JLabel lab = new JLabel(Localization.lang("Main file directory") + ':');
    builder.append(lab);
    builder.append(fileDir);
    browse = BrowseAction.buildForDir(this.frame, fileDir);
    builder.append(new JButton(browse));
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(bibLocationAsFileDir, 3);
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(bibLocAsPrimaryDir, 3);
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(matchStartsWithKey, 3);
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(matchExactKeyOnly, 3);
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(useRegExpComboBox);
    builder.append(regExpTextField);

    builder.append(new HelpAction(Localization.lang("Help on Regular Expression Search"),
            HelpFiles.regularExpressionSearchHelp).getHelpButton());
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(runAutoFileSearch, 3);
    builder.nextLine();
    builder.append(new JPanel());
    builder.append(allowFileAutoOpenBrowse);
    builder.nextLine();

    builder.appendSeparator(Localization.lang("Sending of emails"));
    builder.append(new JPanel());
    lab = new JLabel(Localization.lang("Subject for sending an email with references").concat(":"));
    builder.append(lab);
    emailSubject = new JTextField(25);
    builder.append(emailSubject);
    builder.nextLine();
    builder.append(new JPanel());
    openFoldersOfAttachedFiles = new JCheckBox(
            Localization.lang("Automatically open folders of attached files"));
    builder.append(openFoldersOfAttachedFiles);
    builder.nextLine();

    builder.appendSeparator(Localization.lang("External programs"));
    builder.nextLine();

    JPanel butpan = new JPanel();
    butpan.setLayout(new GridLayout(3, 3));
    for (PushToApplication pushToApplication : PushToApplications.APPLICATIONS) {
        addSettingsButton(pushToApplication, butpan);
    }
    builder.append(new JPanel());
    builder.append(butpan, 3);

    builder.nextLine();
    lab = new JLabel(Localization.lang("Cite command") + ':');
    builder.append(pan);
    builder.append(lab);
    builder.append(citeCommand);

    builder.nextLine();
    builder.append(pan);
    builder.append(editFileTypes);

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);

}

From source file:net.sf.jabref.gui.preftabs.GroupsPrefsTab.java

License:Open Source License

public GroupsPrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;

    keywordSeparator.addFocusListener(new FocusListener() {

        @Override//from   ww  w  .  ja  v a2s  . co m
        public void focusGained(FocusEvent e) {
            keywordSeparator.selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // deselection is automatic
        }
    });

    FormLayout layout = new FormLayout("9dlu, pref", //500px",
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, " + "p, 3dlu, p");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.appendSeparator(Localization.lang("View"));
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(showIcons);
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(showDynamic);
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(expandTree);
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(autoShow);
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(autoHide);
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    builder.append(autoAssignGroup);
    builder.nextLine();
    builder.nextLine();
    builder.appendSeparator(Localization.lang("Dynamic groups"));
    builder.nextLine();
    builder.nextLine();
    builder.nextColumn();
    // build subcomponent
    FormLayout layout2 = new FormLayout("left:pref, 2dlu, left:pref", "p, 3dlu, p");
    DefaultFormBuilder builder2 = new DefaultFormBuilder(layout2);
    builder2.append(new JLabel(Localization.lang("Default grouping field") + ":"));
    builder2.append(groupingField);
    builder2.nextLine();
    builder2.nextLine();
    builder2.append(new JLabel(Localization.lang("When adding/removing keywords, separate them by") + ":"));
    builder2.append(keywordSeparator);
    builder.append(builder2.getPanel());

    setLayout(new BorderLayout());
    JPanel panel = builder.getPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(panel, BorderLayout.CENTER);
}

From source file:net.sf.jabref.gui.preftabs.ImportSettingsTab.java

License:Open Source License

public ImportSettingsTab() {
    setLayout(new BorderLayout());
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:3dlu");
    radioButtonNoMeta = new JRadioButton(Localization.lang("Create_blank_entry_linking_the_PDF"));
    radioButtonXmp = new JRadioButton(Localization.lang("Create_entry_based_on_XMP_data"));
    radioButtonPDFcontent = new JRadioButton(Localization.lang("Create_entry_based_on_content"));
    radioButtononlyAttachPDF = new JRadioButton(Localization.lang("Only_attach_PDF"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(radioButtonNoMeta);//from   w w  w  .  j  av  a2s.  c o m
    bg.add(radioButtonXmp);
    bg.add(radioButtonPDFcontent);
    bg.add(radioButtononlyAttachPDF);

    useDefaultPDFImportStyle = new JCheckBox(
            Localization.lang("Always use this PDF import style (and do not ask for each import)"));

    fileNamePattern = new JTextField(50);
    selectFileNamePattern = new JButton(Localization.lang("Choose pattern"));
    selectFileNamePattern.addActionListener(e -> openFilePatternMenu());

    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();

    builder.appendSeparator(Localization.lang("Default import style for drag&drop of PDFs"));
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonNoMeta);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonXmp);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonPDFcontent);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtononlyAttachPDF);
    builder.nextLine();
    builder.append(pan);
    builder.append(useDefaultPDFImportStyle);
    builder.nextLine();

    builder.appendSeparator(Localization.lang("Default PDF file link action"));
    builder.nextLine();
    builder.append(pan);
    JPanel pan2 = new JPanel();
    JLabel lab = new JLabel(Localization.lang("Filename format pattern").concat(":"));
    pan2.add(lab);
    pan2.add(fileNamePattern);
    pan2.add(selectFileNamePattern);
    builder.append(pan2);

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.gui.preftabs.LabelPatternPrefTab.java

License:Open Source License

private void appendKeyGeneratorSettings() {
    ButtonGroup bg = new ButtonGroup();
    bg.add(letterStartA);//  w  w w  .  j  a  v a  2  s  .c  o  m
    bg.add(letterStartB);
    bg.add(alwaysAddLetter);

    // Build a panel for checkbox settings:
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 8dlu, left:pref", "");
    JPanel pan = new JPanel();
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.appendSeparator(Localization.lang("Key generator settings"));

    builder.nextLine();
    builder.append(pan);
    builder.append(autoGenerateOnImport);
    builder.append(letterStartA);
    builder.nextLine();
    builder.append(pan);
    builder.append(warnBeforeOverwriting);
    builder.append(letterStartB);
    builder.nextLine();
    builder.append(pan);
    builder.append(dontOverwrite);
    builder.append(alwaysAddLetter);
    builder.nextLine();
    builder.append(pan);
    builder.append(generateOnSave);
    builder.nextLine();
    builder.append(pan);
    builder.append(Localization.lang("Replace (regular expression)") + ':');
    builder.append(Localization.lang("by") + ':');

    builder.nextLine();
    builder.append(pan);
    builder.append(KeyPatternRegex);
    builder.append(KeyPatternReplacement);

    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    con.gridx = 1;
    con.gridy = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(builder.getPanel(), con);
    add(builder.getPanel());

    dontOverwrite.addChangeListener(e ->
    // Warning before overwriting is only relevant if overwriting can happen:
    warnBeforeOverwriting.setEnabled(!dontOverwrite.isSelected()));
}

From source file:net.sf.jabref.gui.preftabs.NameFormatterTab.java

License:Open Source License

/**
 * Tab to create custom Name Formatters/* w  ww .  j  av  a  2s.  c  o m*/
 *
 */
public NameFormatterTab() {
    setLayout(new BorderLayout());

    TableModel tableModel = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            if (row >= tableRows.size()) {
                return "";
            }
            TableRow tr = tableRows.get(row);
            if (tr == null) {
                return "";
            }
            // Only two columns
            if (column == 0) {
                return tr.getName();
            } else {
                return tr.getFormat();
            }
        }

        @Override
        public String getColumnName(int col) {
            return col == 0 ? Localization.lang("Formatter Name") : Localization.lang("Format String");
        }

        @Override
        public Class<String> getColumnClass(int column) {
            return String.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return true;
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;

            // Make sure the vector is long enough.
            while (row >= tableRows.size()) {
                tableRows.add(new TableRow());
            }

            TableRow rowContent = tableRows.get(row);

            if (col == 0) {
                rowContent.setName(value.toString());
            } else {
                rowContent.setFormat(value.toString());
            }
        }
    };

    table = new JTable(tableModel);
    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setPreferredWidth(140);
    columnModel.getColumn(1).setPreferredWidth(400);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");

    DefaultFormBuilder builder = new DefaultFormBuilder(layout);

    JPanel pan = new JPanel();

    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    table.setPreferredScrollableViewportSize(new Dimension(250, 200));
    scrollPane.setMinimumSize(new Dimension(250, 300));
    scrollPane.setPreferredSize(new Dimension(600, 300));
    tabPanel.add(scrollPane, BorderLayout.CENTER);

    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setFloatable(false);
    toolBar.setBorder(null);
    toolBar.add(new AddRowAction());
    toolBar.add(new DeleteRowAction());
    toolBar.add(new HelpAction(Localization.lang("Help on Name Formatting"), HelpFiles.nameFormatterHelp));

    tabPanel.add(toolBar, BorderLayout.EAST);

    builder.appendSeparator(Localization.lang("Special Name Formatters"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java

License:Open Source License

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *//*from   ww w .  jav a2 s . com*/
public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    this.prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public Object getValueAt(int row, int column) {
            int internalRow = row;
            if (internalRow == 0) {
                return column == 0 ? GUIGlobals.NUMBER_COL : String.valueOf(ncWidth);
            }
            internalRow--;
            if (internalRow >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.get(internalRow);
            if (rowContent == null) {
                return "";
            }
            TableRow tr = (TableRow) rowContent;
            // Only two columns
            if (column == 0) {
                return tr.getName();
            } else {
                return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : "";
            }
        }

        @Override
        public String getColumnName(int col) {
            return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width");
        }

        @Override
        public Class<?> getColumnClass(int column) {
            if (column == 0) {
                return String.class;
            }
            return Integer.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) {
                tableRows.add(new TableRow("", -1));
            }

            if ((row == 0) && (col == 1)) {
                ncWidth = Integer.parseInt(value.toString());
                return;
            }

            TableRow rowContent = tableRows.get(row - 1);

            if (col == 0) {
                rowContent.setName(value.toString());
                if ("".equals(getValueAt(row, 1))) {
                    setValueAt(String.valueOf(GUIGlobals.DEFAULT_FIELD_LENGTH), row, 1);
                }
            } else {
                if (value == null) {
                    rowContent.setLength(-1);
                } else {
                    rowContent.setLength(Integer.parseInt(value.toString()));
                }
            }
        }

    };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setFloatable(false);
    AddRowAction addRow = new AddRowAction();
    DeleteRowAction deleteRow = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    toolBar.setBorder(null);
    toolBar.add(addRow);
    toolBar.add(deleteRow);
    toolBar.addSeparator();
    toolBar.add(moveUp);
    toolBar.add(moveDown);
    tabPanel.add(toolBar, BorderLayout.EAST);

    fileColumn = new JCheckBox(Localization.lang("Show file column"));
    urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Localization.lang("Show URL first"));
    preferDoi = new JRadioButton(Localization.lang("Show DOI first"));
    ButtonGroup preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(arg0 -> {
        preferUrl.setEnabled(urlColumn.isSelected());
        preferDoi.setEnabled(urlColumn.isSelected());
    });
    arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column"));

    Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection();
    String[] fileTypeNames = new String[fileTypes.size()];
    int i = 0;
    for (ExternalFileType fileType : fileTypes) {
        fileTypeNames[i++] = fileType.getName();
    }
    listOfFileColumns = new JList<>(fileTypeNames);
    JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns);
    listOfFileColumns.setVisibleRowCount(3);
    extraFileColumns = new JCheckBox(Localization.lang("Show Extra columns"));
    extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected()));

    /*** begin: special table columns and special fields ***/

    JButton helpButton = new HelpAction(Localization.lang("Help on special fields"),
            HelpFiles.specialFieldsHelp).getHelpButton();

    rankingColumn = new JCheckBox(Localization.lang("Show rank"));
    qualityColumn = new JCheckBox(Localization.lang("Show quality"));
    priorityColumn = new JCheckBox(Localization.lang("Show priority"));
    relevanceColumn = new JCheckBox(Localization.lang("Show relevance"));
    printedColumn = new JCheckBox(Localization.lang("Show printed status"));
    readStatusColumn = new JCheckBox(Localization.lang("Show read status"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords"));
    writeSpecialFields = new JRadioButton(
            Localization.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields"));
    specialFieldsEnabled.addChangeListener(event -> {
        boolean isEnabled = specialFieldsEnabled.isSelected();
        rankingColumn.setEnabled(isEnabled);
        qualityColumn.setEnabled(isEnabled);
        priorityColumn.setEnabled(isEnabled);
        relevanceColumn.setEnabled(isEnabled);
        printedColumn.setEnabled(isEnabled);
        readStatusColumn.setEnabled(isEnabled);
        syncKeywords.setEnabled(isEnabled);
        writeSpecialFields.setEnabled(isEnabled);
    });

    builder.appendSeparator(Localization.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder(
            new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                    "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2));
    specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2));

    specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2));
    specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /*** end: special table columns and special fields ***/

    builder.appendSeparator(Localization.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.gui.preftabs.TablePrefsTab.java

License:Open Source License

/**
 * Customization of external program paths.
 *
 * @param prefs//from w  w  w .j  a v a  2s . c  o  m
 *            a <code>JabRefPreferences</code> value
 */
public TablePrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;
    setLayout(new BorderLayout());

    /**
     * Added Bibtexkey to combobox.
     *
     * [ 1540646 ] default sort order: bibtexkey
     *
     * http://sourceforge.net/tracker/index.php?func=detail&aid=1540646&group_id=92314&atid=600306
     */
    List<String> fieldNames = new ArrayList<>(InternalBibtexFields.getAllFieldNames());
    fieldNames.add(BibEntry.KEY_FIELD);
    Collections.sort(fieldNames);
    String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]);
    priSort = new JComboBox<>(allPlusKey);
    secSort = new JComboBox<>(allPlusKey);
    terSort = new JComboBox<>(allPlusKey);

    autoResizeMode = new JCheckBox(Localization.lang("Fit table horizontally on screen"));

    namesAsIs = new JRadioButton(Localization.lang("Show names unchanged"));
    namesFf = new JRadioButton(Localization.lang("Show 'Firstname Lastname'"));
    namesFl = new JRadioButton(Localization.lang("Show 'Lastname, Firstname'"));
    namesNatbib = new JRadioButton(Localization.lang("Natbib style"));
    noAbbrNames = new JRadioButton(Localization.lang("Do not abbreviate names"));
    abbrNames = new JRadioButton(Localization.lang("Abbreviate names"));
    lastNamesOnly = new JRadioButton(Localization.lang("Show last names only"));

    floatMarked = new JCheckBox(Localization.lang("Float marked entries"));

    priField = new JTextField(10);
    secField = new JTextField(10);
    terField = new JTextField(10);

    numericFields = new JTextField(30);

    priSort.insertItemAt(Localization.lang("<select>"), 0);
    secSort.insertItemAt(Localization.lang("<select>"), 0);
    terSort.insertItemAt(Localization.lang("<select>"), 0);

    priSort.addActionListener(e -> {
        if (priSort.getSelectedIndex() > 0) {
            priField.setText(priSort.getSelectedItem().toString());
            priSort.setSelectedIndex(0);
        }
    });
    secSort.addActionListener(e -> {
        if (secSort.getSelectedIndex() > 0) {
            secField.setText(secSort.getSelectedItem().toString());
            secSort.setSelectedIndex(0);
        }
    });
    terSort.addActionListener(e -> {
        if (terSort.getSelectedIndex() > 0) {
            terField.setText(terSort.getSelectedItem().toString());
            terSort.setSelectedIndex(0);
        }
    });

    ButtonGroup nameStyle = new ButtonGroup();
    nameStyle.add(namesAsIs);
    nameStyle.add(namesNatbib);
    nameStyle.add(namesFf);
    nameStyle.add(namesFl);
    ButtonGroup nameAbbrev = new ButtonGroup();
    nameAbbrev.add(lastNamesOnly);
    nameAbbrev.add(abbrNames);
    nameAbbrev.add(noAbbrNames);
    priDesc = new JCheckBox(Localization.lang("Descending"));
    secDesc = new JCheckBox(Localization.lang("Descending"));
    terDesc = new JCheckBox(Localization.lang("Descending"));

    FormLayout layout = new FormLayout(
            "1dlu, 8dlu, left:pref, 4dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JLabel lab;
    JPanel pan = new JPanel();

    builder.appendSeparator(Localization.lang("Format of author and editor names"));
    DefaultFormBuilder nameBuilder = new DefaultFormBuilder(new FormLayout("left:pref, 8dlu, left:pref", ""));

    nameBuilder.append(namesAsIs);
    nameBuilder.append(noAbbrNames);
    nameBuilder.nextLine();
    nameBuilder.append(namesFf);
    nameBuilder.append(abbrNames);
    nameBuilder.nextLine();
    nameBuilder.append(namesFl);
    nameBuilder.append(lastNamesOnly);
    nameBuilder.nextLine();
    nameBuilder.append(namesNatbib);
    builder.append(pan);
    builder.append(nameBuilder.getPanel());
    builder.nextLine();

    builder.appendSeparator(Localization.lang("Default sort criteria"));
    // Create a new panel with its own FormLayout for these items:
    FormLayout layout2 = new FormLayout("left:pref, 8dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, left:pref", "");
    DefaultFormBuilder builder2 = new DefaultFormBuilder(layout2);
    lab = new JLabel(Localization.lang("Primary sort criterion"));
    builder2.append(lab);
    builder2.append(priSort);
    builder2.append(priField);
    builder2.append(priDesc);
    builder2.nextLine();
    lab = new JLabel(Localization.lang("Secondary sort criterion"));
    builder2.append(lab);
    builder2.append(secSort);
    builder2.append(secField);
    builder2.append(secDesc);
    builder2.nextLine();
    lab = new JLabel(Localization.lang("Tertiary sort criterion"));
    builder2.append(lab);
    builder2.append(terSort);
    builder2.append(terField);
    builder2.append(terDesc);
    builder.nextLine();
    builder.append(pan);
    builder.append(builder2.getPanel());
    builder.nextLine();
    builder.append(pan);
    builder.append(floatMarked);
    builder.nextLine();
    builder.append(pan);
    builder2 = new DefaultFormBuilder(new FormLayout("left:pref, 8dlu, fill:pref", ""));
    builder2.append(Localization.lang("Sort the following fields as numeric fields") + ':');
    builder2.append(numericFields);
    builder.append(builder2.getPanel(), 5);
    builder.nextLine();
    builder.appendSeparator(Localization.lang("General"));
    builder.append(pan);
    builder.append(autoResizeMode);
    builder.nextLine();

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);

    namesNatbib.addChangeListener(e -> {
        abbrNames.setEnabled(!namesNatbib.isSelected());
        lastNamesOnly.setEnabled(!namesNatbib.isSelected());
        noAbbrNames.setEnabled(!namesNatbib.isSelected());
    });
}

From source file:net.sf.jabref.gui.preftabs.XmpPrefsTab.java

License:Open Source License

/**
 * Customization of external program paths.
 *///from  w w w  .j  a v a 2 s .c  o  m
public XmpPrefsTab() {
    setLayout(new BorderLayout());

    TableModel tableModel = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return rowCount;
        }

        @Override
        public int getColumnCount() {
            return 1;
        }

        @Override
        public Object getValueAt(int row, int column) {
            if (row >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.get(row);
            if (rowContent == null) {
                return "";
            }
            return rowContent;
        }

        @Override
        public String getColumnName(int col) {
            return Localization.lang("Field to filter");
        }

        @Override
        public Class<?> getColumnClass(int column) {
            return String.class;
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return true;
        }

        @Override
        public void setValueAt(Object value, int row, int col) {
            tableChanged = true;

            if (tableRows.size() <= row) {
                ((ArrayList<Object>) tableRows).ensureCapacity(row + 1);
            }

            tableRows.set(row, value);
        }

    };

    table = new JTable(tableModel);
    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setPreferredWidth(140);

    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();

    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    table.setPreferredScrollableViewportSize(new Dimension(250, 200));
    scrollPane.setMinimumSize(new Dimension(250, 300));
    tablePanel.add(scrollPane, BorderLayout.CENTER);

    JToolBar toolbar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolbar.setFloatable(false);
    toolbar.setBorder(null);
    toolbar.add(new AddRowAction());
    toolbar.add(new DeleteRowAction());

    tablePanel.add(toolbar, BorderLayout.EAST);

    // Build Prefs Tabs
    builder.appendSeparator(Localization.lang("XMP Export Privacy Settings"));
    builder.nextLine();

    builder.append(pan);
    builder.append(privacyFilterCheckBox);
    builder.nextLine();

    builder.append(pan);
    builder.append(tablePanel);
    builder.nextLine();

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.ImportSettingsTab.java

License:Open Source License

public ImportSettingsTab() {
    setLayout(new BorderLayout());
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:3dlu");
    radioButtonNoMeta = new JRadioButton(Globals.lang("Create_blank_entry_linking_the_PDF"));
    radioButtonXmp = new JRadioButton(Globals.lang("Create_entry_based_on_XMP_data"));
    radioButtonPDFcontent = new JRadioButton(Globals.lang("Create_entry_based_on_content"));
    radioButtonMrDlib = new JRadioButton(Globals.lang("Create_entry_based_on_data_fetched_from") + " Mr.DLib");
    radioButtononlyAttachPDF = new JRadioButton(Globals.lang("Only_attach_PDF"));
    radioButtonUpdateEmptyFields = new JRadioButton(
            Globals.lang("Update_empty_fields_with_data_fetched_from") + " Mr.DLib");
    ButtonGroup bg = new ButtonGroup();
    bg.add(radioButtonNoMeta);/*from  ww w. j  ava  2 s  . c  om*/
    bg.add(radioButtonXmp);
    bg.add(radioButtonPDFcontent);
    bg.add(radioButtonMrDlib);
    bg.add(radioButtononlyAttachPDF);
    bg.add(radioButtonUpdateEmptyFields);

    useDefaultPDFImportStyle = new JCheckBox(
            Globals.lang("Always use this PDF import style (and do not ask for each import)"));

    fileNamePattern = new JTextField(50);
    selectFileNamePattern = new JButton(Globals.lang("Choose pattern"));
    selectFileNamePattern.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            openFilePatternMenu();
        }
    });

    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();

    builder.appendSeparator(Globals.lang("Default import style for drag&drop of PDFs"));
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonNoMeta);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonXmp);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonPDFcontent);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonMrDlib);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtononlyAttachPDF);
    builder.nextLine();
    builder.append(pan);
    builder.append(radioButtonUpdateEmptyFields);
    builder.nextLine();
    builder.append(pan);
    builder.append(useDefaultPDFImportStyle);
    builder.nextLine();

    builder.appendSeparator(Globals.lang("Default PDF file link action"));
    builder.nextLine();
    builder.append(pan);
    JPanel pan2 = new JPanel();
    JLabel lab = new JLabel(Globals.lang("File name format pattern").concat(":"));
    pan2.add(lab);
    pan2.add(fileNamePattern);
    pan2.add(selectFileNamePattern);
    builder.append(pan2);

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:net.sf.jabref.journals.ManageJournalsPanel.java

License:Open Source License

public ManageJournalsPanel(final JabRefFrame frame) {
    this.frame = frame;

    personalFile.setEditable(false);/*from   w  w  w.j a v  a2  s .  c  o m*/

    ButtonGroup group = new ButtonGroup();
    group.add(newFile);
    group.add(oldFile);
    addExtPan.setLayout(new BorderLayout());
    JButton addExt = new JButton(GUIGlobals.getImage("add"));
    addExtPan.add(addExt, BorderLayout.EAST);
    addExtPan.setToolTipText(Globals.lang("Add"));
    //addExtPan.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref", // 4dlu, left:pref, 4dlu",
            "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref");//150dlu");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);

    CellConstraints cc = new CellConstraints();

    /*JLabel description = new JLabel("<HTML>"+Glbals.lang("JabRef can switch journal names between "
    +"abbreviated and full form. Since it knows only a limited number of journal names, "
    +"you may need to add your own definitions.")+"</HTML>");*/
    builder.addSeparator(Globals.lang("Built-in journal list"), cc.xyw(2, 1, 6));
    JLabel description = new JLabel("<HTML>"
            + Globals.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>"
            + Globals.lang("You can add additional journal names by setting up a personal journal list,<br>as "
                    + "well as linking to external journal lists.")
            + "</HTML>");
    description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    builder.add(description, cc.xyw(2, 2, 6));
    JButton viewBuiltin = new JButton(Globals.lang("View"));
    builder.add(viewBuiltin, cc.xy(7, 2));
    builder.addSeparator(Globals.lang("Personal journal list"), cc.xyw(2, 3, 6));

    //builder.add(description, cc.xyw(2,1,6));
    builder.add(newFile, cc.xy(3, 4));
    builder.add(newNameTf, cc.xy(5, 4));
    JButton browseNew = new JButton(Globals.lang("Browse"));
    builder.add(browseNew, cc.xy(7, 4));
    builder.add(oldFile, cc.xy(3, 5));
    builder.add(personalFile, cc.xy(5, 5));
    //BrowseAction action = new BrowseAction(personalFile, false);
    //JButton browse = new JButton(Globals.lang("Browse"));
    //browse.addActionListener(action);
    JButton browseOld = new JButton(Globals.lang("Browse"));
    builder.add(browseOld, cc.xy(7, 5));

    userPanel.setLayout(new BorderLayout());
    //builtInTable = new JTable(Globals.journalAbbrev.getTableModel());
    builder.add(userPanel, cc.xyw(2, 6, 4));
    ButtonStackBuilder butBul = new ButtonStackBuilder();
    butBul.addButton(add);
    butBul.addButton(remove);

    butBul.addGlue();
    builder.add(butBul.getPanel(), cc.xy(7, 6));

    builder.addSeparator(Globals.lang("External files"), cc.xyw(2, 8, 6));
    externalFilesPanel.setLayout(new BorderLayout());
    //builder.add(/*new JScrollPane(*/externalFilesPanel/*)*/, cc.xyw(2,8,6));

    setLayout(new BorderLayout());
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));//createMatteBorder(1,1,1,1,Color.green));
    add(builder.getPanel(), BorderLayout.NORTH);
    add(externalFilesPanel, BorderLayout.CENTER);
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    JButton ok = new JButton(Globals.lang("Ok"));
    bb.addButton(ok);
    JButton cancel = new JButton(Globals.lang("Cancel"));
    bb.addButton(cancel);
    bb.addUnrelatedGap();
    JButton help = new JButton(Globals.lang("Help"));
    bb.addButton(help);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    dialog = new JDialog(frame, Globals.lang("Journal abbreviations"), false);
    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);

    //add(new JScrollPane(builtInTable), BorderLayout.CENTER);

    // Set up panel for editing a single journal, to be used in a dialog box:
    FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "");
    DefaultFormBuilder builder2 = new DefaultFormBuilder(layout2);
    builder2.append(Globals.lang("Journal name"));
    builder2.append(nameTf);
    builder2.nextLine();
    builder2.append(Globals.lang("ISO abbreviation"));
    builder2.append(abbrTf);
    journalEditPanel = builder2.getPanel();

    viewBuiltin.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JournalAbbreviationRepository abbr = new JournalAbbreviationRepository();
            abbr.readJournalListFromResource(Globals.JOURNALS_FILE_BUILTIN);
            JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbrev));
            JScrollPane pane = new JScrollPane(table);
            JOptionPane.showMessageDialog(null, pane, Globals.lang("Journal list preview"),
                    JOptionPane.INFORMATION_MESSAGE);
        }
    });

    browseNew.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            File old = null;
            if (!newNameTf.getText().equals("")) {
                old = new File(newNameTf.getText());
            }
            String name = FileDialogs.getNewFile(frame, old, null, JFileChooser.SAVE_DIALOG, false);
            if (name != null) {
                newNameTf.setText(name);
                newFile.setSelected(true);
            }
        }
    });
    browseOld.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            File old = null;
            if (!personalFile.getText().equals("")) {
                old = new File(personalFile.getText());
            }
            String name = FileDialogs.getNewFile(frame, old, null, JFileChooser.OPEN_DIALOG, false);
            if (name != null) {
                personalFile.setText(name);
                oldFile.setSelected(true);
                oldFile.setEnabled(true);
                setupUserTable();
            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (readyToClose()) {
                try {
                    storeSettings();
                    dialog.dispose();
                } catch (FileNotFoundException ex) {
                    JOptionPane.showMessageDialog(null,
                            Globals.lang("Error opening file") + ": " + ex.getMessage(),
                            Globals.lang("Error opening file"), JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });
    help.addActionListener(new HelpAction(Globals.helpDiag, GUIGlobals.journalAbbrHelp));

    AbstractAction cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };
    cancel.addActionListener(cancelAction);

    add.addActionListener(tableModel);
    remove.addActionListener(tableModel);
    addExt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            externals.add(new ExternalFileEntry());
            buildExternalsPanel();
        }
    });

    // Key bindings:
    ActionMap am = getActionMap();
    InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", cancelAction);

    //dialog.pack();
    int xSize = getPreferredSize().width;
    dialog.setSize(xSize + 10, 700);
}