Skip to content

Commit

Permalink
Merge pull request #6503 from MootezSaaD/fix-dnd-on-empty-db
Browse files Browse the repository at this point in the history
Fix Drag and Drop on empty database
  • Loading branch information
Siedlerchr authored May 21, 2020
2 parents fe5eec6 + 2ddd583 commit 950d9c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the library sort order was lost. [#6091](https://github.com/JabRef/jabref/issues/6091)
- We fixed an issue where brackets in regular expressions were not working. [6469](https://github.com/JabRef/jabref/pull/6469)
- We fixed an issue where LaTeX citations for specific commands (\autocites) of biblatex-mla were not recognized. [#6476](https://github.com/JabRef/jabref/issues/6476)
- We fixed an issue where drag and drop was not working on empty database. [#6487](https://github.com/JabRef/jabref/issues/6487)

### Removed

Expand Down
48 changes: 21 additions & 27 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,8 @@ private void initDragAndDrop() {
if (!(skin instanceof TabPaneSkin)) {
return;
}

// We need to get the tab header, the following is a ugly workaround
Node tabHeaderArea = ((TabPaneSkin) this.tabbedPane.getSkin())
.getChildren()
.stream()
.filter(node -> node.getStyleClass().contains("tab-header-area"))
.findFirst()
.orElseThrow();

tabHeaderArea.setOnDragOver(event -> {
// Add drag and drop listeners to JabRefFrame
this.getScene().setOnDragOver(event -> {
if (DragAndDropHelper.hasBibFiles(event.getDragboard())) {
event.acceptTransferModes(TransferMode.ANY);
if (!tabbedPane.getTabs().contains(dndIndicator)) {
Expand All @@ -215,11 +207,12 @@ private void initDragAndDrop() {
}
});

tabHeaderArea.setOnDragExited(event -> tabbedPane.getTabs().remove(dndIndicator));

tabHeaderArea.setOnDragDropped(event -> {
this.getScene().setOnDragExited(event -> {
tabbedPane.getTabs().remove(dndIndicator);
});

this.getScene().setOnDragDropped(event -> {
tabbedPane.getTabs().remove(dndIndicator);
List<Path> bibFiles = DragAndDropHelper.getBibFiles(event.getDragboard());
OpenDatabaseAction openDatabaseAction = this.getOpenDatabaseAction();
openDatabaseAction.openFiles(bibFiles, true);
Expand Down Expand Up @@ -633,24 +626,25 @@ public void init() {
}

BasePanel newBasePanel = getBasePanel(tab);
if (newBasePanel != null) {
// Poor-mans binding to global state
stateManager.setSelectedEntries(newBasePanel.getSelectedEntries());

// Poor-mans binding to global state
stateManager.setSelectedEntries(newBasePanel.getSelectedEntries());

// Update active search query when switching between databases
stateManager.activeSearchQueryProperty().set(newBasePanel.getCurrentSearchQuery());
// Update active search query when switching between databases
stateManager.activeSearchQueryProperty().set(newBasePanel.getCurrentSearchQuery());

// groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
// previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
// generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class));
// openOfficePanel.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class));
// groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
// previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
// generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class));
// openOfficePanel.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class));

setWindowTitle();
// Update search autocompleter with information for the correct database:
newBasePanel.updateSearchManager();
setWindowTitle();
// Update search autocompleter with information for the correct database:
newBasePanel.updateSearchManager();

newBasePanel.getUndoManager().postUndoRedoEvent();
newBasePanel.getMainTable().requestFocus();
newBasePanel.getUndoManager().postUndoRedoEvent();
newBasePanel.getMainTable().requestFocus();
}
});
initShowTrackingNotification();
}
Expand Down

0 comments on commit 950d9c0

Please sign in to comment.