Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Drag and Drop on empty database #6503

Merged
merged 3 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. []()
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved

### 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 -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the similar code for the tabHeaderArea below can now be removed, since this is handled on the scene level. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right, I have deleted the unnecessary code.

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