Skip to content

Commit

Permalink
Refactor unlinked files (#7209)
Browse files Browse the repository at this point in the history
* [WIP] Refactor unlinked files

create dialog in fxml and use a background task for import

* add controller

* inject stuff

* empty line

* add progreess indicator
copy over some methods

* finish export implementation
TODO: Import Button does not yet work, always null

* prepare background task for import

* prepare eception handling

* add further logging

* add progrees indicator linkage

TODO: Progress not yet shown

* Fix threading issues, report progress

* remove useless undo stuff

* wire buttons to the viewModel
adjust dialog

* show import results dialog view

* better error messages

* Rename files, fix cancel, fix gui

* Cleanup
checkstyle

* checkstyle

* fix checkstyle in md

* Make table columns more wider
disable import button

* preapre localization

* fix typo

* fix md errors

* fix l10n key

* add l10n

* further l10n fixes

* further l10n fixs to reuse

* remove one dot

* idea extend filenode wrapper

* Remove extra dialog

* fix progressIndicator still visible

* replace with spaces

* fix checkstyle

* add titled pane

* fix checkstyle

* fix duplicate method

* align browse button

* adjust combobox display

* Fixed whitespaces, fxml and refactored for some readability

* Fixed accordion and l10n

* Add changelog

* fix link in changelog

* fix changelog

* fix wrong loop var
fix dnd

* refactor
only call pdf import when xmp did not find a result

* create viewModel for filter model

* wip refactor like in parse latex

* fix view model stuff
adapt to check View model

* add validator

* fix selection and export
move file node view model

* fix bug using wrong parameter
remove l10n keys

* Refactored some style issues and a minor suggestions of IntelliJ

* l10n

* only show results after import

* Add custom skin for putting arrow to the right

* add checkstyle exception

* only change import order

* checkstyle

* load custom skin only on accordion

* Add arrow rotation hack

* Fix merge conflict

* Set disable instead of visible

* Fixed jumping arrow

* Refactored for mvvm pattern and optics

* Remove obsolete language key

* refactor

* cleanup

* fix checkstyle
and l10n

* move vars down to background task
add explaination to checkstyle

* Made treeRootProperty a property of Optional

* l10n

Co-authored-by: Carl Christian Snethlage <[email protected]>
  • Loading branch information
Siedlerchr and calixtus authored Jan 24, 2021
1 parent fac0a23 commit 86d52cd
Show file tree
Hide file tree
Showing 32 changed files with 1,268 additions and 651 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Changed

- We improved the "Find unlinked files" dialog to show import results for each file. [#7209](https://github.com/JabRef/jabref/pull/7209)
- The content of the field `timestamp` is migrated to `creationdate`. In case one configured "udpate timestampe", it is migrated to `modificationdate`. [koppor#130](https://github.com/koppor/jabref/issues/130)
- The JabRef specific meta-data content in the main field such as priorities (prio1, prio2, ...) are migrated to their respective fields. They are removed from the keywords. [#6840](https://github.com/jabref/jabref/issues/6840)
- We fixed an issue where groups generated from authors' last names did not include all entries of the authors' [#5833](https://github.com/JabRef/jabref/issues/5833)
Expand All @@ -30,6 +31,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with the style of highlighted check boxes while searching in preferences. [#7226](https://github.com/JabRef/jabref/issues/7226)
- We fixed an issue where the option "Move file to file directory" was disabled in the entry editor for all files [#7194](https://github.com/JabRef/jabref/issues/7194)
- We fixed an issue where application dialogs were opening in the wrong display when using multiple screens [#7273](https://github.com/JabRef/jabref/pull/7273)
- We fixed an issue where the "Find unlinked files" dialog would freeze JabRef on importing. [#7205](https://github.com/JabRef/jabref/issues/7205)
- We fixed an issue where the "Find unlinked files" would stop importing when importing a single file failed. [#7206](https://github.com/JabRef/jabref/issues/7206)
- We fixed an issue where an exception would be displayed for previewing and preferences when a custom theme has been configured but is missing [#7177](https://github.com/JabRef/jabref/issues/7177)
- We fixed an issue where the Harvard RTF exporter used the wrong default file extension. [4508](https://github.com/JabRef/jabref/issues/4508)
- We fixed an issue where the Harvard RTF exporter did not use the new authors formatter and therefore did not export "organization" authors correctly. [4508](https://github.com/JabRef/jabref/issues/4508)
Expand Down
2 changes: 2 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

<suppressions>
<suppress checks="[a-zA-Z0-9]*" files="[\\/]generated[\\/]" />
<!-- We ignore this file because it's a modification of the original java code https://github.com/openjdk/jfx/blob/jfx15/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TitledPaneSkin.java -->
<suppress checks="[a-zA-Z0-9]*" files="CustomTitledPaneSkin.java" />
</suppressions>
4 changes: 2 additions & 2 deletions docs/getting-into-the-code/code-howtos.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Many times there is a need to provide an object on many locations simultaneously
### Register to the `EventBus`
Any listening method has to be annotated with `@Subscribe` keyword and must have only one accepting parameter. Furthermore the object which contains such listening method\(s\) has to be registered using the `register(Object)` method provided by `EventBus`. The listening methods can be overloaded by using different parameter types.
Any listening method has to be annotated with `@Subscribe` keyword and must have only one accepting parameter. Furthermore, the object which contains such listening method\(s\) has to be registered using the `register(Object)` method provided by `EventBus`. The listening methods can be overloaded by using different parameter types.
### Posting an object
Expand Down Expand Up @@ -190,7 +190,7 @@ If the language is a variant of a language `zh_CN` or `pt_BR` it is necessary to

## Cleanup and Formatters

We try to build a cleanup mechanism based on formatters. The idea is that we can register these actions in arbitrary places, e.g., onSave, onImport, onExport, cleanup, etc. and apply them to different fields. The formatters themself are independent of any logic and therefore easy to test.
We try to build a cleanup mechanism based on formatters. The idea is that we can register these actions in arbitrary places, e.g., onSave, onImport, onExport, cleanup, etc. and apply them to different fields. The formatters themselves are independent of any logic and therefore easy to test.

Example: [NormalizePagesFormatter](https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java)

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,31 @@
-fx-padding: 0;
}

.accordion .titled-pane {
-fx-skin: "org.jabref.gui.util.CustomTitledPaneSkin";
-fx-arrow-side: right;
}

.accordion .titled-pane .title {
-fx-background-color: transparent;
-fx-border-color: transparent;
-fx-background-insets: 5 5 5 5;
}

.accordion .titled-pane > *.content {
-fx-background-color: transparent;
-fx-border-color: transparent;
}

/*
* The arrow button has some right padding that's added
* by "modena.css". This simply puts the padding on the
* left since the arrow is positioned on the right.
*/
.titled-pane > .title > .arrow-button {
-fx-padding: 0.0em 0.0em 0.0em 0.583em;
}

.text-input {
-fx-background-color: -fx-outer-border, -fx-control-inner-background;
-fx-background-insets: 0, 1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(dialogService, prefs, undoManager, stateManager))
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(dialogService, stateManager))
);

// PushToApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class BibtexExtractorViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(BibtexExtractorViewModel.class);

private final StringProperty inputTextProperty = new SimpleStringProperty("");
private DialogService dialogService;
private GrobidCitationFetcher currentCitationfetcher;
private TaskExecutor taskExecutor;
private ImportHandler importHandler;
private final DialogService dialogService;
private final GrobidCitationFetcher currentCitationfetcher;
private final TaskExecutor taskExecutor;
private final ImportHandler importHandler;

public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext,
DialogService dialogService,
Expand All @@ -48,7 +48,6 @@ public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext,
currentCitationfetcher = new GrobidCitationFetcher(preferencesService.getImportFormatPreferences());
this.taskExecutor = taskExecutor;
this.importHandler = new ImportHandler(
dialogService,
bibdatabaseContext,
ExternalFileTypes.getInstance(),
preferencesService,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.jabref.gui.externalfiles;

import java.nio.file.DirectoryStream.Filter;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.gui.util.FileFilterConverter;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.FileType;

public class FileExtensionViewModel {

private final String description;
private final List<String> extensions;
private final ExternalFileTypes externalFileTypes;

FileExtensionViewModel(FileType fileType, ExternalFileTypes externalFileTypes) {
this.description = Localization.lang("%0 file", fileType.toString());
this.extensions = fileType.getExtensionsWithDot();
this.externalFileTypes = externalFileTypes;
}

public String getDescription() {
return this.description + extensions.stream().collect(Collectors.joining(", ", " (", ")"));
}

public JabRefIcon getIcon() {
return externalFileTypes.getExternalFileTypeByExt(extensions.get(0))
.map(ExternalFileType::getIcon)
.orElse(null);
}

public Filter<Path> dirFilter() {
return FileFilterConverter.toDirFilter(extensions);
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
package org.jabref.gui.externalfiles;

import javax.swing.undo.UndoManager;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.PreferencesService;

import static org.jabref.gui.actions.ActionHelper.needsDatabase;

public class FindUnlinkedFilesAction extends SimpleCommand {

private final DialogService dialogService;
private final PreferencesService preferencesService;
private final UndoManager undoManager;
private final StateManager stateManager;

public FindUnlinkedFilesAction(DialogService dialogService, PreferencesService preferencesService, UndoManager undoManager, StateManager stateManager) {
public FindUnlinkedFilesAction(DialogService dialogService, StateManager stateManager) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.undoManager = undoManager;
this.stateManager = stateManager;

this.executable.bind(needsDatabase(this.stateManager));
}

@Override
public void execute() {
BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null"));
dialogService.showCustomDialogAndWait(new FindUnlinkedFilesDialog(database, dialogService, preferencesService, undoManager));
dialogService.showCustomDialogAndWait(new UnlinkedFilesDialogView());
}
}
Loading

0 comments on commit 86d52cd

Please sign in to comment.