From 970a87db9021f1fdee7512824c07b35a90c91ee4 Mon Sep 17 00:00:00 2001 From: cesar-rgon Date: Sat, 6 Nov 2021 18:11:23 +0000 Subject: [PATCH] Testing fixes --- pom.xml | 19 ++++++++++++ .../maincontent/MainContentController.java | 22 ++++++++++++-- .../mapedition/MapEditionController.java | 29 ++++++++----------- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index f23fba1..bb1c6a6 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,25 @@ maven-resources-plugin 3.1.0 + + copy-resource-one + validate + + copy-resources + + + ${project.build.directory}/build/external-images + + + src/main/resources/images + + no-photo.png + photo-borders.png + + + + + copy-resources validate diff --git a/src/main/java/stories/maincontent/MainContentController.java b/src/main/java/stories/maincontent/MainContentController.java index 8818235..e089f9a 100644 --- a/src/main/java/stories/maincontent/MainContentController.java +++ b/src/main/java/stories/maincontent/MainContentController.java @@ -27,6 +27,7 @@ import services.PropertyServiceImpl; import utils.Utils; +import java.io.File; import java.io.InputStream; import java.lang.reflect.Field; import java.net.URL; @@ -221,7 +222,12 @@ public void initialize(URL location, ResourceBundle resources) { if (profileSelect.getValue() != null) { profileOnAction(); } else { - imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + File file = new File(System.getProperty("user.dir") + "/external-images/photo-borders.png"); + if (file.exists()) { + imageWebView.getEngine().load("file:" + System.getProperty("user.dir") + "/external-images/photo-borders.png"); + } else { + imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + } } loadLanguageTexts(languageSelect.getValue() != null? languageSelect.getValue().getKey(): "en"); @@ -586,7 +592,12 @@ public void changed(ObservableValue arg0, Boolean oldProperty if (StringUtils.isNotEmpty(urlImageServer.getText())) { imageWebView.getEngine().load(urlImageServer.getText()); } else { - imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + File file = new File(System.getProperty("user.dir") + "/external-images/photo-borders.png"); + if (file.exists()) { + imageWebView.getEngine().load("file:" + System.getProperty("user.dir") + "/external-images/photo-borders.png"); + } else { + imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + } } } } catch (Exception e) { @@ -1177,7 +1188,12 @@ private void loadActualProfile(ProfileDto profile) throws SQLException { if (StringUtils.isNotEmpty(urlImageServer.getText())) { imageWebView.getEngine().load(urlImageServer.getText()); } else { - imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + File file = new File(System.getProperty("user.dir") + "/external-images/photo-borders.png"); + if (file.exists()) { + imageWebView.getEngine().load("file:" + System.getProperty("user.dir") + "/external-images/photo-borders.png"); + } else { + imageWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + } } serverPassword.setText(Utils.decryptAES(profile.getServerPassword())); webPassword.setText(Utils.decryptAES(profile.getWebPassword())); diff --git a/src/main/java/stories/mapedition/MapEditionController.java b/src/main/java/stories/mapedition/MapEditionController.java index cd2d5b1..a47b1c8 100644 --- a/src/main/java/stories/mapedition/MapEditionController.java +++ b/src/main/java/stories/mapedition/MapEditionController.java @@ -171,21 +171,6 @@ public void changed(ObservableValue observable, Document old } }); - mapPreviewWebView.getEngine().documentProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, Document oldDoc, Document doc) { - if (doc != null) { - NodeList imgList = doc.getElementsByTagName("img"); - if (imgList != null && imgList.getLength() > 0) { - Element img = (Element) imgList.item(0); - img.setAttribute("width", "512"); - img.setAttribute("height", "256"); - } - - } - } - }); - aliasTextField.focusedProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Boolean oldValue, Boolean newValue) { @@ -247,7 +232,12 @@ public void changed(ObservableValue arg0, Boolean oldProperty if (StringUtils.isNotEmpty(mapPreviewUrlTextField.getText())) { mapPreviewWebView.getEngine().load(mapPreviewUrlTextField.getText()); } else { - mapPreviewWebView.getEngine().load("file:" + getClass().getResource("/images/photo-borders.png").getPath()); + File file = new File(System.getProperty("user.dir") + "/external-images/no-photo.png"); + if (file.exists()) { + mapPreviewWebView.getEngine().load("file:" + System.getProperty("user.dir") + "/external-images/no-photo.png"); + } else { + mapPreviewWebView.getEngine().load("file:" + getClass().getResource("/images/no-photo.png").getPath()); + } } } } catch (Exception e) { @@ -368,7 +358,12 @@ private void loadProfileMapData(int mapIndex) { webEngine.load("file:" + installationFolder + profileMapDto.getUrlPhoto()); mapPreviewUrlTextField.setText("file:" + installationFolder + profileMapDto.getUrlPhoto()); } else { - webEngine.load("file:" + getClass().getResource("/images/no-photo.png").getPath()); + File file = new File(System.getProperty("user.dir") + "/external-images/no-photo.png"); + if (file.exists()) { + webEngine.load("file:" + System.getProperty("user.dir") + "/external-images/no-photo.png"); + } else { + webEngine.load("file:" + getClass().getResource("/images/no-photo.png").getPath()); + } mapPreviewUrlTextField.setText(StringUtils.EMPTY); } } else {