Skip to content

Commit

Permalink
move some classes to utility.fx library
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Apr 29, 2024
1 parent 8559c5c commit 04bcf41
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.dua3.fx.application;

import com.dua3.cabe.annotations.Nullable;
import com.dua3.fx.controls.Dialogs;
import com.dua3.utility.fx.FxUtil;
import com.dua3.utility.i18n.I18N;
Expand All @@ -37,6 +38,8 @@
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -132,6 +135,16 @@ public static ResourceBundle getFxAppBundle(Locale locale) {
return resources;
}

/**
* Convert a given URI to text.
*
* @param uri the URI to convert
* @return the text representation of the URI
*/
public static String asText(@Nullable URI uri) {
return uri == null ? "" : URLDecoder.decode(uri.toString(), StandardCharsets.UTF_8);
}

/**
* Get application main resource bundle.
*
Expand Down Expand Up @@ -251,7 +264,7 @@ protected void updateApplicationTitle() {

if (document != null) {
String locStr = document.hasLocation() ?
FxUtil.asText(document.getLocation()) :
asText(document.getLocation()) :
i18n.get("fx.application.text.untitled");
boolean dirty = document.isDirty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ protected boolean open(URI uri) {
} catch (Exception e) {
LOG.warn("error opening document", e);
getApp().showErrorDialog(
i18n.format("fx.application.dialog.error.open.document.{0.name}", FxUtil.asText(uri)),
i18n.format("fx.application.dialog.error.open.document.{0.name}", FxApplication.asText(uri)),
String.valueOf(e.getLocalizedMessage())
);
return false;
Expand Down Expand Up @@ -402,7 +402,7 @@ private boolean saveDocumentAndHandleErrors(D document, URI uri) {
} catch (Exception e) {
LOG.warn("error saving document", e);
getApp().showErrorDialog(
i18n.format("fx.application.dialog.error.save.{0.document}", FxUtil.asText(uri)),
i18n.format("fx.application.dialog.error.save.{0.document}", FxApplication.asText(uri)),
e.getLocalizedMessage()
);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package com.dua3.fx.controls;

import com.dua3.fx.util.FxRefresh;
import com.dua3.fx.util.PlatformHelper;
import com.dua3.utility.data.Pair;
import com.dua3.utility.fx.FxUtil;
import com.dua3.utility.fx.PlatformHelper;
import com.dua3.utility.lang.LangUtil;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package com.dua3.fx.controls;

import com.dua3.fx.util.FxTaskTracker;
import com.dua3.fx.util.PlatformHelper;
import com.dua3.utility.fx.PlatformHelper;
import javafx.concurrent.Task;
import javafx.concurrent.Worker.State;
import javafx.geometry.Pos;
Expand Down
2 changes: 1 addition & 1 deletion fx-util-db/src/main/java/com/dua3/fx/util/db/FxDbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

package com.dua3.fx.util.db;

import com.dua3.fx.util.PlatformHelper;
import com.dua3.utility.db.DbUtil;
import com.dua3.utility.fx.PlatformHelper;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ObservableValue;
Expand Down
1 change: 1 addition & 0 deletions fx-util-db/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
requires javafx.controls;
requires javafx.graphics;
requires static com.dua3.cabe.annotations;
requires com.dua3.utility.fx;
}
126 changes: 0 additions & 126 deletions fx-util/src/main/java/com/dua3/fx/util/PlatformHelper.java

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 04bcf41

Please sign in to comment.