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.journals.ManageJournalsPanel.java

License:Open Source License

private void buildExternalsPanel() {

    DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("fill:pref:grow", ""));
    for (ExternalFileEntry efe : externals) {
        builder.append(efe.getPanel());
        builder.nextLine();//ww  w.  j  a v  a  2s.c o  m
    }
    builder.append(Box.createVerticalGlue());
    builder.nextLine();
    builder.append(addExtPan);
    builder.nextLine();
    builder.append(Box.createVerticalGlue());

    //builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green));
    //externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    JScrollPane pane = new JScrollPane(builder.getPanel());
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    externalFilesPanel.setMinimumSize(new Dimension(400, 400));
    externalFilesPanel.setPreferredSize(new Dimension(400, 400));
    externalFilesPanel.removeAll();
    externalFilesPanel.add(pane, BorderLayout.CENTER);
    externalFilesPanel.revalidate();
    externalFilesPanel.repaint();

}

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

License:Open Source License

/**
 * Tab to create custom Name Formatters//from w  w w .ja v  a2s.  c o  m
 * 
 */
public NameFormatterTab(HelpDialog helpDialog) {
    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) {
            if (row >= tableRows.size()) {
                return "";
            }
            TableRow tr = tableRows.elementAt(row);
            if (tr == null) {
                return "";
            }
            switch (column) {
            case 0:
                return tr.name;
            case 1:
                return tr.format;
            }
            return null; // Unreachable.
        }

        @Override
        public String getColumnName(int col) {
            return (col == 0 ? Globals.lang("Formatter Name") : Globals.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.elementAt(row);

            if (col == 0) {
                rowContent.name = value.toString();
            } else {
                rowContent.format = value.toString();
            }
        }
    };

    table = new JTable(tm);
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.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 sp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    table.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    sp.setPreferredSize(new Dimension(600, 300));
    tabPanel.add(sp, BorderLayout.CENTER);

    JToolBar tlb = new JToolBar(SwingConstants.VERTICAL);
    tlb.setFloatable(false);
    tlb.setBorder(null);
    tlb.add(new AddRowAction());
    tlb.add(new DeleteRowAction());
    tlb.add(new HelpAction(helpDialog, GUIGlobals.nameFormatterHelp, "Help on Name Formatting",
            GUIGlobals.getIconUrl("helpSmall")));

    tabPanel.add(tlb, BorderLayout.EAST);

    builder.appendSeparator(Globals.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.oo.AutoDetectPaths.java

License:Open Source License

private boolean autoDetectPaths() {

    if (Globals.ON_WIN) {
        List<File> progFiles = AutoDetectPaths.findProgramFilesDir();
        File sOffice = null;//from w ww .  jav  a 2 s. c o m
        if (fileSearchCancelled) {
            return false;
        }
        for (File dir : progFiles) {
            sOffice = findFileDir(dir, "soffice.exe");
            if (sOffice != null) {
                break;
            }
        }
        if (sOffice == null) {
            JOptionPane.showMessageDialog(parent, Globals.lang(
                    "Unable to autodetect OpenOffice installation. Please choose the installation directory manually."),
                    Globals.lang("Could not find OpenOffice installation"), JOptionPane.INFORMATION_MESSAGE);
            JFileChooser jfc = new JFileChooser(new File("C:\\"));
            jfc.setDialogType(JFileChooser.OPEN_DIALOG);
            jfc.setFileFilter(new javax.swing.filechooser.FileFilter() {

                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }

                @Override
                public String getDescription() {
                    return Globals.lang("Directories");
                }
            });
            jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jfc.showOpenDialog(parent);
            if (jfc.getSelectedFile() != null) {
                sOffice = jfc.getSelectedFile();
            }
        }
        if (sOffice == null) {
            return false;
        }

        Globals.prefs.put("ooExecutablePath", new File(sOffice, "soffice.exe").getPath());
        File unoil = findFileDir(sOffice.getParentFile(), "unoil.jar");
        if (fileSearchCancelled) {
            return false;
        }
        File jurt = findFileDir(sOffice.getParentFile(), "jurt.jar");
        if (fileSearchCancelled) {
            return false;
        }
        if ((unoil != null) && (jurt != null)) {
            Globals.prefs.put("ooUnoilPath", unoil.getPath());
            Globals.prefs.put("ooJurtPath", jurt.getPath());
            return true;
        } else {
            return false;
        }

    } else if (Globals.ON_MAC) {
        File rootDir = new File("/Applications");
        File[] files = rootDir.listFiles();
        for (File file : files) {
            if (file.isDirectory() && file.getName().equals("OpenOffice.org.app")) {
                rootDir = file;
                //System.out.println("Setting starting dir to: "+file.getPath());
                break;
            }
        }
        //System.out.println("Searching for soffice.bin");
        File sOffice = findFileDir(rootDir, "soffice.bin");
        //System.out.println("Found: "+(sOffice != null ? sOffice.getPath() : "-"));
        if (fileSearchCancelled) {
            return false;
        }
        if (sOffice != null) {
            Globals.prefs.put("ooExecutablePath", new File(sOffice, "soffice.bin").getPath());
            //System.out.println("Searching for unoil.jar");
            File unoil = findFileDir(rootDir, "unoil.jar");
            //System.out.println("Found: "+(unoil != null ? unoil.getPath(): "-"));
            if (fileSearchCancelled) {
                return false;
            }
            //System.out.println("Searching for jurt.jar");
            File jurt = findFileDir(rootDir, "jurt.jar");
            //System.out.println("Found: "+(jurt != null ? jurt.getPath(): "-"));
            if (fileSearchCancelled) {
                return false;
            }
            if ((unoil != null) && (jurt != null)) {
                Globals.prefs.put("ooUnoilPath", unoil.getPath());
                Globals.prefs.put("ooJurtPath", jurt.getPath());
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        // Linux:
        String usrRoot = "/usr/lib";
        File inUsr = findFileDir(new File("/usr/lib"), "soffice");
        if (fileSearchCancelled) {
            return false;
        }
        if (inUsr == null) {
            inUsr = findFileDir(new File("/usr/lib64"), "soffice");
            if (inUsr != null) {
                usrRoot = "/usr/lib64";
            }
        }

        if (fileSearchCancelled) {
            return false;
        }
        File inOpt = findFileDir(new File("/opt"), "soffice");
        if (fileSearchCancelled) {
            return false;
        }
        if ((inUsr != null) && (inOpt == null)) {
            return setupPreferencesForOO(usrRoot, inUsr);
        } else if ((inOpt != null) && (inUsr == null)) {
            Globals.prefs.put("ooExecutablePath", new File(inOpt, "soffice.bin").getPath());
            File unoil = findFileDir(new File("/opt"), "unoil.jar");
            File jurt = findFileDir(new File("/opt"), "jurt.jar");
            if ((unoil != null) && (jurt != null)) {
                Globals.prefs.put("ooUnoilPath", unoil.getPath());
                Globals.prefs.put("ooJurtPath", jurt.getPath());
                return true;
            } else {
                return false;
            }
        } else if (inOpt != null) { // Found both
            JRadioButton optRB = new JRadioButton(inOpt.getPath(), true);
            JRadioButton usrRB = new JRadioButton(inUsr.getPath(), false);
            ButtonGroup bg = new ButtonGroup();
            bg.add(optRB);
            bg.add(usrRB);
            DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("left:pref", ""));
            b.append(Globals
                    .lang("Found more than one OpenOffice executable. Please choose which one to connect to:"));
            b.append(optRB);
            b.append(usrRB);
            int answer = JOptionPane.showConfirmDialog(null, b.getPanel(),
                    Globals.lang("Choose OpenOffice executable"), JOptionPane.OK_CANCEL_OPTION);
            if (answer == JOptionPane.CANCEL_OPTION) {
                return false;
            } else {
                if (optRB.isSelected()) {
                    return setupPreferencesForOO("/opt", inOpt);
                } else {
                    return setupPreferencesForOO(usrRoot, inUsr);
                }

            }
        } else {
            return false;
        }
    }

}

From source file:net.sf.jabref.oo.OpenOfficePanel.java

License:Open Source License

private void initPanel() {

    OpenOfficePanel.useDefaultAuthoryearStyle = Globals.prefs.getBoolean("ooUseDefaultAuthoryearStyle");
    OpenOfficePanel.useDefaultNumericalStyle = Globals.prefs.getBoolean("ooUseDefaultNumericalStyle");
    Action al = new AbstractAction() {

        @Override//from  ww w. ja v  a 2s.  c o  m
        public void actionPerformed(ActionEvent e) {
            connect(true);
        }
    };
    OpenOfficePanel.connect.addActionListener(al);

    OpenOfficePanel.manualConnect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            connect(false);
        }
    });
    OpenOfficePanel.selectDocument.setToolTipText(Globals.lang("Select which open Writer document to work on"));
    OpenOfficePanel.selectDocument.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                OpenOfficePanel.ooBase.selectDocument();
                OpenOfficePanel.frame.output(Globals.lang("Connected to document") + ": "
                        + OpenOfficePanel.ooBase.getCurrentDocumentTitle());
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(OpenOfficePanel.frame, ex.getMessage(), Globals.lang("Error"),
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    OpenOfficePanel.setStyleFile.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (styleDialog == null) {
                styleDialog = new StyleSelectDialog(OpenOfficePanel.frame, OpenOfficePanel.styleFile);
            }
            styleDialog.setVisible(true);
            if (styleDialog.isOkPressed()) {
                OpenOfficePanel.useDefaultAuthoryearStyle = Globals.prefs
                        .getBoolean("ooUseDefaultAuthoryearStyle");
                OpenOfficePanel.useDefaultNumericalStyle = Globals.prefs
                        .getBoolean("ooUseDefaultNumericalStyle");
                OpenOfficePanel.styleFile = Globals.prefs.get("ooBibliographyStyleFile");
                try {
                    readStyleFile();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });

    OpenOfficePanel.pushEntries.setToolTipText(Globals.lang("Cite selected entries"));
    OpenOfficePanel.pushEntries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pushEntries(true, true, false);
        }
    });
    OpenOfficePanel.pushEntriesInt.setToolTipText(Globals.lang("Cite selected entries with in-text citation"));
    OpenOfficePanel.pushEntriesInt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pushEntries(false, true, false);
        }
    });
    OpenOfficePanel.pushEntriesEmpty.setToolTipText(
            Globals.lang("Insert a citation without text (the entry will appear in the reference list)"));
    OpenOfficePanel.pushEntriesEmpty.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            pushEntries(false, false, false);
        }
    });
    OpenOfficePanel.pushEntriesAdvanced
            .setToolTipText(Globals.lang("Cite selected entries with extra information"));
    OpenOfficePanel.pushEntriesAdvanced.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            pushEntries(false, true, true);
        }
    });

    OpenOfficePanel.focus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            OpenOfficePanel.ooBase.setFocus();
        }
    });
    OpenOfficePanel.update.setToolTipText(Globals.lang("Ensure that the bibliography is up-to-date"));
    Action updateAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                try {
                    if (OpenOfficePanel.style == null) {
                        readStyleFile();
                    } else {
                        OpenOfficePanel.style.ensureUpToDate();
                    }
                } catch (Throwable ex) {
                    JOptionPane.showMessageDialog(OpenOfficePanel.frame, Globals.lang(
                            "You must select either a valid style file, or use one of the default styles."),
                            Globals.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE);
                    return;
                }

                OpenOfficePanel.ooBase.updateSortedReferenceMarks();

                java.util.List<BibtexDatabase> databases = getBaseList();
                java.util.List<String> unresolvedKeys = OpenOfficePanel.ooBase.refreshCiteMarkers(databases,
                        OpenOfficePanel.style);
                OpenOfficePanel.ooBase.rebuildBibTextSection(databases, OpenOfficePanel.style);
                //ooBase.sync(frame.basePanel().database(), style);
                if (unresolvedKeys.size() > 0) {
                    JOptionPane.showMessageDialog(OpenOfficePanel.frame, Globals.lang(
                            "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                            unresolvedKeys.get(0)), Globals.lang("Unable to synchronize bibliography"),
                            JOptionPane.ERROR_MESSAGE);
                }
            } catch (UndefinedCharacterFormatException ex) {
                reportUndefinedCharacterFormat(ex);
            } catch (UndefinedParagraphFormatException ex) {
                reportUndefinedParagraphFormat(ex);
            } catch (ConnectionLostException ex) {
                showConnectionLostErrorMessage();
            } catch (BibtexEntryNotFoundException ex) {
                JOptionPane.showMessageDialog(OpenOfficePanel.frame, Globals.lang(
                        "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                        ex.getBibtexKey()), Globals.lang("Unable to synchronize bibliography"),
                        JOptionPane.ERROR_MESSAGE);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    };
    OpenOfficePanel.update.addActionListener(updateAction);

    OpenOfficePanel.insertFullRef.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                insertFullRefs();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    OpenOfficePanel.merge
            .setToolTipText(Globals.lang("Combine pairs of citations that are separated by spaces only"));
    OpenOfficePanel.merge.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                OpenOfficePanel.ooBase.combineCiteMarkers(getBaseList(), OpenOfficePanel.style);
            } catch (UndefinedCharacterFormatException e) {
                reportUndefinedCharacterFormat(e);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });

    OpenOfficePanel.settingsB.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            showSettingsPopup();
        }
    });

    OpenOfficePanel.help.addActionListener(new HelpAction(Globals.helpDiag, "OpenOfficeIntegration.html"));

    OpenOfficePanel.manageCitations.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                CitationManager cm = new CitationManager(OpenOfficePanel.frame, OpenOfficePanel.ooBase);
                cm.showDialog();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    OpenOfficePanel.test.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                //pushEntries(false, true, true);

                //ooBase.testFrameHandling();

                //ooBase.combineCiteMarkers(frame.basePanel().database(), style);
                //insertUsingBST();
                //ooBase.testFootnote();
                //ooBase.refreshCiteMarkers(frame.basePanel().database(), style);
                //ooBase.createBibTextSection(true);
                //ooBase.clearBibTextSectionContent();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });

    OpenOfficePanel.selectDocument.setEnabled(false);
    OpenOfficePanel.pushEntries.setEnabled(false);
    OpenOfficePanel.pushEntriesInt.setEnabled(false);
    OpenOfficePanel.pushEntriesEmpty.setEnabled(false);
    OpenOfficePanel.pushEntriesAdvanced.setEnabled(false);
    OpenOfficePanel.focus.setEnabled(false);
    OpenOfficePanel.update.setEnabled(false);
    OpenOfficePanel.insertFullRef.setEnabled(false);
    OpenOfficePanel.merge.setEnabled(false);
    OpenOfficePanel.manageCitations.setEnabled(false);
    OpenOfficePanel.test.setEnabled(false);
    diag = new JDialog((JFrame) null, "OpenOffice panel", false);

    DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow",
            //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu"));
            "p,p,p,p,p,p,p,p,p,p"));

    //ButtonBarBuilder bb = new ButtonBarBuilder();
    DefaultFormBuilder bb = new DefaultFormBuilder(
            new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
                    + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", ""));
    bb.append(OpenOfficePanel.connect);
    bb.append(OpenOfficePanel.manualConnect);
    bb.append(OpenOfficePanel.selectDocument);
    bb.append(OpenOfficePanel.update);
    bb.append(OpenOfficePanel.help);

    //b.append(connect);
    //b.append(manualConnect);
    //b.append(selectDocument);
    b.append(bb.getPanel());
    b.append(OpenOfficePanel.setStyleFile);
    b.append(OpenOfficePanel.pushEntries);
    b.append(OpenOfficePanel.pushEntriesInt);
    b.append(OpenOfficePanel.pushEntriesAdvanced);
    b.append(OpenOfficePanel.pushEntriesEmpty);
    b.append(OpenOfficePanel.merge);
    b.append(OpenOfficePanel.manageCitations);
    b.append(OpenOfficePanel.settingsB);
    //b.append(focus);
    //b.append(update);

    //b.append(insertFullRef);
    //b.append(test);
    //diag.getContentPane().add(b.getPanel(), BorderLayout.CENTER);

    JPanel content = new JPanel();
    comp.setContentContainer(content);
    content.setLayout(new BorderLayout());
    content.add(b.getPanel(), BorderLayout.CENTER);

    OpenOfficePanel.frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(Globals.prefs.getKey("Refresh OO"), "Refresh OO");
    OpenOfficePanel.frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction);

    //diag.pack();
    //diag.setVisible(true);
}

