Skip to content

Commit

Permalink
Testing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cesar-rgon committed Nov 6, 2021
1 parent b9bb5ff commit 970a87d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resource-one</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/build/external-images</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/images</directory>
<includes>
<include>no-photo.png</include>
<include>photo-borders.png</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/stories/maincontent/MainContentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -586,7 +592,12 @@ public void changed(ObservableValue<? extends Boolean> 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) {
Expand Down Expand Up @@ -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()));
Expand Down
29 changes: 12 additions & 17 deletions src/main/java/stories/mapedition/MapEditionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,6 @@ public void changed(ObservableValue<? extends Document> observable, Document old
}
});

mapPreviewWebView.getEngine().documentProperty().addListener(new ChangeListener<Document>() {
@Override
public void changed(ObservableValue<? extends Document> 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<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
Expand Down Expand Up @@ -247,7 +232,12 @@ public void changed(ObservableValue<? extends Boolean> 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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 970a87d

Please sign in to comment.