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

Getting Rid of Swing #4894

Merged
merged 30 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7efd35f
Add Architecture Test for the usage of Swing and JGoodies
LinusDietz Apr 18, 2019
e47970a
Delete unused classes
LinusDietz Apr 18, 2019
7681ac5
Fix test for matching sub-packages of Swing and JGoodies
LinusDietz Apr 18, 2019
90a64e1
Merge branch 'master' of https://github.com/JabRef/jabref into swing-…
LinusDietz Apr 18, 2019
176a4b9
remove iconset and obsolete key methods
Siedlerchr Apr 18, 2019
3418ca6
remove some more keybindings
Siedlerchr Apr 18, 2019
a9fcb84
Remove FileListTableModel and associated class, improve opening file …
Siedlerchr Apr 18, 2019
5551b60
remove showMessage
Siedlerchr Apr 18, 2019
0f42801
remove swing from file type
Siedlerchr Apr 18, 2019
807e9d0
remove whitespace
Siedlerchr Apr 18, 2019
d214b7f
fix loading of external file type edit dialog
Siedlerchr Apr 18, 2019
69ec0a3
Merge remote-tracking branch 'upstream/master' into swing-test
Siedlerchr Apr 18, 2019
63199fc
remove glazedlists, this time remove all dependencies
Siedlerchr Apr 18, 2019
91e6572
Merge remote-tracking branch 'upstream/master' into swing-test
Siedlerchr Apr 30, 2019
672ca79
remove emacs keybinding
Siedlerchr Apr 30, 2019
47cac3e
remove emacs keybinding rest
Siedlerchr Apr 30, 2019
2104788
Improve tests to exclude the UndoManager
LinusDietz May 2, 2019
76b27a3
Deleted unused FieldSetComponent
LinusDietz May 2, 2019
17d33c0
Merge branch 'master' into swing-test
LinusDietz Jun 6, 2019
f9997ed
Check for awt usages
tobiasdiez Jun 6, 2019
0937d01
Merge remote-tracking branch 'upstream/master' into swing-test
Siedlerchr Jun 8, 2019
70a5c67
Remove awt font and color methods
Siedlerchr Jun 8, 2019
c36af5e
enable backwards compatiblitiy with font size
Siedlerchr Jun 9, 2019
e89333c
Merge remote-tracking branch 'upstream/master' into swing-test
Siedlerchr Jul 25, 2019
4985ca1
Fix remaining swing issues
Siedlerchr Jul 25, 2019
9784798
fix l10n
Siedlerchr Jul 25, 2019
fa25c93
Merge branch 'master' into swing-test
LinusDietz Aug 13, 2019
3e1270d
fix mods tests
LinusDietz Aug 13, 2019
a78f1be
Merge pull request #5189 from JabRef/fix-swing-test
LinusDietz Aug 13, 2019
18ccbb4
Merge remote-tracking branch 'upstream/master' into swing-test
Siedlerchr Aug 23, 2019
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
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ dependencies {

compile 'org.postgresql:postgresql:42.2.6'

compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1'

compile 'com.google.guava:guava:28.0-jre'

// JavaFX stuff
Expand Down
83 changes: 36 additions & 47 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -14,7 +13,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import javax.swing.SwingUtilities;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;

Expand Down Expand Up @@ -45,12 +43,8 @@
import org.jabref.gui.exporter.SaveDatabaseAction;
import org.jabref.gui.exporter.WriteXMPAction;
import org.jabref.gui.externalfiles.FindFullTextAction;
import org.jabref.gui.externalfiletype.ExternalFileMenuItem;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.filelist.FileListEntry;
import org.jabref.gui.filelist.FileListTableModel;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.gui.importer.actions.AppendDatabaseAction;
import org.jabref.gui.journals.AbbreviateAction;
import org.jabref.gui.journals.UnabbreviateAction;
Expand Down Expand Up @@ -92,6 +86,7 @@
import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.database.shared.DatabaseSynchronizer;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FileFieldParser;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.event.EntryChangedEvent;
import org.jabref.model.entry.event.EntryEventSource;
Expand Down Expand Up @@ -342,25 +337,25 @@ private void setupActions() {
actions.put(Actions.REPLACE_ALL, () -> (new ReplaceStringAction(this)).execute());

actions.put(new SpecialFieldValueViewModel(SpecialField.RELEVANCE.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.QUALITY.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.PRINTED.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));

for (SpecialFieldValue prio : SpecialField.PRIORITY.getValues()) {
actions.put(new SpecialFieldValueViewModel(prio).getCommand(),
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
}
for (SpecialFieldValue rank : SpecialField.RANKING.getValues()) {
actions.put(new SpecialFieldValueViewModel(rank).getCommand(),
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
}
for (SpecialFieldValue status : SpecialField.READ_STATUS.getValues()) {
actions.put(new SpecialFieldValueViewModel(status).getCommand(),
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
}

actions.put(Actions.TOGGLE_PREVIEW, () -> {
Expand Down Expand Up @@ -532,7 +527,7 @@ private void copyKeyAndTitle() {
Layout layout;
try {
layout = new LayoutHelper(sr, Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader))
.getLayoutFromText();
.getLayoutFromText();
} catch (IOException e) {
LOGGER.info("Could not get layout", e);
return;
Expand Down Expand Up @@ -579,16 +574,21 @@ private void openExternalFile() {
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
return;
}
FileListTableModel fileListTableModel = new FileListTableModel();
entry.getField(StandardField.FILE).ifPresent(fileListTableModel::setContent);
if (fileListTableModel.getRowCount() == 0) {

List<LinkedFile> files = new ArrayList<>();
entry.getField(StandardField.FILE).map(FileFieldParser::parse).ifPresent(files::addAll);

if (files.isEmpty()) {
// content in BibTeX field is not readable
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
return;
}
FileListEntry flEntry = fileListTableModel.getEntry(0);
ExternalFileMenuItem item = new ExternalFileMenuItem(frame(), "", flEntry.getLink(), flEntry.getType().map(ExternalFileType::getIcon).map(JabRefIcon::getSmallIcon).orElse(null), bibDatabaseContext, flEntry.getType());
item.doClick();
LinkedFile flEntry = files.get(0);
try {
JabRefDesktop.openExternalFileAnyFormat(this.getBibDatabaseContext(), flEntry.getLink(), ExternalFileTypes.getInstance().fromLinkedFile(flEntry, true));
} catch (IOException ex) {
dialogService.showErrorDialogAndWait(ex);
}
});
}

Expand Down Expand Up @@ -828,9 +828,8 @@ public EntryEditor getEntryEditor() {
}

/**
* Sets the entry editor as the bottom component in the split pane. If an entry editor already was shown,
* makes sure that the divider doesn't move. Updates the mode to SHOWING_EDITOR.
* Then shows the given entry.
* Sets the entry editor as the bottom component in the split pane. If an entry editor already was shown, makes sure
* that the divider doesn't move. Updates the mode to SHOWING_EDITOR. Then shows the given entry.
*
* @param entry The entry to edit.
*/
Expand Down Expand Up @@ -949,8 +948,7 @@ public void entryEditorClosing(EntryEditor editor) {
* Closes the entry editor or preview panel if it is showing the given entry.
*/
public void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))
|| ((mode == BasePanelMode.SHOWING_PREVIEW))) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry)) || ((mode == BasePanelMode.SHOWING_PREVIEW))) {
closeBottomPane();
}
}
Expand All @@ -964,16 +962,7 @@ public void updateEntryEditorIfShowing() {

public void markBaseChanged() {
baseChanged = true;

if (SwingUtilities.isEventDispatchThread()) {
markBasedChangedInternal();
} else {
try {
SwingUtilities.invokeAndWait(() -> markBasedChangedInternal());
} catch (InvocationTargetException | InterruptedException e) {
LOGGER.info("Problem marking database as changed", e);
}
}
markBasedChangedInternal();
}

private void markBasedChangedInternal() {
Expand Down Expand Up @@ -1021,18 +1010,19 @@ public boolean showDeleteConfirmationDialog(int numberOfEntries) {
}

return dialogService.showConfirmationDialogWithOptOutAndWait(title,
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
} else {
return true;
}
}

/**
* Depending on whether a preview or an entry editor is showing, save the current divider location in the correct preference setting.
* Depending on whether a preview or an entry editor is showing, save the current divider location in the correct
* preference setting.
*/
private void saveDividerLocation(Number position) {
if (position == null) {
Expand Down Expand Up @@ -1224,7 +1214,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 All @@ -1239,8 +1229,7 @@ public void listen(EntryRemovedEvent entryRemovedEvent) {

/**
* Ensures that the search auto completer is up to date when entries are changed AKA Let the auto completer, if any,
* harvest words from the entry
* Actual methods for autocomplete indexing must run in javafx thread
* harvest words from the entry Actual methods for autocomplete indexing must run in javafx thread
*/
private class SearchAutoCompleteListener {

Expand All @@ -1256,8 +1245,8 @@ public void listen(EntryChangedEvent entryChangedEvent) {
}

/**
* Ensures that the results of the current search are updated when a new entry is inserted into the database
* Actual methods for performing search must run in javafx thread
* Ensures that the results of the current search are updated when a new entry is inserted into the database Actual
* methods for performing search must run in javafx thread
*/
private class SearchListener {

Expand Down Expand Up @@ -1331,8 +1320,8 @@ public void action() {
try {

JabRefDesktop.openExternalFileAnyFormat(bibDatabaseContext,
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));

output(Localization.lang("External viewer called") + '.');
} catch (IOException e) {
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/org/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.jabref.gui;

import java.awt.Color;
import java.awt.Font;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;

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 Down Expand Up @@ -45,20 +44,15 @@ public static void updateEntryEditorColors() {
* on Un*x is unavailable.
*/
public static void init() {
if (Globals.prefs.getBoolean(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS)) {
EmacsKeyBindings.load();
}

// Set up entry editor colors, first time:
GUIGlobals.updateEntryEditorColors();

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

public static void setFont(int size) {
currentFont = new Font(currentFont.getFamily(), currentFont.getStyle(), size);
public static void setFont(double size) {
currentFont = new Font(currentFont.getFamily(), size);
// update preferences
Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, size);
}
Expand Down
54 changes: 0 additions & 54 deletions src/main/java/org/jabref/gui/JabRefDialog.java

This file was deleted.

24 changes: 4 additions & 20 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import java.util.TimerTask;
import java.util.stream.Collectors;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
Expand Down Expand Up @@ -294,9 +291,7 @@ private void initShowTrackingNotification() {

@Override
public void run() {
SwingUtilities.invokeLater(() -> {
DefaultTaskExecutor.runInJavaFXThread(JabRefFrame.this::showTrackingNotification);
});
}
}, 60000); // run in one minute
}
Expand Down Expand Up @@ -402,6 +397,8 @@ private void tearDownJabRef(List<String> filenames) {
prefs.flush();

// dispose all windows, even if they are not displayed anymore
// TODO: javafx variant only avaiable in java 9 and updwards
// https://docs.oracle.com/javase/9/docs/api/javafx/stage/Window.html#getWindows--
for (Window window : Window.getWindows()) {
window.dispose();
}
Expand Down Expand Up @@ -1063,18 +1060,9 @@ public void setProgressBarVisible(final boolean visible) {
/**
* Sets the indeterminate status of the progress bar.
* <p>
* If not called on the event dispatch thread, this method uses SwingUtilities.invokeLater() to do the actual
* operation on the EDT.
*/
public void setProgressBarIndeterminate(final boolean value) {
// TODO: Reimplement
/*
if (SwingUtilities.isEventDispatchThread()) {
progressBar.setIndeterminate(value);
} else {
SwingUtilities.invokeLater(() -> progressBar.setIndeterminate(value));
}
*/
progressBar.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
}

/**
Expand Down Expand Up @@ -1107,10 +1095,6 @@ private boolean isExistURLorDOI(List<BibEntry> selectEntryList) {
return false;
}

public void showMessage(String message) {
JOptionPane.showMessageDialog(null, message);
}

/**
* Ask if the user really wants to close the given database
*
Expand Down Expand Up @@ -1297,7 +1281,7 @@ private void increaseTableFontSize() {
}

private void decreaseTableFontSize() {
int currentSize = GUIGlobals.currentFont.getSize();
double currentSize = GUIGlobals.currentFont.getSize();
if (currentSize < 2) {
return;
}
Expand Down
Loading