use of org.jabref.gui.filelist.FileListTableModel in project jabref by JabRef.
the class SpecialMainTableColumnsBuilder method buildFileColumn.
MainTableColumn buildFileColumn() {
return new MainTableColumn(FieldName.FILE, Collections.singletonList(FieldName.FILE), new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon())) {
@Override
public Object getColumnValue(BibEntry entry) {
// We use a FileListTableModel to parse the field content:
FileListTableModel fileList = new FileListTableModel();
entry.getField(FieldName.FILE).ifPresent(fileList::setContent);
if (fileList.getRowCount() > 1) {
return new JLabel(IconTheme.JabRefIcon.FILE_MULTIPLE.getSmallIcon());
} else if (fileList.getRowCount() == 1) {
Optional<ExternalFileType> type = fileList.getEntry(0).getType();
if (type.isPresent()) {
return type.get().getIconLabel();
} else {
return new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon());
}
}
return null;
}
};
}
use of org.jabref.gui.filelist.FileListTableModel in project jabref by JabRef.
the class SpecialMainTableColumnsBuilder method createFileIconColumn.
/**
* create a MainTableColumn for specific file types.
* <p>
* Shows the icon for the given type (or the FILE_MULTIPLE icon)
*
* @param externalFileTypeName the name of the externalFileType
* @return the created MainTableColumn
*/
MainTableColumn createFileIconColumn(String externalFileTypeName) {
return new MainTableColumn(externalFileTypeName, Collections.singletonList(FieldName.FILE), new JLabel()) {
@Override
public boolean isFileFilter() {
return true;
}
@Override
public String getDisplayName() {
return externalFileTypeName;
}
@Override
public Object getColumnValue(BibEntry entry) {
boolean iconFound = false;
JLabel iconLabel = null;
FileListTableModel fileList = new FileListTableModel();
entry.getField(FieldName.FILE).ifPresent(fileList::setContent);
for (int i = 0; i < fileList.getRowCount(); i++) {
if ((fileList.getEntry(i).getType().isPresent()) && externalFileTypeName.equalsIgnoreCase(fileList.getEntry(i).getType().get().getName())) {
if (iconFound) {
// already found another file of the desired type - show FILE_MULTIPLE Icon
return new JLabel(IconTheme.JabRefIcon.FILE_MULTIPLE.getSmallIcon());
} else {
iconLabel = fileList.getEntry(i).getType().get().getIconLabel();
iconFound = true;
}
}
}
return iconLabel;
}
};
}
Aggregations