From source file:net.sf.jabref.oo.OpenOfficePanel.java

License:Open Source License

private void showConnectDialog() {
    dialogOkPressed = false;/*  w w  w.ja v  a 2s .  co m*/
    final JDialog diag = new JDialog(OpenOfficePanel.frame, Globals.lang("Set connection parameters"), true);
    final JTextField ooPath = new JTextField(30);
    JButton browseOOPath = new JButton(Globals.lang("Browse"));
    ooPath.setText(Globals.prefs.get("ooPath"));
    final JTextField ooExec = new JTextField(30);
    JButton browseOOExec = new JButton(Globals.lang("Browse"));
    browseOOExec.addActionListener(BrowseAction.buildForFile(ooExec));
    final JTextField ooJars = new JTextField(30);
    JButton browseOOJars = new JButton(Globals.lang("Browse"));
    browseOOJars.addActionListener(BrowseAction.buildForDir(ooJars));
    ooExec.setText(Globals.prefs.get("ooExecutablePath"));
    ooJars.setText(Globals.prefs.get("ooJarsPath"));
    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", ""));
    if (Globals.ON_WIN || Globals.ON_MAC) {
        builder.append(Globals.lang("Path to OpenOffice directory"));
        builder.append(ooPath);
        builder.append(browseOOPath);
        builder.nextLine();
    } else {
        builder.append(Globals.lang("Path to OpenOffice executable"));
        builder.append(ooExec);
        builder.append(browseOOExec);
        builder.nextLine();

        builder.append(Globals.lang("Path to OpenOffice library dir"));
        builder.append(ooJars);
        builder.append(browseOOJars);
        builder.nextLine();
    }

    ButtonBarBuilder bb = new ButtonBarBuilder();
    JButton ok = new JButton(Globals.lang("Ok"));
    JButton cancel = new JButton(Globals.lang("Cancel"));
    //JButton auto = new JButton(Globals.lang("Autodetect"));
    ActionListener tfListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText(), true);
            diag.dispose();
        }
    };

    ooPath.addActionListener(tfListener);
    ooExec.addActionListener(tfListener);
    ooJars.addActionListener(tfListener);
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText(), true);
            dialogOkPressed = true;
            diag.dispose();
        }
    });
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    });
    bb.addGlue();
    bb.addRelatedGap();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    diag.pack();
    diag.setLocationRelativeTo(OpenOfficePanel.frame);
    diag.setVisible(true);

}

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

