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
Changes from 1 commit
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
54 changes: 40 additions & 14 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@ private void initDragAndDrop() {
.filter(node -> node.getStyleClass().contains("tab-header-area"))
.findFirst()
.orElseThrow();
// 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)) {
tabbedPane.getTabs().add(dndIndicator);
}
event.consume();
} else {
tabbedPane.getTabs().remove(dndIndicator);
}
});

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);
event.setDropCompleted(true);
event.consume();
});

tabHeaderArea.setOnDragOver(event -> {
if (DragAndDropHelper.hasBibFiles(event.getDragboard())) {
Expand Down Expand Up @@ -633,24 +658,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