Skip to content

Commit 10db39a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into importerbackgroundtask
* upstream/master: Output java error on console, too (#7222) Speedup processResources (#7221) Fix ClipboardManager <-> Prefs ordering (#7224)
2 parents f3d2cca + 08e824f commit 10db39a

File tree

14 files changed

+30
-83
lines changed

14 files changed

+30
-83
lines changed

build.gradle

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ modularity.patchModule("test", "fastparse_2.12-1.0.0.jar")
5050
modularity.patchModule("test2", "fastparse-utils_2.12-1.0.0.jar")
5151
modularity.patchModule("test3", "sourcecode_2.12-0.1.4.jar")
5252

53-
// These are the Java version requirements we will check on each start of JabRef
54-
ext.minRequiredJavaVersion = "1.8.0_171"
55-
ext.allowJava9 = true
56-
5753
sourceSets {
5854
main {
5955
java {
@@ -271,15 +267,12 @@ processResources {
271267
"azureInstrumentationKey": System.getenv('AzureInstrumentationKey'),
272268
"springerNatureAPIKey": System.getenv('SpringerNatureAPIKey'),
273269
"astrophysicsDataSystemAPIKey": System.getenv('AstrophysicsDataSystemAPIKey'),
274-
"ieeeAPIKey": System.getenv('IEEEAPIKey'),
275-
"minRequiredJavaVersion": minRequiredJavaVersion,
276-
"allowJava9": allowJava9
277-
270+
"ieeeAPIKey": System.getenv('IEEEAPIKey')
278271
)
279272
filteringCharset = 'UTF-8'
280273
}
281274

282-
filesMatching("resource/**/meta.xml") {
275+
filesMatching(["resources/resource/ods/meta.xml", "resources/resource/openoffice/meta.xml"]) {
283276
expand version: project.version
284277
}
285278
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.vs.watch=true

src/main/java/org/jabref/gui/DefaultInjector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static Object createDependency(Class<?> clazz) {
4444
} else if (clazz == ProtectedTermsLoader.class) {
4545
return Globals.protectedTermsLoader;
4646
} else if (clazz == ClipBoardManager.class) {
47-
return Globals.clipboardManager;
47+
return Globals.getClipboardManager();
4848
} else if (clazz == UndoManager.class) {
4949
return Globals.undoManager;
5050
} else if (clazz == BibEntryTypesManager.class) {

src/main/java/org/jabref/gui/Globals.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public class Globals {
7373
public static ExporterFactory exportFactory;
7474
public static CountingUndoManager undoManager = new CountingUndoManager();
7575
public static BibEntryTypesManager entryTypesManager = new BibEntryTypesManager();
76-
public static ClipBoardManager clipboardManager = new ClipBoardManager(prefs);
76+
77+
private static ClipBoardManager clipBoardManager = null;
7778

7879
// Key binding preferences
7980
private static KeyBindingRepository keyBindingRepository;
@@ -92,6 +93,13 @@ public static synchronized KeyBindingRepository getKeyPrefs() {
9293
return keyBindingRepository;
9394
}
9495

96+
public static synchronized ClipBoardManager getClipboardManager() {
97+
if (clipBoardManager == null) {
98+
clipBoardManager = new ClipBoardManager(prefs);
99+
}
100+
return clipBoardManager;
101+
}
102+
95103
// Background tasks
96104
public static void startBackgroundTasks() {
97105
Globals.fileUpdateMonitor = new DefaultFileUpdateMonitor();

src/main/java/org/jabref/gui/JabRefFrame.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,13 @@ private MenuBar createMenu() {
716716

717717
factory.createMenuItem(StandardActions.COPY, new EditAction(StandardActions.COPY, this, stateManager)),
718718
factory.createSubMenu(StandardActions.COPY_MORE,
719-
factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, Globals.clipboardManager, prefs)),
720-
factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, Globals.clipboardManager, prefs)),
721-
factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, Globals.clipboardManager, prefs)),
722-
factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, Globals.clipboardManager, prefs)),
723-
factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, Globals.clipboardManager, prefs)),
724-
factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.clipboardManager, prefs.getPreviewPreferences())),
725-
factory.createMenuItem(StandardActions.EXPORT_SELECTED_TO_CLIPBOARD, new ExportToClipboardAction(this, dialogService, Globals.exportFactory, Globals.clipboardManager, Globals.TASK_EXECUTOR))),
719+
factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, Globals.getClipboardManager(), prefs)),
720+
factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, Globals.getClipboardManager(), prefs)),
721+
factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, Globals.getClipboardManager(), prefs)),
722+
factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, Globals.getClipboardManager(), prefs)),
723+
factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, Globals.getClipboardManager(), prefs)),
724+
factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.getClipboardManager(), prefs.getPreviewPreferences())),
725+
factory.createMenuItem(StandardActions.EXPORT_SELECTED_TO_CLIPBOARD, new ExportToClipboardAction(this, dialogService, Globals.exportFactory, Globals.getClipboardManager(), Globals.TASK_EXECUTOR))),
726726