License:Open Source License

private void initPanel() {

    useDefaultAuthoryearStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE);
    useDefaultNumericalStyle = Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE);

    connect.addActionListener(e -> connect(true));
    manualConnect.addActionListener(e -> connect(false));

    selectDocument.setToolTipText(Localization.lang("Select which open Writer document to work on"));
    selectDocument.addActionListener(e -> {

        try {/*from   ww w. j  a v  a 2 s .  c om*/
            ooBase.selectDocument();
            frame.output(Localization.lang("Connected to document") + ": "
                    + ooBase.getCurrentDocumentTitle().orElse(""));
        } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException
                | NoSuchElementException | NoDocumentException ex) {
            JOptionPane.showMessageDialog(frame, ex.getMessage(), Localization.lang("Error"),
                    JOptionPane.ERROR_MESSAGE);
            LOGGER.warn("Problem connecting", ex);
        }

    });

    setStyleFile.addActionListener(e -> {

        if (styleDialog == null) {
            styleDialog = new StyleSelectDialog(frame, styleFile);
        }
        styleDialog.setVisible(true);
        if (styleDialog.isOkPressed()) {
            useDefaultAuthoryearStyle = Globals.prefs
                    .getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE);
            useDefaultNumericalStyle = Globals.prefs
                    .getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE);
            styleFile = Globals.prefs.get(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE);
            try {
                readStyleFile();
            } catch (IOException ex) {
                LOGGER.warn("Could not read style file", ex);
            }
        }

    });

    pushEntries.setToolTipText(Localization.lang("Cite selected entries between parenthesis"));
    pushEntries.addActionListener(e -> pushEntries(true, true, false));
    pushEntriesInt.setToolTipText(Localization.lang("Cite selected entries with in-text citation"));
    pushEntriesInt.addActionListener(e -> pushEntries(false, true, false));
    pushEntriesEmpty.setToolTipText(
            Localization.lang("Insert a citation without text (the entry will appear in the reference list)"));
    pushEntriesEmpty.addActionListener(e -> pushEntries(false, false, false));
    pushEntriesAdvanced.setToolTipText(Localization.lang("Cite selected entries with extra information"));
    pushEntriesAdvanced.addActionListener(e -> pushEntries(false, true, true));

    update.setToolTipText(Localization.lang("Ensure that the bibliography is up-to-date"));
    Action updateAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (style == null) {
                    readStyleFile();
                } else {
                    style.ensureUpToDate();
                }

                ooBase.updateSortedReferenceMarks();

                List<BibDatabase> databases = getBaseList();
                List<String> unresolvedKeys = ooBase.refreshCiteMarkers(databases, style);
                ooBase.rebuildBibTextSection(databases, style);
                if (!unresolvedKeys.isEmpty()) {
                    JOptionPane.showMessageDialog(frame, Localization.lang(
                            "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                            unresolvedKeys.get(0)), Localization.lang("Unable to synchronize bibliography"),
                            JOptionPane.ERROR_MESSAGE);
                }
            } catch (UndefinedCharacterFormatException ex) {
                reportUndefinedCharacterFormat(ex);
            } catch (UndefinedParagraphFormatException ex) {
                reportUndefinedParagraphFormat(ex);
            } catch (ConnectionLostException ex) {
                showConnectionLostErrorMessage();
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang(
                                "You must select either a valid style file, or use one of the default styles."),
                        Localization.lang("No valid style file defined"), JOptionPane.ERROR_MESSAGE);
                LOGGER.warn("Problem with style file", ex);
                return;
            } catch (BibEntryNotFoundException ex) {
                JOptionPane.showMessageDialog(frame, Localization.lang(
                        "Your OpenOffice document references the BibTeX key '%0', which could not be found in your current database.",
                        ex.getBibtexKey()), Localization.lang("Unable to synchronize bibliography"),
                        JOptionPane.ERROR_MESSAGE);
                LOGGER.debug("BibEntry not found", ex);
            } catch (Exception ex) {
                LOGGER.warn("Could not update bibliography", ex);
            }
        }
    };
    update.addActionListener(updateAction);

    merge.setToolTipText(Localization.lang("Combine pairs of citations that are separated by spaces only"));
    merge.addActionListener(e -> {
        try {
            ooBase.combineCiteMarkers(getBaseList(), style);
        } catch (UndefinedCharacterFormatException ex) {
            reportUndefinedCharacterFormat(ex);
        } catch (Exception ex) {
            LOGGER.warn("Problem combining cite markers", ex);
        }

    });
    settingsB.addActionListener(e -> showSettingsPopup());
    manageCitations.addActionListener(e -> {
        try {
            CitationManager cm = new CitationManager(frame, ooBase);
            cm.showDialog();
        } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) {
            LOGGER.warn("Problem showing citation manager", ex);
        }

    });

    selectDocument.setEnabled(false);
    pushEntries.setEnabled(false);
    pushEntriesInt.setEnabled(false);
    pushEntriesEmpty.setEnabled(false);
    pushEntriesAdvanced.setEnabled(false);
    update.setEnabled(false);
    merge.setEnabled(false);
    manageCitations.setEnabled(false);
    diag = new JDialog((JFrame) null, "OpenOffice panel", false);

    DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("fill:pref:grow",
            //"p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu,p,0dlu"));
            "p,p,p,p,p,p,p,p,p,p"));

    //ButtonBarBuilder bb = new ButtonBarBuilder();
    DefaultFormBuilder bb = new DefaultFormBuilder(
            new FormLayout("fill:pref:grow, 1dlu, fill:pref:grow, 1dlu, fill:pref:grow, "
                    + "1dlu, fill:pref:grow, 1dlu, fill:pref:grow", ""));
    bb.append(connect);
    bb.append(manualConnect);
    bb.append(selectDocument);
    bb.append(update);
    bb.append(help);
    b.append(bb.getPanel());
    b.append(setStyleFile);
    b.append(pushEntries);
    b.append(pushEntriesInt);
    b.append(pushEntriesAdvanced);
    b.append(pushEntriesEmpty);
    b.append(merge);
    b.append(manageCitations);
    b.append(settingsB);

    JPanel content = new JPanel();
    comp.setContentContainer(content);
    content.setLayout(new BorderLayout());
    content.add(b.getPanel(), BorderLayout.CENTER);

    frame.getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(Globals.getKeyPrefs().getKey(KeyBinding.REFRESH_OO), "Refresh OO");
    frame.getTabbedPane().getActionMap().put("Refresh OO", updateAction);

}

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

