From b02ce7b7436dc1fda6be90245068d2995f23ccd5 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 15:20:15 +0100 Subject: [PATCH 1/7] Travis integration --- .travis.yml | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..a376f486825 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,76 @@ +language: java +jdk: + - openjdk11 + +# we test at Ubuntu Trusty (Ubuntu 14.04 LTS) +# see https://docs.travis-ci.com/user/trusty-ci-environment/ +# This environment is continuously updated as described in https://docs.travis-ci.com/user/build-environment-updates/ +dist: trusty +sudo: required + +git: + depth: 1 + +services: + - postgresql + - mysql + +env: + global: + - GRADLE_OPTS=-Dorg.gradle.daemon=false + matrix: + - TEST_SUITE=check + - TEST_SUITE=checkstyle + - TEST_SUITE=fetcherTest + - TEST_SUITE=databaseTest + - TEST_SUITE=guiTest + - TEST_SUITE=codecov + - DEPENDENCY_UPDATES=check + +matrix: + fast_finish: true + allow_failures: + - env: TEST_SUITE=fetcherTest + - env: TEST_SUITE=guiTest + - env: TEST_SUITE=codecov + - env: DEPENDENCY_UPDATES=check + +# JavaFX localization tests need a running X environment +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 3 # give xvfb some time to start + +install: true + +before_script: + - psql -c 'create database jabref;' -U postgres + - mysql -u root -e 'create database jabref' + +script: + # --scan enables the Gradle build scan, which can be used to investigate the time each action consumes + # For more information see https://gradle.com/scans/get-started + - if [ "$TEST_SUITE" != "guiTest" ] && [ "$TEST_SUITE" != "checkstyle" ] && [ "$TEST_SUITE" != "codecov" ]; then ./gradlew $TEST_SUITE $OPTIONS -x checkstyleJmh -x checkstyleMain -x checkstyleTest --scan; fi + - if [ "$TEST_SUITE" == "checkstyle" ]; then ./gradlew checkstyleMain checkstyleTest checkstyleJmh; fi + - if [ "$TEST_SUITE" == "guiTest" ]; then ./buildres/gui-tests.sh; fi + - if [ "$TEST_SUITE" == "codecov" ]; then ./gradlew jacocoTestReport; bash <(curl -s https://codecov.io/bash); fi + - if [ "$DEPENDENCY_UPDATES" == "check" ]; then ./gradlew -q checkOutdatedDependencies; fi + +after_failure: + # show test results if build fails + - $TRAVIS_BUILD_DIR/scripts/after-failure.sh + +branches: + only: + - /.*/ + +# cache gradle dependencies +# https://docs.travis-ci.com/user/languages/java#Caching +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + From 7b2544accc917e965d3effe56a8c09e58ff831c9 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 15:30:04 +0100 Subject: [PATCH 2/7] Bugfix for issue 5037: made several methods on JabRefGUI and second position Variables in JabRefPreferences to support bugfix --- src/main/java/org/jabref/JabRefGUI.java | 58 +++++++++++++++++++ .../jabref/preferences/JabRefPreferences.java | 8 +++ 2 files changed, 66 insertions(+) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 4ddd788eff9..d93a5e7d6b0 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -1,5 +1,6 @@ package org.jabref; +import java.awt.*; import java.io.File; import java.sql.SQLException; import java.util.ArrayList; @@ -40,12 +41,14 @@ public class JabRefGUI { private final List bibDatabases; private final boolean isBlank; + private boolean correctedWindowPos; private final List failed = new ArrayList<>(); private final List toOpenTab = new ArrayList<>(); public JabRefGUI(Stage mainStage, List databases, boolean isBlank) { this.bibDatabases = databases; this.isBlank = isBlank; + this.correctedWindowPos = false; mainFrame = new JabRefFrame(mainStage); openWindow(mainStage); @@ -62,12 +65,21 @@ private void openWindow(Stage mainStage) { // Restore window location and/or maximised state if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { mainStage.setMaximized(true); + } else if (numberOfMonitors() == 1 && testExternalCoordinates()) { + //corrects the + LOGGER.debug("The Jabref Window is outside the Main Monitor\n"); + mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X_CORE)); + mainStage.setY(Globals.prefs.getDouble(JabRefPreferences.POS_Y_CORE)); + mainStage.setWidth(Globals.prefs.getDouble(JabRefPreferences.SIZE_X_CORE)); + mainStage.setHeight(Globals.prefs.getDouble(JabRefPreferences.SIZE_Y_CORE)); + correctedWindowPos = true; } else { mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X)); mainStage.setY(Globals.prefs.getDouble(JabRefPreferences.POS_Y)); mainStage.setWidth(Globals.prefs.getDouble(JabRefPreferences.SIZE_X)); mainStage.setHeight(Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)); } + printWindowState(mainStage); // We create a decoration pane ourselves for performance reasons // (otherwise it has to be injected later, leading to a complete redraw/relayout of the complete scene) @@ -188,6 +200,52 @@ private void saveWindowState(Stage mainStage) { Globals.prefs.putDouble(JabRefPreferences.POS_Y, mainStage.getY()); Globals.prefs.putDouble(JabRefPreferences.SIZE_X, mainStage.getWidth()); Globals.prefs.putDouble(JabRefPreferences.SIZE_Y, mainStage.getHeight()); + printWindowState(mainStage); + } + + /** + * outprints the Data from the Screen + * @param mainStage + */ + private void printWindowState(Stage mainStage) { + StringBuilder bob = new StringBuilder(); + bob.append("SCREEN DATA:"); + bob.append("JabRefPreferences.WINDOW_MAXIMISED: " + mainStage.isMaximized() + "\n"); + bob.append("JabRefPreferences.POS_X: " + mainStage.getX() + "\n"); + bob.append("JabRefPreferences.POS_Y: " + mainStage.getY() + "\n"); + bob.append("JabRefPreferences.SIZE_X: " + mainStage.getWidth() + "\n"); + bob.append("JabRefPreferences.SIZE_Y: " + mainStage.getHeight() + "\n"); + LOGGER.debug(bob.toString()); + } + + /** + * Tests if the Coordinates are out of the mainscreen + * @return outbounds + */ + private boolean testExternalCoordinates(){ + boolean outbounds = false; + if(Globals.prefs.getDouble(JabRefPreferences.POS_X)>Globals.prefs.getDouble(JabRefPreferences.SIZE_X)) outbounds = true; + if(Globals.prefs.getDouble(JabRefPreferences.POS_Y)>Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)) outbounds = true; + if(Globals.prefs.getDouble(JabRefPreferences.POS_X)<0) outbounds = true; + if(Globals.prefs.getDouble(JabRefPreferences.POS_Y)<0) outbounds = true; + return outbounds; + } + + /** + * returns the number of Monitors connected to the Computer + * @return numberOfmonitors + */ + private int numberOfMonitors(){ + //this following part is from the Internet: + //https://stackoverflow.com/questions/20966385/in-java-is-it-possible-to-listen-for-the-connection-disconnection-of-an-externa (from 17.11.2019 + //TODO: proof if we can use this codepiece + int numberOfmonitors = 0; + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice[] gs = ge.getScreenDevices(); + for (int j = 0; j < gs.length; j++) { + numberOfmonitors++; + } + return numberOfmonitors; } private void openLastEditedDatabases() { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index d4d40c3bf7d..ad489ae5441 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -172,6 +172,10 @@ public class JabRefPreferences implements PreferencesService { public static final String SIZE_X = "mainWindowSizeX"; public static final String POS_Y = "mainWindowPosY"; public static final String POS_X = "mainWindowPosX"; + public static final String SIZE_Y_CORE = "mainWindowSizeYCore"; + public static final String SIZE_X_CORE = "mainWindowSizeXCore"; + public static final String POS_Y_CORE = "mainWindowPosYCore"; + public static final String POS_X_CORE = "mainWindowPosXCore"; public static final String STRINGS_SIZE_Y = "stringsSizeY"; public static final String STRINGS_SIZE_X = "stringsSizeX"; public static final String STRINGS_POS_Y = "stringsPosY"; @@ -491,6 +495,10 @@ private JabRefPreferences() { defaults.put(POS_Y, 0); defaults.put(SIZE_X, 1024); defaults.put(SIZE_Y, 768); + defaults.put(POS_X_CORE, 0); + defaults.put(POS_Y_CORE, 0); + defaults.put(SIZE_X_CORE, 1024); + defaults.put(SIZE_Y_CORE, 768); defaults.put(WINDOW_MAXIMISED, Boolean.TRUE); defaults.put(AUTO_RESIZE_MODE, Boolean.TRUE); defaults.put(ENTRY_EDITOR_HEIGHT, 0.65); From 8f5cd011a74f8532b166abdf9e166dd1c747cc78 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 16:27:37 +0100 Subject: [PATCH 3/7] made comments and corrected Checkstyle --- .travis.yml | 2 +- src/main/java/org/jabref/JabRefGUI.java | 39 ++++++++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index a376f486825..eebf6dee8ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: java jdk: - - openjdk11 + - openjdk13 # we test at Ubuntu Trusty (Ubuntu 14.04 LTS) # see https://docs.travis-ci.com/user/trusty-ci-environment/ diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index d93a5e7d6b0..a55b3171bda 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -1,6 +1,7 @@ package org.jabref; -import java.awt.*; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.io.File; import java.sql.SQLException; import java.util.ArrayList; @@ -66,7 +67,7 @@ private void openWindow(Stage mainStage) { if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { mainStage.setMaximized(true); } else if (numberOfMonitors() == 1 && testExternalCoordinates()) { - //corrects the + //corrects the Window, if its outside of the mainscreen LOGGER.debug("The Jabref Window is outside the Main Monitor\n"); mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X_CORE)); mainStage.setY(Globals.prefs.getDouble(JabRefPreferences.POS_Y_CORE)); @@ -94,7 +95,11 @@ private void openWindow(Stage mainStage) { mainStage.show(); mainStage.setOnCloseRequest(event -> { - saveWindowState(mainStage); + if (!correctedWindowPos) { + //saves the window position only if its not corrected -> the window will rest at the old Position, + //if the external Screen is connected again. + saveWindowState(mainStage); + } boolean reallyQuit = mainFrame.quit(); if (!reallyQuit) { event.consume(); @@ -205,6 +210,7 @@ private void saveWindowState(Stage mainStage) { /** * outprints the Data from the Screen + * (only in debug mode) * @param mainStage */ private void printWindowState(Stage mainStage) { @@ -219,15 +225,23 @@ private void printWindowState(Stage mainStage) { } /** - * Tests if the Coordinates are out of the mainscreen + * Tests if the window coordinates are out of the mainscreen * @return outbounds */ - private boolean testExternalCoordinates(){ + private boolean testExternalCoordinates() { boolean outbounds = false; - if(Globals.prefs.getDouble(JabRefPreferences.POS_X)>Globals.prefs.getDouble(JabRefPreferences.SIZE_X)) outbounds = true; - if(Globals.prefs.getDouble(JabRefPreferences.POS_Y)>Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)) outbounds = true; - if(Globals.prefs.getDouble(JabRefPreferences.POS_X)<0) outbounds = true; - if(Globals.prefs.getDouble(JabRefPreferences.POS_Y)<0) outbounds = true; + if (Globals.prefs.getDouble(JabRefPreferences.POS_X) > Globals.prefs.getDouble(JabRefPreferences.SIZE_X)) { + outbounds = true; + } + if (Globals.prefs.getDouble(JabRefPreferences.POS_Y) > Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)) { + outbounds = true; + } + if (Globals.prefs.getDouble(JabRefPreferences.POS_X) < 0) { + outbounds = true; + } + if (Globals.prefs.getDouble(JabRefPreferences.POS_Y) < 0) { + outbounds = true; + } return outbounds; } @@ -235,10 +249,9 @@ private boolean testExternalCoordinates(){ * returns the number of Monitors connected to the Computer * @return numberOfmonitors */ - private int numberOfMonitors(){ - //this following part is from the Internet: - //https://stackoverflow.com/questions/20966385/in-java-is-it-possible-to-listen-for-the-connection-disconnection-of-an-externa (from 17.11.2019 - //TODO: proof if we can use this codepiece + private int numberOfMonitors() { + //this following part (this method) is from the Internet: + //https://stackoverflow.com/questions/20966385/in-java-is-it-possible-to-listen-for-the-connection-disconnection-of-an-externa (from 17.11.2019) int numberOfmonitors = 0; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); From 67920102517b64b501126bf8c4eca50b723cb945 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 18:36:45 +0100 Subject: [PATCH 4/7] added my change/bugfix to Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b28e1370db..658e434d2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where JabRef could not interact with [Oracle XE](https://www.oracle.com/de/database/technologies/appdev/xe.html) in the [shared SQL database setup](https://docs.jabref.org/collaborative-work/sqldatabase). - We fixed an issue where the toolbar icons were hidden on smaller screens. - We fixed an issue where renaming referenced files for bib entries with long titles was not possible. [#5603](https://github.com/JabRef/jabref/issues/5603) +- We fixed an issue where a window which is on an external screen gets unreachable when external screen is removed. [#5037](https://github.com/JabRef/jabref/issues/5037) ### Removed From 31a2c1abf17452ce0377c8e083d27a794bf5fbb9 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 21:35:46 +0100 Subject: [PATCH 5/7] removed .travis.yml --- .travis.yml | 76 ----------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eebf6dee8ba..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,76 +0,0 @@ -language: java -jdk: - - openjdk13 - -# we test at Ubuntu Trusty (Ubuntu 14.04 LTS) -# see https://docs.travis-ci.com/user/trusty-ci-environment/ -# This environment is continuously updated as described in https://docs.travis-ci.com/user/build-environment-updates/ -dist: trusty -sudo: required - -git: - depth: 1 - -services: - - postgresql - - mysql - -env: - global: - - GRADLE_OPTS=-Dorg.gradle.daemon=false - matrix: - - TEST_SUITE=check - - TEST_SUITE=checkstyle - - TEST_SUITE=fetcherTest - - TEST_SUITE=databaseTest - - TEST_SUITE=guiTest - - TEST_SUITE=codecov - - DEPENDENCY_UPDATES=check - -matrix: - fast_finish: true - allow_failures: - - env: TEST_SUITE=fetcherTest - - env: TEST_SUITE=guiTest - - env: TEST_SUITE=codecov - - env: DEPENDENCY_UPDATES=check - -# JavaFX localization tests need a running X environment -before_install: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - -install: true - -before_script: - - psql -c 'create database jabref;' -U postgres - - mysql -u root -e 'create database jabref' - -script: - # --scan enables the Gradle build scan, which can be used to investigate the time each action consumes - # For more information see https://gradle.com/scans/get-started - - if [ "$TEST_SUITE" != "guiTest" ] && [ "$TEST_SUITE" != "checkstyle" ] && [ "$TEST_SUITE" != "codecov" ]; then ./gradlew $TEST_SUITE $OPTIONS -x checkstyleJmh -x checkstyleMain -x checkstyleTest --scan; fi - - if [ "$TEST_SUITE" == "checkstyle" ]; then ./gradlew checkstyleMain checkstyleTest checkstyleJmh; fi - - if [ "$TEST_SUITE" == "guiTest" ]; then ./buildres/gui-tests.sh; fi - - if [ "$TEST_SUITE" == "codecov" ]; then ./gradlew jacocoTestReport; bash <(curl -s https://codecov.io/bash); fi - - if [ "$DEPENDENCY_UPDATES" == "check" ]; then ./gradlew -q checkOutdatedDependencies; fi - -after_failure: - # show test results if build fails - - $TRAVIS_BUILD_DIR/scripts/after-failure.sh - -branches: - only: - - /.*/ - -# cache gradle dependencies -# https://docs.travis-ci.com/user/languages/java#Caching -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - From 031dbc5534a6917931bb881c63c135855cd30998 Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Wed, 11 Dec 2019 22:25:28 +0100 Subject: [PATCH 6/7] made suggested Changes from tobiasdiez --- src/main/java/org/jabref/JabRefGUI.java | 37 ++++--------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index a55b3171bda..3c8d78123f7 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -1,7 +1,5 @@ package org.jabref; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; import java.io.File; import java.sql.SQLException; import java.util.ArrayList; @@ -10,6 +8,7 @@ import javafx.application.Platform; import javafx.scene.Scene; +import javafx.stage.Screen; import javafx.stage.Stage; import org.jabref.gui.BasePanel; @@ -66,7 +65,7 @@ private void openWindow(Stage mainStage) { // Restore window location and/or maximised state if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { mainStage.setMaximized(true); - } else if (numberOfMonitors() == 1 && testExternalCoordinates()) { + } else if (Screen.getScreens().size() == 1 && testExternalCoordinates()) { //corrects the Window, if its outside of the mainscreen LOGGER.debug("The Jabref Window is outside the Main Monitor\n"); mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X_CORE)); @@ -229,36 +228,10 @@ private void printWindowState(Stage mainStage) { * @return outbounds */ private boolean testExternalCoordinates() { - boolean outbounds = false; - if (Globals.prefs.getDouble(JabRefPreferences.POS_X) > Globals.prefs.getDouble(JabRefPreferences.SIZE_X)) { - outbounds = true; - } - if (Globals.prefs.getDouble(JabRefPreferences.POS_Y) > Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)) { - outbounds = true; - } - if (Globals.prefs.getDouble(JabRefPreferences.POS_X) < 0) { - outbounds = true; - } - if (Globals.prefs.getDouble(JabRefPreferences.POS_Y) < 0) { - outbounds = true; - } - return outbounds; - } - /** - * returns the number of Monitors connected to the Computer - * @return numberOfmonitors - */ - private int numberOfMonitors() { - //this following part (this method) is from the Internet: - //https://stackoverflow.com/questions/20966385/in-java-is-it-possible-to-listen-for-the-connection-disconnection-of-an-externa (from 17.11.2019) - int numberOfmonitors = 0; - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice[] gs = ge.getScreenDevices(); - for (int j = 0; j < gs.length; j++) { - numberOfmonitors++; - } - return numberOfmonitors; + boolean outbounds = !Screen.getPrimary().getBounds().contains(Globals.prefs.getDouble(JabRefPreferences.POS_X) , Globals.prefs.getDouble(JabRefPreferences.POS_Y)); + + return outbounds; } private void openLastEditedDatabases() { From e652b3803da5e723323ff01f52ff8af94877a46b Mon Sep 17 00:00:00 2001 From: Matthias Mueller Date: Thu, 12 Dec 2019 14:03:36 +0100 Subject: [PATCH 7/7] replaced JabrefPreferences with mainStage at printWindowState(), renamed method testExternalCoordinates with isWindowPositionOutOfBounds(), Deleted unused Variables at JabrefPreferences due to a correction in openWindow (at JabRefGUI) --- src/main/java/org/jabref/JabRefGUI.java | 25 +++++++++---------- .../jabref/preferences/JabRefPreferences.java | 8 ------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 3c8d78123f7..76684d8e1ed 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -65,13 +65,13 @@ private void openWindow(Stage mainStage) { // Restore window location and/or maximised state if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { mainStage.setMaximized(true); - } else if (Screen.getScreens().size() == 1 && testExternalCoordinates()) { + } else if (Screen.getScreens().size() == 1 && isWindowPositionOutOfBounds()) { //corrects the Window, if its outside of the mainscreen LOGGER.debug("The Jabref Window is outside the Main Monitor\n"); - mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X_CORE)); - mainStage.setY(Globals.prefs.getDouble(JabRefPreferences.POS_Y_CORE)); - mainStage.setWidth(Globals.prefs.getDouble(JabRefPreferences.SIZE_X_CORE)); - mainStage.setHeight(Globals.prefs.getDouble(JabRefPreferences.SIZE_Y_CORE)); + mainStage.setX(0); + mainStage.setY(0); + mainStage.setWidth(1024); + mainStage.setHeight(768); correctedWindowPos = true; } else { mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X)); @@ -215,11 +215,11 @@ private void saveWindowState(Stage mainStage) { private void printWindowState(Stage mainStage) { StringBuilder bob = new StringBuilder(); bob.append("SCREEN DATA:"); - bob.append("JabRefPreferences.WINDOW_MAXIMISED: " + mainStage.isMaximized() + "\n"); - bob.append("JabRefPreferences.POS_X: " + mainStage.getX() + "\n"); - bob.append("JabRefPreferences.POS_Y: " + mainStage.getY() + "\n"); - bob.append("JabRefPreferences.SIZE_X: " + mainStage.getWidth() + "\n"); - bob.append("JabRefPreferences.SIZE_Y: " + mainStage.getHeight() + "\n"); + bob.append("mainStage.WINDOW_MAXIMISED: " + mainStage.isMaximized() + "\n"); + bob.append("mainStage.POS_X: " + mainStage.getX() + "\n"); + bob.append("mainStage.POS_Y: " + mainStage.getY() + "\n"); + bob.append("mainStage.SIZE_X: " + mainStage.getWidth() + "\n"); + bob.append("mainStages.SIZE_Y: " + mainStage.getHeight() + "\n"); LOGGER.debug(bob.toString()); } @@ -227,11 +227,10 @@ private void printWindowState(Stage mainStage) { * Tests if the window coordinates are out of the mainscreen * @return outbounds */ - private boolean testExternalCoordinates() { + private boolean isWindowPositionOutOfBounds() { - boolean outbounds = !Screen.getPrimary().getBounds().contains(Globals.prefs.getDouble(JabRefPreferences.POS_X) , Globals.prefs.getDouble(JabRefPreferences.POS_Y)); + return !Screen.getPrimary().getBounds().contains(Globals.prefs.getDouble(JabRefPreferences.POS_X) , Globals.prefs.getDouble(JabRefPreferences.POS_Y)); - return outbounds; } private void openLastEditedDatabases() { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index ad489ae5441..d4d40c3bf7d 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -172,10 +172,6 @@ public class JabRefPreferences implements PreferencesService { public static final String SIZE_X = "mainWindowSizeX"; public static final String POS_Y = "mainWindowPosY"; public static final String POS_X = "mainWindowPosX"; - public static final String SIZE_Y_CORE = "mainWindowSizeYCore"; - public static final String SIZE_X_CORE = "mainWindowSizeXCore"; - public static final String POS_Y_CORE = "mainWindowPosYCore"; - public static final String POS_X_CORE = "mainWindowPosXCore"; public static final String STRINGS_SIZE_Y = "stringsSizeY"; public static final String STRINGS_SIZE_X = "stringsSizeX"; public static final String STRINGS_POS_Y = "stringsPosY"; @@ -495,10 +491,6 @@ private JabRefPreferences() { defaults.put(POS_Y, 0); defaults.put(SIZE_X, 1024); defaults.put(SIZE_Y, 768); - defaults.put(POS_X_CORE, 0); - defaults.put(POS_Y_CORE, 0); - defaults.put(SIZE_X_CORE, 1024); - defaults.put(SIZE_Y_CORE, 768); defaults.put(WINDOW_MAXIMISED, Boolean.TRUE); defaults.put(AUTO_RESIZE_MODE, Boolean.TRUE); defaults.put(ENTRY_EDITOR_HEIGHT, 0.65);