Skip to content

Commit

Permalink
Merge pull request #30 from teletha/origin/master
Browse files Browse the repository at this point in the history
fix: add various version info to UpdateSettingView
  • Loading branch information
teletha authored Dec 10, 2023
2 parents 87ede51 + 0de5faf commit 9c6f608
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/main/java/viewtify/Viewtify.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ public Thread newThread(Runnable runnable) {
/** The configurable setting. */
private String title;

/** The configurable setting. */
private String version = "1.0.0";

/** We must continue to hold the lock object to avoid releasing by GC. */
@SuppressWarnings("unused")
private FileLock lock;
Expand Down Expand Up @@ -458,6 +461,26 @@ public Viewtify update(String archive) {
return this;
}

/**
* Get applicaiton metadata.
*
* @return
*/
public String version() {
return version;
}

/**
* Configure application metadata.
*
* @return Chainable API.
*/
public Viewtify version(String version) {
this.version = version;

return this;
}

/**
* Configure error logging.
*
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/viewtify/update/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ private static String validate(String archive) {
return null;
}

/**
* Build the update task for the specified new version.
*/
public static void apply() {
apply(Viewtify.application().updateSite(), false);
}

/**
* Build the update task for the specified new version.
*
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/viewtify/update/UpdateSettingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@
import kiss.Variable;
import viewtify.Viewtify;
import viewtify.ui.UIButton;
import viewtify.ui.UILabel;
import viewtify.ui.View;
import viewtify.ui.ViewDSL;

public class UpdateSettingView extends View {

private UILabel version;

private UIButton confirm;

private UILabel osVersion;

private UILabel javaVersion;

/**
* {@inheritDoc}
*/
Expand All @@ -27,7 +34,10 @@ protected ViewDSL declareUI() {
return new ViewDSL() {
{
$(vbox, () -> {
form(en("Current version"), version);
form(en("Confirn update"), confirm);
form(en("Java Specification"), javaVersion);
form(en("OS Specification"), osVersion);
});
}
};
Expand All @@ -46,8 +56,12 @@ public Variable<String> title() {
*/
@Override
protected void initialize() {
confirm.text(en("Confirm")).action(() -> {
Update.apply(Viewtify.application().updateSite(), false);
});
Viewtify app = Viewtify.application();

version.text(app.version());
confirm.text(en("Confirm")).action(Update::apply);

javaVersion.text(System.getProperty("java.vm.name") + " " + System.getProperty("java.version"));
osVersion.text(System.getProperty("os.name") + " " + System.getProperty("os.arch") + " " + System.getProperty("os.version"));
}
}

0 comments on commit 9c6f608

Please sign in to comment.