Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into newEntryDialog
Browse files Browse the repository at this point in the history
* upstream/master:
  Fix that sometimes a white background appeared in the groups panel (#4316)
  Minimal code improvements
  Fix drag and drop in entry editor (#4311)
  • Loading branch information
Siedlerchr committed Sep 5, 2018
2 parents 0435d8f + d1da461 commit ef38692
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas

this.getDatabase().registerListener(new UpdateTimestampListener(Globals.prefs));

this.entryEditor = new EntryEditor(this, preferences.getEntryEditorPreferences(), Globals.getFileUpdateMonitor(), dialogService);
this.entryEditor = new EntryEditor(this, preferences.getEntryEditorPreferences(), Globals.getFileUpdateMonitor(), dialogService, externalFileTypes);

this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService, externalFileTypes);
frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview);
Expand Down
57 changes: 56 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.entryeditor;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -16,16 +18,21 @@
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.input.DataFormat;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;

import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.GUIGlobals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.GenerateBibtexKeySingleAction;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab;
import org.jabref.gui.externalfiles.NewDroppedFileHandler;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.menus.ChangeEntryTypeMenu;
Expand All @@ -41,10 +48,13 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.JabRefPreferences;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* GUI component that allows editing of the fields of a BibEntry (i.e. the
Expand All @@ -58,6 +68,8 @@
*/
public class EntryEditor extends BorderPane {

private static final Logger LOGGER = LoggerFactory.getLogger(EntryEditor.class);

private final BibDatabaseContext databaseContext;
private final CountingUndoManager undoManager;
private final BasePanel panel;
Expand All @@ -79,15 +91,24 @@ public class EntryEditor extends BorderPane {

private final EntryEditorPreferences preferences;
private final DialogService dialogService;
private final NewDroppedFileHandler fileHandler;

public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpdateMonitor fileMonitor, DialogService dialogService) {
public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpdateMonitor fileMonitor, DialogService dialogService, ExternalFileTypes externalFileTypes) {
this.panel = panel;
this.databaseContext = panel.getBibDatabaseContext();
this.undoManager = panel.getUndoManager();
this.preferences = Objects.requireNonNull(preferences);
this.fileMonitor = fileMonitor;
this.dialogService = dialogService;

fileHandler = new NewDroppedFileHandler(dialogService, databaseContext, externalFileTypes,
Globals.prefs.getFileDirectoryPreferences(),
Globals.prefs.getCleanupPreferences(Globals.journalAbbreviationLoader).getFileDirPattern(),
Globals.prefs.getImportFormatPreferences(),
Globals.prefs.getUpdateFieldPreferences(),
Globals.getFileUpdateMonitor(),
Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));

ViewLoader.view(this)
.root(this)
.load();
Expand All @@ -109,6 +130,40 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda
setupKeyBindings();

tabs = createTabs();

this.setOnDragOver(event -> {
if (event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.COPY, TransferMode.MOVE, TransferMode.LINK);
}
event.consume();
});

this.setOnDragDropped(event -> {
BibEntry entry = this.getEntry();
boolean success = false;
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);
}
if (event.getTransferMode() == TransferMode.LINK) {
LOGGER.debug("Node LINK"); //alt on win
fileHandler.addToEntry(entry, files);

}
if (event.getTransferMode() == TransferMode.COPY) {
LOGGER.debug("Mode Copy"); //ctrl on win, no modifier on Xubuntu
fileHandler.copyFilesToFileDirAndAddToEntry(entry, files);
}
}

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

});
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupTree.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#groupTree:focused,
#groupTree:filled:selected {
-fx-background-color: -jr-sidepane-background;
}

.tree-table-view, .tree-table-row-cell {
-fx-background-color: -jr-sidepane-background;
-fx-table-cell-border-color: transparent; /* hide grid lines */
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupTree.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<?import javafx.scene.layout.Region?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import org.controlsfx.control.textfield.CustomTextField?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="150.0" styleClass="groupsPane"
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="150.0"
xmlns="http://javafx.com/javafx/8.0.112" fx:controller="org.jabref.gui.groups.GroupTreeView">
<center>
<TreeTableView fx:id="groupTree" layoutY="-7.0" prefHeight="600.0" prefWidth="250.0" styleClass="groupsPane">
<TreeTableView fx:id="groupTree" layoutY="-7.0" prefHeight="600.0" prefWidth="250.0">
<columns>
<TreeTableColumn fx:id="mainColumn"/>
<TreeTableColumn fx:id="numberColumn" minWidth="50.0" maxWidth="70.0" prefWidth="60.0"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public MainTable(MainTableDataModel model, JabRefFrame frame,
this.setItems(model.getEntriesFilteredAndSorted());

// Enable sorting
model.bindComparator(this.comparatorProperty());
model.getEntriesFilteredAndSorted().comparatorProperty().bind(this.comparatorProperty());

this.panel = panel;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package org.jabref.gui.maintable;

import java.util.Comparator;
import java.util.List;
import java.util.Optional;

import javafx.beans.binding.Bindings;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
Expand Down Expand Up @@ -68,11 +66,7 @@ private Optional<MatcherSet> createGroupMatcher(List<GroupTreeNode> selectedGrou
return Optional.of(searchRules);
}

public ObservableList<BibEntryTableViewModel> getEntriesFilteredAndSorted() {
public SortedList<BibEntryTableViewModel> getEntriesFilteredAndSorted() {
return entriesSorted;
}

public void bindComparator(ReadOnlyObjectProperty<Comparator<BibEntryTableViewModel>> comparator) {
entriesSorted.comparatorProperty().bind(comparator);
}
}

0 comments on commit ef38692

Please sign in to comment.