License:Open Source License

private void showConnectDialog() {

    dialogOkPressed = false;//www.j  av a 2 s  .  c  o  m
    final JDialog cDiag = new JDialog(frame, Localization.lang("Set connection parameters"), true);
    final JTextField ooPath = new JTextField(30);
    JButton browseOOPath = new JButton(Localization.lang("Browse"));
    ooPath.setText(Globals.prefs.get(JabRefPreferences.OO_PATH));
    browseOOPath.addActionListener(BrowseAction.buildForDir(ooPath));

    final JTextField ooExec = new JTextField(30);
    JButton browseOOExec = new JButton(Localization.lang("Browse"));
    ooExec.setText(Globals.prefs.get(JabRefPreferences.OO_EXECUTABLE_PATH));
    browseOOExec.addActionListener(BrowseAction.buildForFile(ooExec));

    final JTextField ooJars = new JTextField(30);
    JButton browseOOJars = new JButton(Localization.lang("Browse"));
    browseOOJars.addActionListener(BrowseAction.buildForDir(ooJars));
    ooJars.setText(Globals.prefs.get(JabRefPreferences.OO_JARS_PATH));

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", ""));
    if (OS.WINDOWS || OS.OS_X) {
        builder.append(Localization.lang("Path to OpenOffice directory"));
        builder.append(ooPath);
        builder.append(browseOOPath);
        builder.nextLine();
    } else {
        builder.append(Localization.lang("Path to OpenOffice executable"));
        builder.append(ooExec);
        builder.append(browseOOExec);
        builder.nextLine();

        builder.append(Localization.lang("Path to OpenOffice library dir"));
        builder.append(ooJars);
        builder.append(browseOOJars);
        builder.nextLine();
    }

    ButtonBarBuilder bb = new ButtonBarBuilder();
    JButton ok = new JButton(Localization.lang("OK"));
    JButton cancel = new JButton(Localization.lang("Cancel"));
    ActionListener tfListener = (e -> {

        updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText());
        cDiag.dispose();

    });

    ooPath.addActionListener(tfListener);
    ooExec.addActionListener(tfListener);
    ooJars.addActionListener(tfListener);
    ok.addActionListener(e -> {
        updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText());
        dialogOkPressed = true;
        cDiag.dispose();
    });

    cancel.addActionListener(e -> cDiag.dispose());

    bb.addGlue();
    bb.addRelatedGap();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    cDiag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    cDiag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    cDiag.pack();
    cDiag.setLocationRelativeTo(frame);
    cDiag.setVisible(true);

}

