Skip to content

Commit

Permalink
Fix setting of title (and simplify BasePanel to LibraryTab) (#6129)
Browse files Browse the repository at this point in the history
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
  • Loading branch information
koppor and calixtus authored Oct 20, 2020
1 parent a7b05d0 commit 4cf2fb0
Show file tree
Hide file tree
Showing 69 changed files with 730 additions and 896 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ inserting new citations in a OpenOffic/LibreOffice document. [#6957](https://git
- We improved the duplicate detection when identifiers like DOI or arxiv are semantiaclly the same, but just syntactically differ (e.g. with or without http(s):// prefix). [#6707](https://github.com/JabRef/jabref/issues/6707)
- We changed in the group interface "Generate groups from keywords in a BibTeX field" by "Generate groups from keywords in the following field". [#6983](https://github.com/JabRef/jabref/issues/6983)
- We changed the name of a group type from "Searching for keywords" to "Searching for a keyword". [6995](https://github.com/JabRef/jabref/pull/6995)
- We changed the way JabRef displays the title of a tab and of the window. [4161](https://github.com/JabRef/jabref/issues/4161)
- We changed connect timeouts for server requests to 30 seconds in general and 5 seconds for GROBID server (special) and improved user notifications on connection issues. [7026](https://github.com/JabRef/jabref/pull/7026)

### Fixed
Expand Down
79 changes: 0 additions & 79 deletions src/main/java/org/jabref/gui/BasePanelPreferences.java

This file was deleted.

13 changes: 7 additions & 6 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.importer.IdBasedFetcher;
import org.jabref.logic.importer.WebFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryType;
Expand Down Expand Up @@ -60,16 +61,16 @@ public class EntryTypeView extends BaseDialog<EntryType> {
@FXML private TitledPane customTitlePane;
@FXML private TitledPane biblatexSoftwareTitlePane;

private final BasePanel basePanel;
private final LibraryTab libraryTab;
private final DialogService dialogService;
private final JabRefPreferences prefs;

private EntryType type;
private EntryTypeViewModel viewModel;
private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer();

public EntryTypeView(BasePanel basePanel, DialogService dialogService, JabRefPreferences preferences) {
this.basePanel = basePanel;
public EntryTypeView(LibraryTab libraryTab, DialogService dialogService, JabRefPreferences preferences) {
this.libraryTab = libraryTab;
this.dialogService = dialogService;
this.prefs = preferences;

Expand Down Expand Up @@ -120,7 +121,7 @@ private void addEntriesToPane(FlowPane pane, Collection<? extends BibEntryType>
@FXML
public void initialize() {
visualizer.setDecoration(new IconValidationDecorator());
viewModel = new EntryTypeViewModel(prefs, basePanel, dialogService, stateManager);
viewModel = new EntryTypeViewModel(prefs, libraryTab, dialogService, stateManager);

idBasedFetchers.itemsProperty().bind(viewModel.fetcherItemsProperty());
idTextField.textProperty().bindBidirectional(viewModel.idTextProperty());
Expand All @@ -133,7 +134,7 @@ public void initialize() {
}
});

new ViewModelListCellFactory<IdBasedFetcher>().withText(item -> item.getName()).install(idBasedFetchers);
new ViewModelListCellFactory<IdBasedFetcher>().withText(WebFetcher::getName).install(idBasedFetchers);

// we set the managed property so that they will only be rendered when they are visble so that the Nodes only take the space when visible
// avoids removing and adding from the scence graph
Expand All @@ -143,7 +144,7 @@ public void initialize() {
customTitlePane.managedProperty().bind(customTitlePane.visibleProperty());
biblatexSoftwareTitlePane.managedProperty().bind(biblatexSoftwareTitlePane.visibleProperty());

if (basePanel.getBibDatabaseContext().isBiblatexMode()) {
if (libraryTab.getBibDatabaseContext().isBiblatexMode()) {
addEntriesToPane(biblatexPane, BiblatexEntryTypeDefinitions.ALL);
addEntriesToPane(biblatexSoftwarePane, BiblatexSoftwareEntryTypeDefinitions.ALL);

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class EntryTypeViewModel {
private final StringProperty idText = new SimpleStringProperty();
private final BooleanProperty focusAndSelectAllProperty = new SimpleBooleanProperty();
private Task<Optional<BibEntry>> fetcherWorker = new FetcherWorker();
private final BasePanel basePanel;
private final LibraryTab libraryTab;
private final DialogService dialogService;
private final Validator idFieldValidator;
private final StateManager stateManager;

public EntryTypeViewModel(JabRefPreferences preferences, BasePanel basePanel, DialogService dialogService, StateManager stateManager) {
this.basePanel = basePanel;
public EntryTypeViewModel(JabRefPreferences preferences, LibraryTab libraryTab, DialogService dialogService, StateManager stateManager) {
this.libraryTab = libraryTab;
this.prefs = preferences;
this.dialogService = dialogService;
this.stateManager = stateManager;
Expand Down Expand Up @@ -147,31 +147,31 @@ public void runFetcherWorker() {
Optional<BibEntry> result = fetcherWorker.getValue();
if (result.isPresent()) {
final BibEntry entry = result.get();
ImportCleanup cleanup = new ImportCleanup(basePanel.getBibDatabaseContext().getMode());
ImportCleanup cleanup = new ImportCleanup(libraryTab.getBibDatabaseContext().getMode());
cleanup.doPostCleanup(entry);
Optional<BibEntry> duplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(basePanel.getDatabase(), entry, basePanel.getBibDatabaseContext().getMode());
Optional<BibEntry> duplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(libraryTab.getDatabase(), entry, libraryTab.getBibDatabaseContext().getMode());
if ((duplicate.isPresent())) {
DuplicateResolverDialog dialog = new DuplicateResolverDialog(entry, duplicate.get(), DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, basePanel.getBibDatabaseContext(), stateManager);
DuplicateResolverDialog dialog = new DuplicateResolverDialog(entry, duplicate.get(), DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, libraryTab.getBibDatabaseContext(), stateManager);
switch (dialog.showAndWait().orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK)) {
case KEEP_LEFT:
basePanel.getDatabase().removeEntry(duplicate.get());
basePanel.getDatabase().insertEntry(entry);
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_BOTH:
basePanel.getDatabase().insertEntry(entry);
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_MERGE:
basePanel.getDatabase().removeEntry(duplicate.get());
basePanel.getDatabase().insertEntry(dialog.getMergedEntry());
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(dialog.getMergedEntry());
break;
default:
// Do nothing
break;
}
} else {
// Regenerate CiteKey of imported BibEntry
new CitationKeyGenerator(basePanel.getBibDatabaseContext(), prefs.getCitationKeyPatternPreferences()).generateAndSetKey(entry);
basePanel.insertEntry(entry);
new CitationKeyGenerator(libraryTab.getBibDatabaseContext(), prefs.getCitationKeyPatternPreferences()).generateAndSetKey(entry);
libraryTab.insertEntry(entry);
}
searchSuccesfulProperty.set(true);
} else if (StringUtil.isBlank(idText.getValue())) {
Expand Down
Loading

0 comments on commit 4cf2fb0

Please sign in to comment.