Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filetype icon issues #893

Merged
merged 6 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Integrity check now also checks broken file links, abbreviations in journal and booktitle, and incorrect use of proceedings with page numbers

### Fixed
- Fixed [#883](https://github.com/JabRef/jabref/issues/883): No NPE during cleanup
- Fixed [#598](https://github.com/JabRef/jabref/issues/598) and [#402](https://github.com/JabRef/jabref/issues/402): No more issues with invalid icons for ExternalFileTypes in global search or after editing the settings
- Fixed [#883](https://github.com/JabRef/jabref/issues/883): No NPE during cleanup
- Fixed [#466](https://github.com/JabRef/jabref/issues/466): Rename PDF cleanup now also changes case of file name
- Fixed [#621](https://github.com/JabRef/jabref/issues/621) and [#669](https://github.com/JabRef/jabref/issues/669): Encoding and preamble now end with newline.
- Make BibTex parser more robust against missing newlines
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/net/sf/jabref/external/ExternalFileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ public static ExternalFileType buildFromArgs(String[] val) {
iconName = val[4];
}

if ("new".equals(iconName)) {
icon = IconTheme.JabRefIcon.FILE.getSmallIcon();
} else {
icon = IconTheme.getImage(iconName);
// set icon to default first
icon = IconTheme.JabRefIcon.FILE.getSmallIcon();

// check whether there is another icon defined for this file type
for(ExternalFileType fileType : ExternalFileTypes.getDefaultExternalFileTypes()) {
if(fileType.getName().equals(name)) {
icon = fileType.icon;
break;
}
}

return new ExternalFileType(name, extension, mimeType, openWith, iconName, icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void actionPerformed(ActionEvent e) {
Globals.lang("Reset file type definitions"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);*/
//if (reply == JOptionPane.YES_OPTION) {
List<ExternalFileType> list = ExternalFileTypes.getInstance().getDefaultExternalFileTypes();
List<ExternalFileType> list = ExternalFileTypes.getDefaultExternalFileTypes();
fileTypes.clear();
fileTypes.addAll(list);
Collections.sort(fileTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private ExternalFileTypes() {
updateExternalFileTypes();
}

public List<ExternalFileType> getDefaultExternalFileTypes() {
public static List<ExternalFileType> getDefaultExternalFileTypes() {
List<ExternalFileType> list = new ArrayList<>();
list.add(new ExternalFileType("PDF", "pdf", "application/pdf", "evince", "pdfSmall",
IconTheme.JabRefIcon.PDF_FILE.getSmallIcon()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class UnknownExternalFileType extends ExternalFileType {

public UnknownExternalFileType(String name) {
super(name, "", "", "", "unknown", IconTheme.getImage("unknown"));
super(name, "", "", "", "unknown", IconTheme.JabRefIcon.FILE.getSmallIcon());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public Object getColumnValue(BibEntry entry) {
ExternalFileType type = fileList.getEntry(0).type;
if (type != null) {
return type.getIconLabel();
} else {
return new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ public Object getColumnValue(BibEntry entry, int column) {
tmpModel.setContent(entry.getField(Globals.FILE_FIELD));
fileLabel.setToolTipText(tmpModel.getToolTipHTMLRepresentation());
if (tmpModel.getRowCount() > 0) {
fileLabel.setIcon(tmpModel.getEntry(0).type.getIcon());
if(tmpModel.getEntry(0).type!=null) {
fileLabel.setIcon(tmpModel.getEntry(0).type.getIcon());
} else {
fileLabel.setIcon(IconTheme.JabRefIcon.FILE.getSmallIcon());
}
}
return fileLabel;
} else {
Expand Down