Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into improveFetcher
Browse files Browse the repository at this point in the history
* upstream/master:
  New Crowdin translations (#4454)
  Fix error in l10n file: Toogle -> Toggle (#4453)
  Remove depandabot
  Bump junit-pioneer from 0.2.2 to 0.3.0 (#4451)
  Add Depandabot badge
  Emphasize that users should try out the newest version before reporting a bug
  Add a preference to add files in entry editor (#4408)
  Add submodule pull to circle ci and fix theme loading css (#4443)
  fix groups drag and drop (#4439)
  • Loading branch information
Siedlerchr committed Nov 3, 2018
2 parents e843eb2 + d4f6826 commit f340eec
Show file tree
Hide file tree
Showing 32 changed files with 3,920 additions and 2,044 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ jobs:
- image: circleci/openjdk:8-jdk
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
keys:
- install4j-{{ checksum "scripts/extract-install4j.sh" }}
Expand All @@ -26,6 +28,8 @@ jobs:
- restore_cache:
key: dependency-cache
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
key: install4j-{{ checksum "scripts/extract-install4j.sh" }}
- run: scripts/extract-install4j.sh
Expand All @@ -47,6 +51,8 @@ jobs:
- restore_cache:
key: dependency-cache
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
key: install4j-{{ checksum "scripts/extract-install4j.sh" }}
- run: scripts/extract-install4j.sh
Expand Down
10 changes: 9 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ Thanks!
-->

JabRef version <!-- version as shown in the about box --> on <!-- Windows 10|Ubuntu 14.04|Mac OS X 10.8|... -->
<!-- Hint: If you use a development version (available at http://builds.jabref.org/master/), ensure that you use the latest one. -->

<!-- IMPORTANT NOTE ->
<!--
Please always test if the bug is still reproducible in the latest development version.
We are constantly improving JabRef and some bugs may already be fixed.
You can download the development version at: http://builds.jabref.org/master/
Please make a backup of your library before you try out this version.
If you already use a development version, ensure that you use the latest one.
-->
- [ ] I have tested the latest development version from http://builds.jabref.org/master/ and the problem persists

<!-- Add a clear and concise description of what the bug is. -->
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Alexsandro Lauber
Ali Ayan
Alick Zhao
Ambrogio Oliva
Amish Shah
Andreas Amann
Andreas Buhr
Andreas Rudert
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We added a new keyboard shortcut so that the entry editor could be closed by <kbd>Ctrl<kbd> + <kbd>E<kbd>. [#4222] (https://github.com/JabRef/jabref/issues/4222)
- We added an option in the preference dialog box, that allows user to pick the dark or light theme option. [#4130] (https://github.com/JabRef/jabref/issues/4130)
- We updated updated the Related Articles tab to accept JSON from the new version of the Mr. DLib service

- We added an option in the preference dialog box that allows user to choose behavior after dragging and dropping files in Entry Editor. [#4356](https://github.com/JabRef/jabref/issues/4356)



Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'
testCompile 'org.junit.platform:junit-platform-launcher:1.3.1'
testCompile 'org.junit-pioneer:junit-pioneer:0.2.2'
testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1'
testCompile 'org.mockito:mockito-core:2.23.0'
Expand Down
64 changes: 54 additions & 10 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,63 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda
if (event.getDragboard().hasContent(DataFormat.FILES)) {
List<Path> files = event.getDragboard().getFiles().stream().map(File::toPath).collect(Collectors.toList());

if (event.getTransferMode() == TransferMode.MOVE) {

LOGGER.debug("Mode MOVE"); //shift on win or no modifier
fileHandler.addToEntryRenameAndMoveToFileDir(entry, files);
FileDragDropPreferenceType dragDropPreferencesType = Globals.prefs.getEntryEditorFileLinkPreference();

if (dragDropPreferencesType == FileDragDropPreferenceType.MOVE)
{
if (event.getTransferMode() == TransferMode.LINK) //alt on win
{
LOGGER.debug("Mode LINK");
fileHandler.addToEntry(entry, files);
}
else if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu
{
LOGGER.debug("Mode COPY");
fileHandler.copyFilesToFileDirAndAddToEntry(entry, files);
}
else
{
LOGGER.debug("Mode MOVE"); //shift on win or no modifier
fileHandler.addToEntryRenameAndMoveToFileDir(entry, files);
}
}
if (event.getTransferMode() == TransferMode.LINK) {
LOGGER.debug("Node LINK"); //alt on win
fileHandler.addToEntry(entry, files);

if (dragDropPreferencesType == FileDragDropPreferenceType.COPY)
{
if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu
{
LOGGER.debug("Mode MOVE");
fileHandler.addToEntryRenameAndMoveToFileDir(entry, files);
}
else if (event.getTransferMode() == TransferMode.LINK) //alt on win
{
LOGGER.debug("Mode LINK");
fileHandler.addToEntry(entry, files);
}
else
{
LOGGER.debug("Mode COPY"); //shift on win or no modifier
fileHandler.copyFilesToFileDirAndAddToEntry(entry, files);
}
}
if (event.getTransferMode() == TransferMode.COPY) {
LOGGER.debug("Mode Copy"); //ctrl on win, no modifier on Xubuntu
fileHandler.copyFilesToFileDirAndAddToEntry(entry, files);

if (dragDropPreferencesType == FileDragDropPreferenceType.LINK)
{
if (event.getTransferMode() == TransferMode.COPY) //ctrl on win, no modifier on Xubuntu
{
LOGGER.debug("Mode COPY");
fileHandler.copyFilesToFileDirAndAddToEntry(entry, files);
}
else if (event.getTransferMode() == TransferMode.LINK) //alt on win
{
LOGGER.debug("Mode MOVE");
fileHandler.addToEntryRenameAndMoveToFileDir(entry, files);
}
else
{
LOGGER.debug("Mode LINK"); //shift on win or no modifier
fileHandler.addToEntry(entry, files);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jabref.gui.entryeditor;

public enum FileDragDropPreferenceType {
COPY,
LINK,
MOVE;
}
36 changes: 1 addition & 35 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.jabref.gui.fieldeditors;

import java.io.File;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javafx.beans.binding.Bindings;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -71,41 +68,14 @@ public LinkedFilesEditor(String fieldName, DialogService dialogService, BibDatab

listView.setCellFactory(cellFactory);

setUpFilesDragAndDrop();
Bindings.bindContentBidirectional(listView.itemsProperty().get(), viewModel.filesProperty());
setUpKeyBindings();
}

private void setUpFilesDragAndDrop() {
listView.setOnDragOver(event -> {
if (event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.COPY, TransferMode.LINK);
}
});

listView.setOnDragDropped(event -> {
Dragboard dragboard = event.getDragboard();
boolean success = false;
ObservableList<LinkedFileViewModel> items = listView.itemsProperty().get();

if (dragboard.hasFiles()) {
List<LinkedFileViewModel> linkedFiles = dragboard.getFiles().stream().map(File::toPath).map(viewModel::fromFile).collect(Collectors.toList());
items.addAll(linkedFiles);
success = true;
}
event.setDropCompleted(success);
event.consume();
});

}

private void handleOnDragOver(LinkedFileViewModel originalItem, DragEvent event) {
if ((event.getGestureSource() != originalItem) && event.getDragboard().hasContent(DragAndDropDataFormats.LINKED_FILE)) {
event.acceptTransferModes(TransferMode.MOVE);
}
if (event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.COPY, TransferMode.LINK);
}
}

private void handleOnDragDetected(@SuppressWarnings("unused") LinkedFileViewModel linkedFile, MouseEvent event) {
Expand Down Expand Up @@ -143,11 +113,7 @@ private void handleOnDragDropped(LinkedFileViewModel originalItem, DragEvent eve
items.set(thisIdx, transferedItem);
success = true;
}
if (dragboard.hasFiles()) {
List<LinkedFileViewModel> linkedFiles = dragboard.getFiles().stream().map(File::toPath).map(viewModel::fromFile).collect(Collectors.toList());
items.addAll(linkedFiles);
success = true;
}

event.setDropCompleted(success);
event.consume();

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/groups/GroupModeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class GroupModeViewModel {

private GroupViewMode mode;
private final GroupViewMode mode;

public GroupModeViewModel(GroupViewMode mode) {
this.mode = mode;
Expand All @@ -27,9 +27,9 @@ public Node getUnionIntersectionGraphic() {

public Tooltip getUnionIntersectionTooltip() {
if (mode == GroupViewMode.UNION) {
return new Tooltip(Localization.lang("Toogle intersection"));
return new Tooltip(Localization.lang("Toggle intersection"));
} else if (mode == GroupViewMode.INTERSECTION) {
return new Tooltip(Localization.lang("Toogle union"));
return new Tooltip(Localization.lang("Toggle union"));
}
return new Tooltip();
}
Expand Down
42 changes: 23 additions & 19 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,21 @@ public void initialize() {

// Drag and drop support
row.setOnDragDetected(event -> {
TreeItem<GroupNodeViewModel> selectedItem = treeTable.getSelectionModel().getSelectedItem();
if ((selectedItem != null) && (selectedItem.getValue() != null)) {
Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);

// Display the group when dragging
dragboard.setDragView(row.snapshot(null, null));

// Put the group node as content
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.GROUP, selectedItem.getValue().getPath());
dragboard.setContent(content);

event.consume();
List<String> groupsToMove = new ArrayList<>();
for (TreeItem<GroupNodeViewModel> selectedItem : treeTable.getSelectionModel().getSelectedItems()) {
if ((selectedItem != null) && (selectedItem.getValue() != null)) {
groupsToMove.add(selectedItem.getValue().getPath());
}
}

// Put the group nodes as content
Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);
// Display the group when dragging
dragboard.setDragView(row.snapshot(null, null));
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.GROUP, groupsToMove);
dragboard.setContent(content);
event.consume();
});
row.setOnDragOver(event -> {
Dragboard dragboard = event.getDragboard();
Expand Down Expand Up @@ -240,13 +241,16 @@ public void initialize() {
row.setOnDragDropped(event -> {
Dragboard dragboard = event.getDragboard();
boolean success = false;

if (dragboard.hasContent(DragAndDropDataFormats.GROUP)) {
String pathToSource = (String) dragboard.getContent(DragAndDropDataFormats.GROUP);
Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get()
.getChildByPath(pathToSource);
if (source.isPresent()) {
source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
success = true;
List<String> pathToSources = (List<String>) dragboard.getContent(DragAndDropDataFormats.GROUP);
for (String pathToSource : pathToSources) {
Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get()
.getChildByPath(pathToSource);
if (source.isPresent()) {
source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
success = true;
}
}
}

Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/jabref/gui/preferences/EntryEditorPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.jabref.gui.autocompleter.AutoCompleteFirstNameMode;
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.entryeditor.FileDragDropPreferenceType;
import org.jabref.gui.keyboard.EmacsKeyBindings;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
Expand Down Expand Up @@ -42,10 +43,14 @@ class EntryEditorPrefsTab extends Pane implements PrefsTab {
private final JabRefPreferences prefs;
private final AutoCompletePreferences autoCompletePreferences;

private final RadioButton copyFile;
private final RadioButton linkFile;
private final RadioButton renameCopyFile;

public EntryEditorPrefsTab(JabRefPreferences prefs) {
this.prefs = prefs;
autoCompletePreferences = prefs.getAutoCompletePreferences();

autoOpenForm = new CheckBox(Localization.lang("Open editor when a new entry is created"));
defSource = new CheckBox(Localization.lang("Show BibTeX source by default"));
emacsMode = new CheckBox(Localization.lang("Use Emacs key bindings"));
Expand Down Expand Up @@ -123,6 +128,20 @@ public EntryEditorPrefsTab(JabRefPreferences prefs) {
firstNameModeAbbr.setToggleGroup(treatmentOfFirstNamesToggleGroup);
firstNameModeFull.setToggleGroup(treatmentOfFirstNamesToggleGroup);
firstNameModeBoth.setToggleGroup(treatmentOfFirstNamesToggleGroup);

final ToggleGroup group = new ToggleGroup();
Label linkFileOptions = new Label(Localization.lang("Default drag & drop action"));
linkFileOptions.getStyleClass().add("sectionHeader");
copyFile = new RadioButton(Localization.lang("Copy file to default file folder"));
linkFile = new RadioButton(Localization.lang("Link file (without copying)"));
renameCopyFile = new RadioButton(Localization.lang("Copy, rename and link file"));
builder.add(linkFileOptions, 1, 23);
builder.add(copyFile, 1, 24);
builder.add(linkFile, 1, 25);
builder.add(renameCopyFile, 1, 26);
copyFile.setToggleGroup(group);
linkFile.setToggleGroup(group);
renameCopyFile.setToggleGroup(group);
}

@Override
Expand Down Expand Up @@ -172,6 +191,15 @@ public void setValues() {
break;
}

FileDragDropPreferenceType dragDropPreferenceType = prefs.getEntryEditorFileLinkPreference();
if (dragDropPreferenceType == FileDragDropPreferenceType.COPY) {
copyFile.setSelected(true);
} else if (dragDropPreferenceType == FileDragDropPreferenceType.LINK) {
linkFile.setSelected(true);
} else {
renameCopyFile.setSelected(true);
}

// similar for emacs CTRL-a and emacs mode
emacsRebindCtrlA.setDisable(!emacsMode.isSelected());
// Autocomplete fields is only enabled when autocompletion is selected
Expand Down Expand Up @@ -230,6 +258,15 @@ else if (autoCompFF.isSelected()) {
} else {
autoCompletePreferences.setFirstNameMode(AutoCompleteFirstNameMode.BOTH);
}

if (copyFile.isSelected()) {
prefs.storeEntryEditorFileLinkPreference(FileDragDropPreferenceType.COPY);
} else if (linkFile.isSelected()) {
prefs.storeEntryEditorFileLinkPreference(FileDragDropPreferenceType.LINK);
} else {
prefs.storeEntryEditorFileLinkPreference(FileDragDropPreferenceType.MOVE);
}

prefs.storeAutoCompletePreferences(autoCompletePreferences);
}

Expand Down
Loading

0 comments on commit f340eec

Please sign in to comment.