mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
rather add functionality to formattedLabel class than to extend it
This commit is contained in:
@@ -12,6 +12,7 @@ public class FormattedLabel extends Label {
|
||||
|
||||
private final StringProperty format = new SimpleStringProperty("");
|
||||
private final ObjectProperty<Object> arg1 = new SimpleObjectProperty<>();
|
||||
private final ObjectProperty<Object> arg2 = new SimpleObjectProperty<>();
|
||||
// add arg2, arg3, ... on demand
|
||||
|
||||
public FormattedLabel() {
|
||||
@@ -19,11 +20,11 @@ public class FormattedLabel extends Label {
|
||||
}
|
||||
|
||||
protected StringBinding createStringBinding() {
|
||||
return Bindings.createStringBinding(this::updateText, format, arg1);
|
||||
return Bindings.createStringBinding(this::updateText, format, arg1, arg2);
|
||||
}
|
||||
|
||||
private String updateText() {
|
||||
return String.format(format.get(), arg1.get());
|
||||
return String.format(format.get(), arg1.get(), arg2.get());
|
||||
}
|
||||
|
||||
/* Observables */
|
||||
@@ -51,4 +52,16 @@ public class FormattedLabel extends Label {
|
||||
public void setArg1(Object arg1) {
|
||||
this.arg1.set(arg1);
|
||||
}
|
||||
|
||||
public ObjectProperty<Object> arg2Property() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
public Object getArg2() {
|
||||
return arg2.get();
|
||||
}
|
||||
|
||||
public void setArg2(Object arg2) {
|
||||
this.arg2.set(arg2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package org.cryptomator.ui.controls;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
public class FormattedLabel2 extends FormattedLabel {
|
||||
|
||||
private final ObjectProperty<Object> arg2 = new SimpleObjectProperty<>();
|
||||
|
||||
public FormattedLabel2() {
|
||||
textProperty().unbind();
|
||||
textProperty().bind(createStringBinding2());
|
||||
}
|
||||
|
||||
private StringBinding createStringBinding2() {
|
||||
return Bindings.createStringBinding(this::updateText, formatProperty(), arg1Property(), arg2);
|
||||
}
|
||||
|
||||
private String updateText() {
|
||||
return String.format(getFormat(), getArg1(), arg2.get());
|
||||
}
|
||||
|
||||
/* Getter & Setter */
|
||||
|
||||
public ObjectProperty<Object> arg2Property() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
public Object getArg2() {
|
||||
return arg2.get();
|
||||
}
|
||||
|
||||
public void setArg2(Object arg2) {
|
||||
this.arg2.set(arg2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.cryptomator.ui.controls.FormattedLabel2?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="org.cryptomator.ui.health.CheckDetailController"
|
||||
@@ -18,7 +17,7 @@
|
||||
<Label text="%health.check.detail.taskFailed" visible="${controller.taskFailed}" managed="${controller.taskFailed}"/>
|
||||
<FormattedLabel styleClass="label" format="%health.check.detail.taskSucceeded" arg1="${controller.taskDuration}" visible="${controller.taskSucceeded}" managed="${controller.taskSucceeded}"/>
|
||||
|
||||
<FormattedLabel2 styleClass="label" format="%health.check.detail.problemCount" arg1="${controller.countOfWarnSeverity}" arg2="${controller.countOfCritSeverity}" visible="${!controller.taskNotStarted}"
|
||||
<FormattedLabel styleClass="label" format="%health.check.detail.problemCount" arg1="${controller.countOfWarnSeverity}" arg2="${controller.countOfCritSeverity}" visible="${!controller.taskNotStarted}"
|
||||
managed="${!controller.taskNotStarted}" />
|
||||
<ListView fx:id="resultsListView" VBox.vgrow="ALWAYS"/>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user