Search in sources :

Example 1 with EntryFromFileCreator

use of org.jabref.gui.importer.EntryFromFileCreator in project jabref by JabRef.

the class FindUnlinkedFilesDialog method createFileTypesCombobox.

/**
     * Initialises the combobox that contains the available file types which
     * bibtex entries can be created of.
     */
private void createFileTypesCombobox() {
    List<FileFilter> fileFilterList = creatorManager.getFileFilterList();
    Vector<FileFilter> vector = new Vector<>();
    for (FileFilter fileFilter : fileFilterList) {
        vector.add(fileFilter);
    }
    comboBoxFileTypeSelection = new JComboBox<>(vector);
    comboBoxFileTypeSelection.setRenderer(new DefaultListCellRenderer() {

        /* (non-Javadoc)
             * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
             */
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value instanceof EntryFromFileCreator) {
                EntryFromFileCreator creator = (EntryFromFileCreator) value;
                if (creator.getExternalFileType() != null) {
                    label.setIcon(creator.getExternalFileType().getIcon());
                }
            }
            return label;
        }
    });
}
Also used : JLabel(javax.swing.JLabel) EntryFromFileCreator(org.jabref.gui.importer.EntryFromFileCreator) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) UnlinkedPDFFileFilter(org.jabref.gui.importer.UnlinkedPDFFileFilter) FileFilter(java.io.FileFilter) Component(java.awt.Component) JComponent(javax.swing.JComponent) Vector(java.util.Vector)

Aggregations

Component (java.awt.Component)1 FileFilter (java.io.FileFilter)1 Vector (java.util.Vector)1 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 EntryFromFileCreator (org.jabref.gui.importer.EntryFromFileCreator)1 UnlinkedPDFFileFilter (org.jabref.gui.importer.UnlinkedPDFFileFilter)1