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 26 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
61 changes: 25 additions & 36 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 All @@ -68,6 +62,7 @@
import org.jabref.gui.undo.UndoableFieldChange;
import org.jabref.gui.undo.UndoableInsertEntry;
import org.jabref.gui.undo.UndoableRemoveEntry;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.worker.SendAsEMailAction;
import org.jabref.logic.citationstyle.CitationStyleCache;
Expand All @@ -93,6 +88,7 @@
import org.jabref.model.database.shared.DatabaseSynchronizer;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.FileFieldParser;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.event.EntryChangedEvent;
Expand Down Expand Up @@ -571,24 +567,27 @@ private void openExternalFile() {
output(Localization.lang("This operation requires exactly one item to be selected."));
return;
}
JabRefExecutorService.INSTANCE.execute(() -> {
final BibEntry entry = selectedEntries.get(0);
if (!entry.hasField(FieldName.FILE)) {
// no bibtex field
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
return;
}
FileListTableModel fileListTableModel = new FileListTableModel();
entry.getField(FieldName.FILE).ifPresent(fileListTableModel::setContent);
if (fileListTableModel.getRowCount() == 0) {
// 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();
});
final BibEntry entry = selectedEntries.get(0);
if (!entry.hasField(FieldName.FILE)) {
// no bibtex field
BackgroundTask.wrap(() -> new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen()).executeWith(Globals.TASK_EXECUTOR);
return;
}

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

if (files.isEmpty()) {
// content in BibTeX field is not readable
BackgroundTask.wrap(() -> new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen()).executeWith(Globals.TASK_EXECUTOR);
return;
}
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 @@ -948,8 +947,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 @@ -963,16 +961,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
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