Skip to content

Commit ec88998

Browse files
Siedlerchrcalixtus
andauthored
Fix File Filter and some layout issues (#7385)
* Fix File Filter and some layout issues Fixes part of #7383 * better min width * Any file instead of all * remove style class * l10n Co-authored-by: Carl Christian Snethlage <[email protected]>
1 parent 034cf8c commit ec88998

File tree

10 files changed

+70
-51
lines changed

10 files changed

+70
-51
lines changed

src/main/java/org/jabref/gui/Base.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,6 @@ TextFlow * {
12171217

12181218
}
12191219

1220-
.mainTable-header{
1220+
.mainTable-header {
12211221
-fx-fill: -fx-mid-text-color;
12221222
}

src/main/java/org/jabref/gui/externalfiles/FileExtensionViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class FileExtensionViewModel {
1919
private final ExternalFileTypes externalFileTypes;
2020

2121
FileExtensionViewModel(FileType fileType, ExternalFileTypes externalFileTypes) {
22-
this.description = Localization.lang("%0 file", fileType.toString());
22+
this.description = Localization.lang("%0 file", fileType.getName());
2323
this.extensions = fileType.getExtensionsWithDot();
2424
this.externalFileTypes = externalFileTypes;
2525
}

src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesCrawler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private FileNodeViewModel searchDirectory(Path directory, UnlinkedPDFFileFilter
7474
Map<Boolean, List<Path>> fileListPartition;
7575

7676
try (Stream<Path> filesStream = StreamSupport.stream(Files.newDirectoryStream(directory, fileFilter).spliterator(), false)) {
77-
fileListPartition = filesStream.collect(Collectors.partitioningBy(path -> path.toFile().isDirectory()));
77+
fileListPartition = filesStream.collect(Collectors.partitioningBy(Files::isDirectory));
7878
} catch (IOException e) {
7979
LOGGER.error(String.format("%s while searching files: %s", e.getClass().getName(), e.getMessage()));
8080
return parent;

src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialog.fxml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
<ColumnConstraints hgrow="SOMETIMES"/>
3535
</columnConstraints>
3636
<rowConstraints>
37-
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
38-
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
37+
<RowConstraints minHeight="20.0" vgrow="SOMETIMES"/>
38+
<RowConstraints minHeight="20.0" vgrow="SOMETIMES"/>
3939
</rowConstraints>
4040
<Label text="%Start directory:" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
4141
<TextField fx:id="directoryPathField" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
4242
<Button onAction="#browseFileDirectory" styleClass="icon-button,narrow"
4343
GridPane.columnIndex="2" GridPane.rowIndex="0"
44-
prefHeight="20.0" prefWidth="20.0">
44+
minWidth="20.0" minHeight="20.0" prefHeight="20.0" prefWidth="20.0">
4545
<graphic>
4646
<JabRefIconView glyph="OPEN"/>
4747
</graphic>
@@ -50,9 +50,9 @@
5050
</tooltip>
5151
</Button>
5252

53-
<Label text="%File extension:" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
53+
<Label text="%File type:" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
5454
<ComboBox fx:id="fileTypeCombo" maxWidth="Infinity" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
55-
<Button fx:id="scanButton" onAction="#scanFiles" text="%Scan directory"
55+
<Button fx:id="scanButton" onAction="#scanFiles" text="%Search"
5656
GridPane.columnIndex="2" GridPane.rowIndex="1">
5757
<tooltip>
5858
<Tooltip text="%Searches the selected directory for unlinked files."/>
@@ -71,11 +71,11 @@
7171
<TableView fx:id="importResultTable">
7272
<columns>
7373
<TableColumn fx:id="colStatus" prefWidth="100.0" text="%Status"/>
74-
<TableColumn fx:id="colMessage" prefWidth="300.0" text="%Message"/>
7574
<TableColumn fx:id="colFile" prefWidth="500.0" text="%File"/>
75+
<TableColumn fx:id="colMessage" prefWidth="300.0" text="%Message"/>
7676
</columns>
7777
<columnResizePolicy>
78-
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
78+
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
7979
</columnResizePolicy>
8080
</TableView>
8181
</TitledPane>

src/main/java/org/jabref/gui/externalfiles/UnlinkedPDFFileFilter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.nio.file.DirectoryStream;
66
import java.nio.file.DirectoryStream.Filter;
7+
import java.nio.file.Files;
78
import java.nio.file.Path;
89

910
import org.jabref.logic.util.io.DatabaseFileLookup;
@@ -31,6 +32,11 @@ public UnlinkedPDFFileFilter(DirectoryStream.Filter<Path> fileFilter, BibDatabas
3132

3233
@Override
3334
public boolean accept(Path pathname) throws IOException {
34-
return fileFilter.accept(pathname) && !lookup.lookupDatabase(pathname.toFile());
35+
36+
if (Files.isDirectory(pathname)) {
37+
return true;
38+
} else {
39+
return fileFilter.accept(pathname) && !lookup.lookupDatabase(pathname);
40+
}
3541
}
3642
}

src/main/java/org/jabref/logic/util/FileType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ default List<String> getExtensionsWithDot() {
1515
}
1616

1717
List<String> getExtensions();
18+
19+
String getName();
1820
}

src/main/java/org/jabref/logic/util/StandardFileType.java

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,64 @@
1010
*/
1111
public enum StandardFileType implements FileType {
1212

13-
BIBTEXML("bibx", "xml"),
14-
ENDNOTE("ref", "enw"),
15-
ISI("isi", "txt"),
16-
MEDLINE("nbib", "xml"),
17-
MEDLINE_PLAIN("nbib", "txt"),
18-
PUBMED("fcgi"),
19-
SILVER_PLATTER("dat", "txt"),
20-
21-
AUX("aux"),
22-
BIBTEX_DB("bib"),
23-
CITATION_STYLE("csl"),
24-
CLASS("class"),
25-
CSV("csv"),
26-
HTML("html", "htm"),
27-
JAR("jar"),
28-
JAVA_KEYSTORE("jks"),
29-
JSTYLE("jstyle"),
30-
LAYOUT("layout"),
31-
ODS("ods"),
32-
PDF("pdf"),
33-
RIS("ris"),
34-
TERMS("terms"),
35-
TXT("txt"),
36-
RDF("rdf"),
37-
RTF("rtf"),
38-
SXC("sxc"),
39-
TEX("tex"),
40-
XML("xml"),
41-
JSON("json"),
42-
XMP("xmp"),
43-
ZIP("zip"),
44-
CSS("css"),
45-
YAML("yaml"),
46-
ANY_FILE("*");
13+
BIBTEXML("BibTeXML", "bibx", "xml"),
14+
ENDNOTE("Endnote", "ref", "enw"),
15+
ISI("Isi", "isi", "txt"),
16+
MEDLINE("Medline", "nbib", "xml"),
17+
MEDLINE_PLAIN("Medline Plain", "nbib", "txt"),
18+
PUBMED("Pubmed", "fcgi"),
19+
SILVER_PLATTER("SilverPlatter", "dat", "txt"),
20+
AUX("Aux file", "aux"),
21+
BIBTEX_DB("Bibtex library", "bib"),
22+
CITATION_STYLE("Citation Style", "csl"),
23+
CLASS("Class file", "class"),
24+
CSV("CSV", "csv"),
25+
HTML("HTML", "html", "htm"),
26+
JAR("JAR", "jar"),
27+
JAVA_KEYSTORE("Java Keystore", "jks"),
28+
JSTYLE("LibreOffice layout style", "jstyle"),
29+
LAYOUT("Custom Exporter format", "layout"),
30+
ODS("OpenOffice Calc", "ods"),
31+
PDF("PDF", "pdf"),
32+
RIS("RIS", "ris"),
33+
TERMS("Protected terms", "terms"),
34+
TXT("Plain Text", "txt"),
35+
RDF("RDF", "rdf"),
36+
RTF("RTF", "rtf"),
37+
SXC("Open Office Calc 1.x", "sxc"),
38+
TEX("LaTeX", "tex"),
39+
XML("XML", "xml"),
40+
JSON("JSON", "json"),
41+
XMP("XMP", "xmp"),
42+
ZIP("Zip Archive", "zip"),
43+
CSS("CSS Styleshet", "css"),
44+
YAML("YAML Markup", "yaml"),
45+
ANY_FILE("Any", "*");
4746

4847
private final List<String> extensions;
48+
private final String name;
4949

50-
StandardFileType(String... extensions) {
50+
StandardFileType(String name, String... extensions) {
5151
this.extensions = Arrays.asList(extensions);
52+
this.name = name;
5253
}
5354

5455
@Override
5556
public List<String> getExtensions() {
5657
return extensions;
5758
}
5859

60+
@Override
61+
public String getName() {
62+
return this.name;
63+
}
64+
5965
public static FileType fromExtensions(String... extensions) {
6066
var exts = Arrays.asList(extensions);
6167

6268
return OptionalUtil.orElse(Arrays.stream(StandardFileType.values())
6369
.filter(field -> field.getExtensions().stream().anyMatch(elem -> exts.contains(elem)))
6470
.findAny(),
65-
new UnknownFileType(extensions));
71+
new UnknownFileType(extensions));
6672
}
6773
}

src/main/java/org/jabref/logic/util/UnknownFileType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ public boolean equals(Object o) {
4343
public int hashCode() {
4444
return Objects.hash(extensions);
4545
}
46+
47+
@Override
48+
public String getName() {
49+
return "Unknown File Type" + extensions.toString();
50+
}
4651
}

src/main/java/org/jabref/logic/util/io/DatabaseFileLookup.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public DatabaseFileLookup(BibDatabaseContext databaseContext, FilePreferences fi
4848
* <br>
4949
* For the matching, the absolute file paths will be used.
5050
*
51-
* @param file A {@link File} Object.
51+
* @param pathname A {@link File} Object.
5252
* @return <code>true</code>, if the file Object is stored in at least one
5353
* entry in the database, otherwise <code>false</code>.
5454
*/
55-
public boolean lookupDatabase(File file) {
56-
return fileCache.contains(file.toPath());
55+
public boolean lookupDatabase(Path pathname) {
56+
return fileCache.contains(pathname);
5757
}
5858

5959
private List<Path> parseFileField(BibEntry entry) {

src/main/resources/l10n/JabRef_en.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,10 @@ Unable\ to\ clear\ preferences.=Unable to clear preferences.
11071107
Unselect\ all=Unselect all
11081108
Expand\ all=Expand all
11091109
Collapse\ all=Collapse all
1110-
Scan\ directory=Scan directory
11111110
Searches\ the\ selected\ directory\ for\ unlinked\ files.=Searches the selected directory for unlinked files.
11121111
Starts\ the\ import\ of\ BibTeX\ entries.=Starts the import of BibTeX entries.
11131112
Start\ directory\:=Start directory:
1113+
File\ type\:=File type:
11141114
Currently\ unlinked\ files=Currently unlinked files
11151115
Import\ result=Import result
11161116
Searching\ file\ system...=Searching file system...

0 commit comments

Comments
 (0)