From source file:net.sf.jabref.sql.DBConnectDialog.java

License:Open Source License

/** Creates a new instance of DBConnectDialog */
public DBConnectDialog(JFrame parent, DBStrings dbs) {

    super(parent, Globals.lang("Connect to SQL database"), true);

    this.setResizable(false);
    this.setLocationRelativeTo(parent);

    dbStrings = dbs;//w  w w.  ja  va  2s .  c  om

    // build collections of components
    ArrayList<JLabel> lhs = new ArrayList<JLabel>();
    JLabel lblServerType = new JLabel();
    lhs.add(lblServerType);
    JLabel lblServerHostname = new JLabel();
    lhs.add(lblServerHostname);
    JLabel lblDatabase = new JLabel();
    lhs.add(lblDatabase);
    JLabel lblUsername = new JLabel();
    lhs.add(lblUsername);
    JLabel lblPassword = new JLabel();
    lhs.add(lblPassword);

    ArrayList<JComponent> rhs = new ArrayList<JComponent>();
    rhs.add(cmbServerType);
    rhs.add(txtServerHostname);
    rhs.add(txtDatabase);
    rhs.add(txtUsername);
    rhs.add(pwdPassword);

    // setup label text
    lblServerType.setText(Globals.lang("Server Type :"));
    lblServerHostname.setText(Globals.lang("Server Hostname :"));
    lblDatabase.setText(Globals.lang("Database :"));
    lblUsername.setText(Globals.lang("Username :"));
    lblPassword.setText(Globals.lang("Password :"));

    // set label text alignment
    for (JLabel label : lhs) {
        label.setHorizontalAlignment(SwingConstants.RIGHT);
    }

    // set button text
    JButton btnConnect = new JButton();
    btnConnect.setText(Globals.lang("Connect"));
    JButton btnCancel = new JButton();
    btnCancel.setText(Globals.lang("Cancel"));

    // init input fields to current DB strings
    String srvSel = dbStrings.getServerType();
    String[] srv = dbStrings.getServerTypes();
    for (String aSrv : srv) {
        cmbServerType.addItem(aSrv);
    }

    cmbServerType.setSelectedItem(srvSel);
    txtServerHostname.setText(dbStrings.getServerHostname());
    txtDatabase.setText(dbStrings.getDatabase());
    txtUsername.setText(dbStrings.getUsername());
    pwdPassword.setText(dbStrings.getPassword());

    // construct dialog
    DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("right:pref, 4dlu, fill:pref", ""));

    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // add labels and input fields
    builder.append(lblServerType);
    builder.append(cmbServerType);
    builder.nextLine();
    builder.append(lblServerHostname);
    builder.append(txtServerHostname);
    builder.nextLine();
    builder.append(lblDatabase);
    builder.append(txtDatabase);
    builder.nextLine();
    builder.append(lblUsername);
    builder.append(txtUsername);
    builder.nextLine();
    builder.append(lblPassword);
    builder.append(pwdPassword);
    builder.nextLine();

    // add the panel to the CENTER of your dialog:
    getContentPane().add(builder.getPanel(), BorderLayout.CENTER);

    // add buttons are added in a similar way:
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(btnConnect);
    bb.addButton(btnCancel);
    bb.addGlue();

    // add the buttons to the SOUTH of your dialog:
    getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    pack();

    ActionListener connectAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String errorMessage = checkInput();

            if (errorMessage == null) {
                storeSettings();
                setVisible(false);
                setConnectToDB(true);
            } else {
                JOptionPane.showMessageDialog(null, errorMessage, "Input Error", JOptionPane.ERROR_MESSAGE);
            }

        }
    };

    btnConnect.addActionListener(connectAction);
    txtDatabase.addActionListener(connectAction);
    txtServerHostname.addActionListener(connectAction);
    txtUsername.addActionListener(connectAction);
    pwdPassword.addActionListener(connectAction);

    AbstractAction cancelAction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
            setConnectToDB(false);
        }
    };
    btnCancel.addActionListener(cancelAction);

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

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

