Skip to content

Commit

Permalink
feat/#1 Add CSS file type, add button in preferences to import custom…
Browse files Browse the repository at this point in the history
… CSS file, started on import functionality
  • Loading branch information
nilsstre committed Feb 26, 2020
1 parent 8c1b35c commit f402fd2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
</Button>
<Button maxWidth="Infinity" onAction="#showAllPreferences" text="%Show preferences"/>
<Button maxWidth="Infinity" onAction="#resetPreferences" text="%Reset preferences"/>
<Button maxWidth="Infinity" onAction="#importStyle" text="%Import CSS">
<tooltip>
<Tooltip text="%Import custom CSS file" />
</tooltip>
</Button>
</VBox>
</VBox>
<ScrollPane fx:id="preferencesContainer" maxHeight="Infinity" maxWidth="Infinity"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ private void savePreferencesAndCloseDialog() {

@FXML
void resetPreferences() { viewModel.resetPreferences(); }

@FXML
void importStyle() {viewModel.importCSSFile();}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,27 @@ public void setValues() {
preferencesTab.setValues();
}
}

public void importCSSFile() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.CSS)
.withDefaultExtension(StandardFileType.CSS)
.withInitialDirectory(preferences.setLastPreferencesExportPath()).build();

dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> {
try {
preferences.importPreferences(file);
updateAfterPreferenceChanges();

dialogService.showWarningDialogAndWait(Localization.lang("Import CSS"),
Localization.lang("You must restart JabRef for this to come into effect."));
} catch (JabRefException ex) {
LOGGER.error("Error while importing preferences", ex);
dialogService.showErrorDialogAndWait(Localization.lang("Import CSS"), ex);
}
});
}

public void updateCSS() {
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/logic/util/StandardFileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public enum StandardFileType implements FileType {
XML("xml"),
JSON("json"),
XMP("xmp"),
ZIP("zip");
ZIP("zip"),
CSS("css");

private final List<String> extensions;

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ Importing=Importing

Importing\ in\ unknown\ format=Importing in unknown format

Import\ CSS=Import CSS file

Import\ custom\ CSS\ file=Import custom CSS file

Include\ subgroups\:\ When\ selected,\ view\ entries\ contained\ in\ this\ group\ or\ its\ subgroups=Include subgroups: When selected, view entries contained in this group or its subgroups

Independent\ group\:\ When\ selected,\ view\ only\ this\ group's\ entries=Independent group: When selected, view only this group's entries
Expand Down

0 comments on commit f402fd2

Please sign in to comment.