727727
factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, this, stateManager)),
728728

src/main/java/org/jabref/gui/JabRefMain.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import javafx.application.Application;
66
import javafx.application.Platform;
7-
import javafx.scene.control.Alert;
87
import javafx.stage.Stage;
98

109
import org.jabref.cli.ArgumentProcessor;
@@ -19,8 +18,6 @@
1918
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
2019
import org.jabref.logic.remote.RemotePreferences;
2120
import org.jabref.logic.remote.client.RemoteClient;
22-
import org.jabref.logic.util.BuildInfo;
23-
import org.jabref.logic.util.JavaVersion;
2421
import org.jabref.logic.util.OS;
2522
import org.jabref.migrations.PreferencesMigrations;
2623
import org.jabref.model.database.BibDatabaseMode;
@@ -48,8 +45,6 @@ public static void main(String[] args) {
4845
@Override
4946
public void start(Stage mainStage) {
5047
try {
51-
// Fail on unsupported Java versions
52-
ensureCorrectJavaVersion();
5348
FallbackExceptionHandler.installExceptionHandler();
5449

5550
// Init preferences
@@ -93,51 +88,6 @@ public void stop() {
9388
Globals.shutdownThreadPools();
9489
}
9590

96-
/**
97-
* Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported.
98-
* This test uses the requirements for the Java version as specified in <code>gradle.build</code>. It is possible to
99-
* define a minimum version including the built number and to indicate whether Java 9 can be used (which it currently
100-
* can't). It tries to compare this version number to the version of the currently running JVM. The check is
101-
* optimistic and will rather return true even if we could not exactly determine the version.
102-
* <p>
103-
* Note: Users with a very old version like 1.6 will not profit from this since class versions are incompatible and
104-
* JabRef won't even start. Currently, JabRef won't start with Java 9 either, but the warning that it cannot be used
105-
* with this version is helpful anyway to prevent users to update from an old 1.8 directly to version 9. Additionally,
106-
* we soon might have a JabRef that does start with Java 9 but is not perfectly compatible. Therefore, we should leave
107-
* the Java 9 check alive.
108-
*/
109-
private static void ensureCorrectJavaVersion() {
110-
// Check if we are running an acceptable version of Java
111-
final BuildInfo buildInfo = Globals.BUILD_INFO;
112-
JavaVersion checker = new JavaVersion();
113-
final boolean java9Fail = !buildInfo.allowJava9 && checker.isJava9();
114-
final boolean versionFail = !checker.isAtLeast(buildInfo.minRequiredJavaVersion);
115-
116-
if (java9Fail || versionFail) {
117-
StringBuilder versionError = new StringBuilder(
118-
Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.",
119-
checker.getJavaVersion(),
120-
buildInfo.minRequiredJavaVersion));
121-
122-
versionError.append("\n");
123-
versionError.append(Localization.lang("Your Java Runtime Environment is located at %0.", checker.getJavaInstallationDirectory()));
124-
125-
if (!buildInfo.allowJava9) {
126-
versionError.append("\n");
127-
versionError.append(Localization.lang("Note that currently, JabRef does not run with Java 9."));
128-
}
129-
130-
FXDialog alert = new FXDialog(Alert.AlertType.ERROR, Localization.lang("Error"), true);
131-
alert.setHeaderText(null);
132-
alert.setContentText(versionError.toString());
133-
134-
// We exit on Java 9 error since this will definitely not work
135-
if (java9Fail) {
136-
System.exit(0);
137-
}
138-
}
139-
}
140-
14191
private static boolean handleMultipleAppInstances(String[] args) {
14292
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
14393
if (remotePreferences.useRemoteServer()) {

src/main/java/org/jabref/gui/desktop/JabRefDesktop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static void openBrowserShowPopup(String url) {
212212
try {
213213
openBrowser(url);
214214
} catch (IOException exception) {
215-
Globals.clipboardManager.setContent(url);
215+
Globals.getClipboardManager().setContent(url);
216216
LOGGER.error("Could not open browser", exception);
217217
String couldNotOpenBrowser = Localization.lang("Could not open browser.");
218218
String openManually = Localization.lang("Please open %0 manually.", url);

src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void execute() {
2727

2828
Optional<String> urlOptional = DOI.parse(identifier).map(DOI::getURIAsASCIIString);
2929
if (urlOptional.isPresent()) {
30-
Globals.clipboardManager.setContent(urlOptional.get());
30+
Globals.getClipboardManager().setContent(urlOptional.get());
3131
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("The link has been copied to the clipboard."));
3232
} else {
3333
JabRefGUI.getMainFrame().getDialogService().notify(Localization.lang("Invalid DOI: '%0'.", identifier));

src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void copyCurrentAnnotation() {
123123
sj.add(Localization.lang("Content") + ": " + getCurrentAnnotation().getContent());
124124
sj.add(Localization.lang("Marking") + ": " + getCurrentAnnotation().markingProperty().get());
125125

126-
Globals.clipboardManager.setContent(sj.toString());
126+
Globals.getClipboardManager().setContent(sj.toString());
127127
}
128128

129129
private FileAnnotationViewModel getCurrentAnnotation() {

src/main/java/org/jabref/gui/maintable/MainTable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public MainTable(MainTableDataModel model,
115115
stateManager,
116116
preferencesService,
117117
undoManager,
118-
Globals.clipboardManager))
118+
Globals.getClipboardManager()))
119119
.setOnDragDetected(this::handleOnDragDetected)
120120
.setOnDragDropped(this::handleOnDragDropped)
121121
.setOnDragOver(this::handleOnDragOver)
@@ -224,7 +224,7 @@ public void copy() {
224224

225225
if (!selectedEntries.isEmpty()) {
226226
try {
227-
Globals.clipboardManager.setContent(selectedEntries);
227+
Globals.getClipboardManager().setContent(selectedEntries);
228228
dialogService.notify(libraryTab.formatOutputMessage(Localization.lang("Copied"), selectedEntries.size()));
229229
} catch (IOException e) {
230230
LOGGER.error("Error while copying selected entries to clipboard", e);
@@ -293,7 +293,7 @@ private void clearAndSelectLast() {
293293

294294
public void paste(BibDatabaseMode bibDatabaseMode) {
295295
// Find entries in clipboard
296-
List<BibEntry> entriesToAdd = Globals.clipboardManager.extractData();
296+
List<BibEntry> entriesToAdd = Globals.getClipboardManager().extractData();
297297
ImportCleanup cleanup = new ImportCleanup(bibDatabaseMode);
298298
cleanup.doPostCleanup(entriesToAdd);
299299
libraryTab.insertEntries(entriesToAdd);

0 commit comments

Comments
 (0)