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

Implement drag and drop for maintable #3765

Merged
merged 64 commits into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
c29344b
Implement drag and drop for maintable
Siedlerchr Feb 22, 2018
80a3a63
Use BibtexWriter to serialize all entries and parser to deserialize
Siedlerchr Feb 22, 2018
8f17758
try further around with serializing and deserializing
Siedlerchr Feb 23, 2018
bb14f03
Add new Dataformat for List<BibEntry>
Siedlerchr Feb 23, 2018
d02f180
Add DragAndDropDataFormat
Siedlerchr Feb 23, 2018
cc2c1d2
drag and drop to groups works now
Siedlerchr Feb 23, 2018
9eee5ae
Prepare File Dropping
Siedlerchr Feb 23, 2018
9989f9e
No reordering of items in the maintable via drag and drop
Siedlerchr Feb 23, 2018
b25151e
add basic support for adding droppped file to entry
Siedlerchr Feb 23, 2018
262e0c9
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Feb 28, 2018
d8ee0e8
add check for transfer mode move and link
Siedlerchr Feb 28, 2018
744726a
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Mar 9, 2018
adf4cba
Add link to file handler
Siedlerchr Mar 9, 2018
e12335d
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Mar 14, 2018
0ebdcfb
add dialog for importing entries from xmp
Siedlerchr Mar 14, 2018
718eb4e
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Mar 16, 2018
d4a5af4
prepare pdf content importer code
Siedlerchr Mar 16, 2018
0bce0ec
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Mar 30, 2018
ad4ef86
remove no longer needed loop
Siedlerchr Mar 30, 2018
317a77f
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr Apr 1, 2018
4982e4c
add XMPPreferences to ImportFormatPreferences
Siedlerchr Apr 1, 2018
fa9d08c
Merge remote-tracking branch 'upstream/maintable-beta' into fixdragan…
Siedlerchr May 10, 2018
77c5e82
when no modifier is avaiable show Dialog if xmp entries found
Siedlerchr May 10, 2018
0c5eb0c
rework copy options using clipboard manager
Siedlerchr May 10, 2018
4dac741
TODO: Find out why dnd doesn't work on preview panel
Siedlerchr May 10, 2018
a8c3a67
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Jun 5, 2018
236646b
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Jun 8, 2018
6987735
fix checkstyle and compile error
Siedlerchr Jun 8, 2018
73bf304
enable dnd on preview pane
Siedlerchr Jun 8, 2018
0fffe24
add method for opening or import db
Siedlerchr Jun 8, 2018
c6fdb71
add l10n
Siedlerchr Jun 8, 2018
6e67471
checkstyle
Siedlerchr Jun 8, 2018
cab2762
Open bib files dragged to tab pane
Siedlerchr Jun 9, 2018
d779f2d
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Jun 12, 2018
6b15e31
handle import of dropped bib files
Siedlerchr Jun 12, 2018
95d0957
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Jun 15, 2018
de2f845
add drag and drop copy handler
Siedlerchr Jun 16, 2018
f35092c
fix event propagation
Siedlerchr Jun 16, 2018
60f6553
fix checkstyle
Siedlerchr Jun 16, 2018
c9f1d61
literals first in comparison
Siedlerchr Jun 16, 2018
07272ac
add l10n for error message
Siedlerchr Jun 16, 2018
1d4db3d
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Jul 26, 2018
d12446f
remove old swing related dnd stuff
Siedlerchr Jul 26, 2018
21c7955
fix merge error
Siedlerchr Jul 26, 2018
34b2f99
fix NPE discovered on linux when row.getItem is null
Siedlerchr Jul 27, 2018
6c4458f
Put Dragboard Instance into Gui Globals
Siedlerchr Jul 28, 2018
df79fa3
checkstyle
Siedlerchr Jul 28, 2018
177b7ad
fix checkstyle
Siedlerchr Jul 28, 2018
37e354c
fix l10n
Siedlerchr Jul 29, 2018
9f804d8
fix copying on linux
Siedlerchr Jul 30, 2018
737b1c3
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Aug 13, 2018
c10d838
remove old drag and drop popup classes
Siedlerchr Aug 13, 2018
58e5bcc
fix import order
Siedlerchr Aug 13, 2018
f5c62a7
Merge remote-tracking branch 'upstream/master' into fixdragandrop
Siedlerchr Aug 16, 2018
57aa79a
extract part to logic
Siedlerchr Aug 16, 2018
f1f1d91
extract files adding and content importer to own class
Siedlerchr Aug 17, 2018
8fcaf66
some cleanups
Siedlerchr Aug 17, 2018
ab1b90a
Add fileUtil method for checking if it's a bib file
Siedlerchr Aug 18, 2018
adf1095
fix l10n
Siedlerchr Aug 18, 2018
e2c6c0e
cleanup
Siedlerchr Aug 19, 2018
dfdc6dc
add methods for putting and getting bib entries of localdragboard
Siedlerchr Aug 19, 2018
259d5fd
add javadoc
Siedlerchr Aug 19, 2018
f2de954
Merge branch 'master' into fixdragandrop
tobiasdiez Aug 19, 2018
44b7524
Fix build
tobiasdiez Aug 19, 2018
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
28 changes: 15 additions & 13 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.jabref.gui;

