Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/maintable-beta' into removeCus…
Browse files Browse the repository at this point in the history
…tomjfx

* upstream/maintable-beta: (28 commits)
  Fixes #3796: Pretend that we have every translation for every key (#3820)
  adjust line wrapping on column
  replace open office install selection dialog with choice dialog Wrap error messages in fx executor (because abstract worker is swing thread)
  Convert swing error dialog in save db action to custom fx dialog
  Replace swing export dialog in ExportToClipboardAction with fx choices dlg
  run find fulltext dialog in fx thread
  fix cut, copy & paste action from toolbar
  Set resizable for custom dialog with dialog pane convert merge entries dlg to javafx and make action working again
  checkstyle argh!
  Update test order -> Execute checkstyle first (#3807)
  embed cleanup dialog in javafx
  Fix some non FX Thread issues Main drawback: Cleanup panel is in backgroung due to swing thread)
  Allow search field to be smaller
  Fix Codacy Unused Params, Fields (#3753)
  Dialogstojavafx (#3801)
  Remove unused import
  Add group coloring in maintable as replacement for marked entries (#3769)
  Enable travis build for maintable-beta (#3804)
  Remove setting of tooltip manually
  Change open last edited dialgo to javafx (#3800)
  ...
  • Loading branch information
Siedlerchr committed Mar 10, 2018
2 parents cec8d2c + 13f59f0 commit 4bbd3b6
Show file tree
Hide file tree
Showing 103 changed files with 1,685 additions and 1,947 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ env:
global:
- GRADLE_OPTS=-Dorg.gradle.daemon=false
matrix:
- TEST_SUITE=checkstyle
- TEST_SUITE=check OPTIONS=modernizer
- TEST_SUITE=fetcherTest
- TEST_SUITE=databaseTest
- TEST_SUITE=guiTest
- TEST_SUITE=checkstyle
- TEST_SUITE=codecov
- DEPENDENCY_UPDATES=check

Expand Down Expand Up @@ -60,6 +60,7 @@ after_failure:
branches:
only:
- master
- maintable-beta

# cache gradle dependencies
# https://docs.travis-ci.com/user/languages/java#Caching
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ dependencies {
compile 'org.fxmisc.easybind:easybind:1.0.3'
compile 'org.fxmisc.flowless:flowless:0.6'
compile 'org.fxmisc.richtext:richtextfx:0.8.2'
compile 'com.sibvisions.external.jvxfx:dndtabpane:0.1'


// Cannot be updated to 9.*.* until Jabref works with Java 9
compile 'org.controlsfx:controlsfx:8.40.15-SNAPSHOT'
Expand Down
5 changes: 5 additions & 0 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ Project: Application Insights SDK for Java
URL: https://github.com/Microsoft/ApplicationInsights-Java
License: MIT

Id: com.sibvisions.external.jvxfx:DnDTabPane
Project: Drag'n'Drop TabPane
URL: https://github.com/sibvisions/javafx.DndTabPane
License: EPL-1.0

Id: commons-cli:commons-cli
Project: Apache Commons CLI
URL: http://commons.apache.org/cli/
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.jabref.gui.AbstractView;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.FXDialogService;
import org.jabref.gui.GUIGlobals;
import org.jabref.gui.IconTheme;
import org.jabref.gui.JabRefFrame;
Expand Down Expand Up @@ -50,12 +52,14 @@ public class JabRefGUI {
private final boolean isBlank;
private final List<ParserResult> failed = new ArrayList<>();
private final List<ParserResult> toOpenTab = new ArrayList<>();
private final DialogService dialogService;

private final String focusedFile;

public JabRefGUI(Stage mainStage, List<ParserResult> argsDatabases, boolean isBlank) {
this.bibDatabases = argsDatabases;
this.isBlank = isBlank;
this.dialogService = new FXDialogService(mainStage);

// passed file (we take the first one) should be focused
focusedFile = argsDatabases.stream().findFirst().flatMap(ParserResult::getFile).map(File::getAbsolutePath)
Expand Down Expand Up @@ -158,12 +162,11 @@ private void openWindow(Stage mainStage) {
});

for (ParserResult pr : failed) {
String message = "<html>" + Localization.lang("Error opening file '%0'.", pr.getFile().get().getName())
+ "<p>"
+ pr.getErrorMessage() + "</html>";
String message = Localization.lang("Error opening file '%0'.", pr.getFile().get().getName()) + "\n"
+ pr.getErrorMessage();

dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), message);

JOptionPane.showMessageDialog(null, message, Localization.lang("Error opening file"),
JOptionPane.ERROR_MESSAGE);
}

// Display warnings, if any
Expand Down Expand Up @@ -205,7 +208,7 @@ private void openLastEditedDatabases() {
}

if (BackupManager.checkForBackupFile(dbFile.toPath())) {
BackupUIManager.showRestoreBackupDialog(null, dbFile.toPath());
BackupUIManager.showRestoreBackupDialog(dialogService, dbFile.toPath());
}

ParserResult parsedDatabase = OpenDatabase.loadDatabase(fileName,
Expand Down Expand Up @@ -263,11 +266,11 @@ private void setLookAndFeel() {
// also set system l&f as default
Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLookFeel);
// notify the user
JOptionPane.showMessageDialog(null,
Localization
.lang("Unable to find the requested look and feel and thus the default one is used."),
Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);

LOGGER.warn("Unable to find requested look and feel", e);
dialogService.showWarningDialogAndWait(Localization.lang("Warning"),
Localization.lang("Unable to find the requested look and feel and thus the default one is used."));

}
}

Expand Down
92 changes: 24 additions & 68 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.jabref.gui.journals.UnabbreviateAction;
import org.jabref.gui.maintable.MainTable;
import org.jabref.gui.maintable.MainTableDataModel;
import org.jabref.gui.mergeentries.MergeEntriesDialog;
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
import org.jabref.gui.specialfields.SpecialFieldDatabaseChangeListener;
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
Expand All @@ -84,7 +85,6 @@
import org.jabref.gui.undo.UndoableRemoveEntry;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.component.CheckBoxMessage;
import org.jabref.gui.worker.AbstractWorker;
import org.jabref.gui.worker.CallBack;
import org.jabref.gui.worker.CitationStyleToClipboardWorker;
Expand Down Expand Up @@ -158,7 +158,7 @@ public class BasePanel extends StackPane implements ClipboardOwner {
// Keeps track of the string dialog if it is open.
private final Map<Actions, Object> actions = new HashMap<>();
private final SidePaneManager sidePaneManager;
private final PreviewPanel preview;
private PreviewPanel preview;
private final BasePanelPreferences preferences;
private final ExternalFileTypes externalFileTypes;

Expand Down Expand Up @@ -237,7 +237,7 @@ 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);
DefaultTaskExecutor.runInJavaFXThread(() -> this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService));
DefaultTaskExecutor.runInJavaFXThread(() -> frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview));
}

Expand Down Expand Up @@ -349,8 +349,6 @@ private void setupActions() {

actions.put(Actions.CUT, (BaseAction) mainTable::cut);

//when you modify this action be sure to adjust Actions.CUT,
//they are the same except of the Localization, delete confirmation and Actions.COPY call
actions.put(Actions.DELETE, (BaseAction) () -> delete(false));

// The action for pasting entries or cell contents.
Expand Down Expand Up @@ -422,15 +420,16 @@ public void run() {
// if we're going to override some cite keys warn the user about it
} else if (Globals.prefs.getBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY)) {
if (entries.parallelStream().anyMatch(BibEntry::hasCiteKey)) {
CheckBoxMessage cbm = new CheckBoxMessage(

boolean overwriteKeysPressed = dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Overwrite keys"),
Localization.lang("One or more keys will be overwritten. Continue?"),
Localization.lang("Disable this confirmation dialog"), false);
final int answer = JOptionPane.showConfirmDialog(null, cbm,
Localization.lang("Overwrite keys"), JOptionPane.YES_NO_OPTION);
Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, !cbm.isSelected());
Localization.lang("Overwrite keys"),
Localization.lang("Cancel"),
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, !optOut));

