Skip to content

Commit

Permalink
Style choice box can be internationalized
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianromero committed Jul 31, 2019
1 parent 75aec35 commit 18f3d82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
13 changes: 12 additions & 1 deletion src/main/java/com/adr/helloiot/ClientLoginNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextFlow;
import javafx.util.StringConverter;

public class ClientLoginNode {

Expand Down Expand Up @@ -555,7 +556,17 @@ private void initialize() {
updateDevicesUnitsList();
});
updateDevicesUnitsList();


skins.setConverter(new StringConverter<Style>() {
@Override
public String toString(Style style) {
return resources.getString("style." + style.name());
}
@Override
public Style fromString(String value) {
return null;
}
});
skins.getItems().addAll(Style.values());
skins.getSelectionModel().selectedItemProperty().addListener((ov, old_val, new_val) -> {
if (!updating) {
Expand Down
27 changes: 6 additions & 21 deletions src/main/java/com/adr/helloiot/Style.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// HelloIoT is a dashboard creator for MQTT
// Copyright (C) 2018 Adrián Romero Corchado.
// Copyright (C) 2018-2019 Adrián Romero Corchado.
//
// This file is part of HelloIot.
//
Expand All @@ -20,38 +20,23 @@

import javafx.scene.layout.StackPane;

/**
*
* @author adrian
*/
public enum Style {

PRETTY("Pretty", "/com/adr/helloiot/styles/main"),
LIGHT("Light", "/com/adr/helloiot/styles/main-light"),
DARK("Dark", "/com/adr/helloiot/styles/main-dark"),
CLASSIC("Classic", "/com/adr/helloiot/styles/empty");
PRETTY("/com/adr/helloiot/styles/main"),
LIGHT("/com/adr/helloiot/styles/main-light"),
DARK("/com/adr/helloiot/styles/main-dark"),
CLASSIC("/com/adr/helloiot/styles/empty");

private final String displayname;
private final String styleurl;

private Style(String displayname, String styleurl) {
this.displayname = displayname;
private Style(String styleurl) {
this.styleurl = styleurl;
}

public String geDisplayName() {
return displayname;
}

public String getStyleURL() {
return styleurl;
}

@Override
public String toString() {
return displayname;
}

public static void changeStyle(StackPane root, Style style) {

Object currentstyle = root.getProperties().get("currentstyleurl");
Expand Down

0 comments on commit 18f3d82

Please sign in to comment.