import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.Transferable;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
Expand Down Expand Up @@ -134,7 +131,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BasePanel extends StackPane implements ClipboardOwner {
public class BasePanel extends StackPane {

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

private final BibDatabaseContext bibDatabaseContext;
Expand Down Expand Up @@ -227,8 +225,10 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas

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

this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService);
this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService, externalFileTypes);
frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview);


}

@Subscribe
Expand Down Expand Up @@ -680,15 +680,15 @@ public void runCommand(final Actions command) {
*/
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding,
SavePreferences.DatabaseSaveType saveType)
throws SaveException {
throws SaveException {
SaveSession session;
final String SAVE_DATABASE = Localization.lang("Save library");
try {
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences()
.withEncoding(encoding)
.withSaveType(saveType);
.withSaveType(saveType);
BibtexDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(
FileSaveSession::new);
FileSaveSession::new);
if (selectedOnly) {
session = databaseWriter.savePartOfDatabase(bibDatabaseContext, mainTable.getSelectedEntries(), prefs);
} else {
Expand All @@ -700,7 +700,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding,
// FIXME: not sure if this is really thrown anywhere
catch (UnsupportedCharsetException ex) {
frame.getDialogService().showErrorDialogAndWait(Localization.lang("Save library"), Localization.lang("Could not save file.")
+ Localization.lang("Character encoding '%0' is not supported.", encoding.displayName()));
+ Localization.lang("Character encoding '%0' is not supported.", encoding.displayName()));
throw new SaveException("rt");
} catch (SaveException ex) {
if (ex.specificEntry()) {
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public void entryEditorClosing(EntryEditor editor) {
*/
public void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
closeBottomPane();
}
}
Expand Down Expand Up @@ -1312,11 +1312,13 @@ private void saveDividerLocation(Number position) {
}
}

/*
Copy link
Member

Choose a reason for hiding this comment

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

Remove?

// Method pertaining to the ClipboardOwner interface.
@Override
public void lostOwnership(Clipboard clipboard, Transferable contents) {
// Nothing
}
*/

/**
* Perform necessary cleanup when this BasePanel is closed.
Expand Down Expand Up @@ -1500,7 +1502,7 @@ public void listen(EntryAddedEvent addedEntryEvent) {
if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)) {
final List<BibEntry> entries = Collections.singletonList(addedEntryEvent.getBibEntry());
Globals.stateManager.getSelectedGroup(bibDatabaseContext).forEach(
selectedGroup -> selectedGroup.addEntriesToGroup(entries));
selectedGroup -> selectedGroup.addEntriesToGroup(entries));
}
}
}
Expand Down Expand Up @@ -1601,8 +1603,8 @@ public void action() {

Optional<LinkedFile> linkedFile = files.stream()
.filter(file -> (FieldName.URL.equalsIgnoreCase(file.getFileType())
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
.findFirst();

if (linkedFile.isPresent()) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/gui/DragAndDropDataFormats.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.jabref.gui;

import java.util.List;

import javafx.scene.input.DataFormat;

import org.jabref.model.entry.BibEntry;

/**
* Contains all the different {@link DataFormat}s that may occur in JabRef.
*/
Expand All @@ -10,4 +14,6 @@ public class DragAndDropDataFormats {
public static final DataFormat GROUP = new DataFormat("dnd/org.jabref.model.groups.GroupTreeNode");
public static final DataFormat LINKED_FILE = new DataFormat("dnd/org.jabref.model.entry.LinkedFile");
public static final DataFormat ENTRIES = new DataFormat("dnd/org.jabref.model.entry.BibEntries");
@SuppressWarnings("unchecked") public static final Class<List<BibEntry>> BIBENTRY_LIST_CLASS = (Class<List<BibEntry>>) (Class<?>) List.class;

}
160 changes: 0 additions & 160 deletions src/main/java/org/jabref/gui/DragDropPane.java

This file was deleted.

31 changes: 0 additions & 31 deletions src/main/java/org/jabref/gui/DragDropPopupPane.java

This file was deleted.

7 changes: 5 additions & 2 deletions src/main/java/org/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jabref.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.keyboard.EmacsKeyBindings;
import org.jabref.gui.util.CustomLocalDragboard;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;

Expand All @@ -16,12 +17,15 @@
* Static variables for graphics files and keyboard shortcuts.
*/
public class GUIGlobals {

public static Color editorTextColor;
public static Color validFieldBackgroundColor;
public static Color activeBackgroundColor;
public static Color invalidFieldBackgroundColor;
public static Font currentFont;

public static CustomLocalDragboard localDragboard = new CustomLocalDragboard();

public static final int WIDTH_ICON_COL = 16 + 12; // add some additional space to improve appearance

public static final int WIDTH_ICON_COL_RANKING = 5 * 16; // Width of Ranking Icon Column
Expand Down Expand Up @@ -58,13 +62,12 @@ public static void init() {

IconTheme.loadFonts();
GUIGlobals.currentFont = new Font(Globals.prefs.get(JabRefPreferences.FONT_FAMILY),
Globals.prefs.getInt(JabRefPreferences.FONT_STYLE), Globals.prefs.getInt(JabRefPreferences.FONT_SIZE));
Globals.prefs.getInt(JabRefPreferences.FONT_STYLE), Globals.prefs.getInt(JabRefPreferences.FONT_SIZE));
}

public static void setFont(int size) {
currentFont = new Font(currentFont.getFamily(), currentFont.getStyle(), size);
// update preferences
Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, size);
}

}
Loading