License:Open Source License

private void appendKeyGeneratorSettings() {
    ButtonGroup bg = new ButtonGroup();
    bg.add(letterStartA);//from   w  ww .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", "");//, 8dlu, 20dlu, 8dlu, fill:pref", "");
    JPanel pan = new JPanel();
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.appendSeparator(Globals.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(Globals.lang("Replace (regular expression)") + ':');
    builder.append(Globals.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(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            // Warning before overwriting is only relevant if overwriting can happen:
            warnBeforeOverwriting.setEnabled(!dontOverwrite.isSelected());
        }
    });
}

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

License:Open Source License

/**
 * Customization of external program paths.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *///ww w  .ja  v  a  2  s .  c om
public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    _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) {
            if (row == 0) {
                return (column == 0 ? GUIGlobals.NUMBER_COL : "" + ncWidth);
            }
            row--;
            if (row >= tableRows.size()) {
                return "";
            }
            Object rowContent = tableRows.elementAt(row);
            if (rowContent == null) {
                return "";
            }
            TableRow tr = (TableRow) rowContent;
            switch (column) {
            case 0:
                return tr.name;
            case 1:
                return ((tr.length > 0) ? Integer.toString(tr.length) : "");
            }
            return null; // Unreachable.
        }

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

        @Override
        public Class<?> getColumnClass(int column) {
            if (column == 0) {
                return String.class;
            } else {
                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.elementAt(row - 1);

            if (col == 0) {
                rowContent.name = value.toString();
                if (getValueAt(row, 1).equals("")) {
                    setValueAt("" + GUIGlobals.DEFAULT_FIELD_LENGTH, row, 1);
                }
            } else {
                if (value == null) {
                    rowContent.length = -1;
                } else {
                    rowContent.length = 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", //, 4dlu, fill:60dlu, 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 tlb = new JToolBar(SwingConstants.VERTICAL);
    tlb.setFloatable(false);
    //tlb.setRollover(true);
    //tlb.setLayout(gbl);
    AddRowAction ara = new AddRowAction();
    DeleteRowAction dra = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    tlb.setBorder(null);
    tlb.add(ara);
    tlb.add(dra);
    tlb.addSeparator();
    tlb.add(moveUp);
    tlb.add(moveDown);
    //tlb.addSeparator();
    //tlb.add(new UpdateWidthsAction());
    tabPanel.add(tlb, BorderLayout.EAST);

    showOneLetterHeadingForIconColumns = new JCheckBox(
            Globals.lang("Show one letter heading for icon columns"));

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

    urlColumn.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            preferUrl.setEnabled(urlColumn.isSelected());
            preferDoi.setEnabled(urlColumn.isSelected());
        }
    });
    arxivColumn = new JCheckBox(Globals.lang("Show ArXiv column"));

    extraFileColumns = new JCheckBox(Globals.lang("Show Extra columns"));
    extraFileColumns.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            listOfFileColumns.setEnabled(extraFileColumns.isSelected());
        }
    });
    ExternalFileType[] fileTypes = Globals.prefs.getExternalFileTypeSelection();
    String[] fileTypeNames = new String[fileTypes.length];
    for (int i = 0; i < fileTypes.length; i++) {
        fileTypeNames[i] = fileTypes[i].getName();
    }
    listOfFileColumns = new JList(fileTypeNames);
    JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns);
    listOfFileColumns.setVisibleRowCount(3);

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

    HelpAction help = new HelpAction(frame.helpDiag, GUIGlobals.specialFieldsHelp);
    JButton hlb = new JButton(GUIGlobals.getImage("helpSmall"));
    hlb.setToolTipText(Globals.lang("Help on special fields"));
    hlb.addActionListener(help);

    specialFieldsEnabled = new JCheckBox(Globals.lang("Enable special fields"));
    //      .concat(". ").concat(Globals.lang("You must restart JabRef for this to come into effect.")));
    specialFieldsEnabled.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            boolean isEnabled = specialFieldsEnabled.isSelected();
            rankingColumn.setEnabled(isEnabled);
            compactRankingColumn.setEnabled(isEnabled && rankingColumn.isSelected());
            qualityColumn.setEnabled(isEnabled);
            priorityColumn.setEnabled(isEnabled);
            relevanceColumn.setEnabled(isEnabled);
            printedColumn.setEnabled(isEnabled);
            readStatusColumn.setEnabled(isEnabled);
            syncKeywords.setEnabled(isEnabled);
            writeSpecialFields.setEnabled(isEnabled);
        }
    });
    rankingColumn = new JCheckBox(Globals.lang("Show rank"));
    rankingColumn.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            compactRankingColumn.setEnabled(rankingColumn.isSelected());
        }
    });
    compactRankingColumn = new JCheckBox(Globals.lang("Compact rank"));
    qualityColumn = new JCheckBox(Globals.lang("Show quality"));
    priorityColumn = new JCheckBox(Globals.lang("Show priority"));
    relevanceColumn = new JCheckBox(Globals.lang("Show relevance"));
    printedColumn = new JCheckBox(Globals.lang("Show printed status"));
    readStatusColumn = new JCheckBox(Globals.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(Globals.lang("Synchronize with keywords"));
    writeSpecialFields = new JRadioButton(
            Globals.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    builder.appendSeparator(Globals.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(compactRankingColumn, cc.xy(3, 3));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 8, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2));
    specialTableColumnsBuilder.add(showOneLetterHeadingForIconColumns, cc.xyw(1, 12, 4));
    specialTableColumnsBuilder.add(hlb, cc.xyw(1, 13, 2));

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

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

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

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

    builder.appendSeparator(Globals.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    //   lab = new JLabel("<HTML>("+Globals.lang("this button will update the column width settings<BR>"
    //                  +"to match the current widths in your table")+")</HTML>");
    //        lab = new JLabel("<HTML>("+Globals.lang("this_button_will_update") +")</HTML>") ;
    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.append(lab);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}