// The user doesn't want to overide cite keys
if (answer == JOptionPane.NO_OPTION) {
if (!overwriteKeysPressed) {
canceled = true;
return;
}
Expand Down Expand Up @@ -467,7 +466,7 @@ public void update() {
// The action for cleaning up entry.
actions.put(Actions.CLEANUP, cleanUpAction);

//actions.put(Actions.MERGE_ENTRIES, (BaseAction) () -> new MergeEntriesDialog(BasePanel.this));
actions.put(Actions.MERGE_ENTRIES, (BaseAction) () -> new MergeEntriesDialog(BasePanel.this, dialogService));

actions.put(Actions.SEARCH, (BaseAction) frame.getGlobalSearchBar()::focus);
actions.put(Actions.GLOBAL_SEARCH, (BaseAction) frame.getGlobalSearchBar()::performGlobalSearch);
Expand Down Expand Up @@ -527,7 +526,7 @@ public void update() {

actions.put(Actions.OPEN_URL, new OpenURLAction());

actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this));
actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this, frame.getDialogService()));

actions.put(Actions.REPLACE_ALL, (BaseAction) () -> {
final ReplaceStringDialog rsd = new ReplaceStringDialog(frame);
Expand Down Expand Up @@ -560,47 +559,6 @@ public void update() {
(BaseAction) () -> JabRefExecutorService.INSTANCE.execute(new DuplicateSearch(BasePanel.this)));
*/

// TODO
//actions.put(Actions.MARK_ENTRIES, new MarkEntriesAction(frame, 0));

actions.put(Actions.UNMARK_ENTRIES, (BaseAction) () -> {
try {
List<BibEntry> bes = mainTable.getSelectedEntries();
if (bes.isEmpty()) {
output(Localization.lang("This operation requires one or more entries to be selected."));
return;
}
NamedCompound ce = new NamedCompound(Localization.lang("Unmark entries"));
for (BibEntry be : bes) {
EntryMarker.unmarkEntry(be, false, bibDatabaseContext.getDatabase(), ce);
}
ce.end();
getUndoManager().addEdit(ce);
markBaseChanged();
String outputStr;
if (bes.size() == 1) {
outputStr = Localization.lang("Unmarked selected entry");
} else {
outputStr = Localization.lang("Unmarked all %0 selected entries", Integer.toString(bes.size()));
}
output(outputStr);
} catch (Throwable ex) {
LOGGER.warn("Could not unmark", ex);
}
});

actions.put(Actions.UNMARK_ALL, (BaseAction) () -> {
NamedCompound ce = new NamedCompound(Localization.lang("Unmark all"));

for (BibEntry be : bibDatabaseContext.getDatabase().getEntries()) {
EntryMarker.unmarkEntry(be, false, bibDatabaseContext.getDatabase(), ce);
}
ce.end();
getUndoManager().addEdit(ce);
markBaseChanged();
output(Localization.lang("Unmarked all entries"));
});

// Note that we can't put the number of entries that have been reverted into the undoText as the concrete number cannot be injected
actions.put(new SpecialFieldValueViewModel(SpecialField.RELEVANCE.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(
Expand Down Expand Up @@ -659,7 +617,7 @@ public void update() {
actions.put(Actions.REMOVE_FROM_GROUP, new GroupAddRemoveDialog(this, false, false));
actions.put(Actions.MOVE_TO_GROUP, new GroupAddRemoveDialog(this, true, true));

actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(this));
actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(frame.getDialogService(), this));
}

/**
Expand Down Expand Up @@ -968,6 +926,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset enc,
new String[] {Localization.lang("Save"), tryDiff, Localization.lang("Cancel")}, tryDiff);

if (answer == JOptionPane.NO_OPTION) {

// The user wants to use another encoding.
Object choice = JOptionPane.showInputDialog(null, Localization.lang("Select encoding"), SAVE_DATABASE,
JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, enc);
Expand Down Expand Up @@ -1562,22 +1521,21 @@ private void changeType(List<BibEntry> entries, String newType) {

public boolean showDeleteConfirmationDialog(int numberOfEntries) {
if (Globals.prefs.getBoolean(JabRefPreferences.CONFIRM_DELETE)) {
String msg;
msg = Localization.lang("Really delete the selected entry?");
String title = Localization.lang("Delete entry");
String message = Localization.lang("Really delete the selected entry?");
String okButton = Localization.lang("Delete entry");
String cancelButton = Localization.lang("Keep entry");
if (numberOfEntries > 1) {
msg = Localization.lang("Really delete the %0 selected entries?", Integer.toString(numberOfEntries));
title = Localization.lang("Delete multiple entries");
message = Localization.lang("Really delete the %0 selected entries?", Integer.toString(numberOfEntries));
okButton = Localization.lang("Delete entries");
cancelButton = Localization.lang("Keep entries");
}

CheckBoxMessage cb = new CheckBoxMessage(msg, Localization.lang("Disable this confirmation dialog"), false);

int answer = JOptionPane.showConfirmDialog(null, cb, title, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (cb.isSelected()) {
Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, false);
}
return answer == JOptionPane.YES_OPTION;
return dialogService.showConfirmationDialogWithOptOutAndWait(title, message,
okButton, cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
} else {
return true;
}
Expand Down Expand Up @@ -1963,8 +1921,6 @@ private class RedoAction implements BaseAction {
@Override
public void action() {
try {

JComponent focused = Globals.getFocusListener().getFocused();
getUndoManager().redo();
markBaseChanged();
frame.output(Localization.lang("Redo"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/BasePanelPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public BasePanelPreferences(MainTablePreferences tablePreferences, AutoCompleteP

public static BasePanelPreferences from(JabRefPreferences preferences) {
BasePanelPreferences basePanelPreferences = new BasePanelPreferences(
MainTablePreferences.from(preferences),
preferences.getMainTablePreferences(),
preferences.getAutoCompletePreferences(),
EntryEditorPreferences.from(preferences),
Globals.getKeyPrefs(),
Expand Down
Loading

0 comments on commit 4bbd3b6

Please sign in to comment.