update item's model name on change lang
This commit is contained in:
@@ -65,8 +65,10 @@ public class MainController {
|
|||||||
}
|
}
|
||||||
toggleGroup.selectedToggleProperty().addListener((cb, o, n) -> {
|
toggleGroup.selectedToggleProperty().addListener((cb, o, n) -> {
|
||||||
try {
|
try {
|
||||||
if (n!=null)
|
if (n != null) {
|
||||||
Main.changeLocale((Locale) n.getUserData());
|
Main.changeLocale((Locale) n.getUserData());
|
||||||
|
world.refresh();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Error on change locale to {}", n.getUserData());
|
LOG.error("Error on change locale to {}", n.getUserData());
|
||||||
LOG.error("",e);
|
LOG.error("",e);
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ public class GroupModel implements Comparable<GroupModel> {
|
|||||||
return Localization.getString("item.group." + group.getName(), group.getName());
|
return Localization.getString("item.group." + group.getName(), group.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateName(){
|
||||||
|
if (name != null){
|
||||||
|
name.setValue(buildName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(GroupModel other) {
|
public int compareTo(GroupModel other) {
|
||||||
int cmp = group.getType().compareTo(other.group.getType());
|
int cmp = group.getType().compareTo(other.group.getType());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class ItemModel implements Comparable<ItemModel> {
|
|||||||
|
|
||||||
public String getId() {return item.getName();}
|
public String getId() {return item.getName();}
|
||||||
|
|
||||||
public String getName() {return name != null ? name.get() : Localization.getString("item." + item.getName(), item.getName());}
|
public String getName() {return name != null ? name.get() : buildName();}
|
||||||
|
|
||||||
public void setName(String value) {
|
public void setName(String value) {
|
||||||
LOG.info("Change name of item {} to {}", item, value);
|
LOG.info("Change name of item {} to {}", item, value);
|
||||||
@@ -49,12 +49,22 @@ public class ItemModel implements Comparable<ItemModel> {
|
|||||||
|
|
||||||
public ReadOnlyStringProperty nameProperty() {
|
public ReadOnlyStringProperty nameProperty() {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
String lName = Localization.getString("item." + item.getName(), item.getName());
|
String lName = buildName();
|
||||||
name = new SimpleStringProperty(lName);
|
name = new SimpleStringProperty(lName);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildName(){
|
||||||
|
return Localization.getString("item." + item.getName(), item.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateName(){
|
||||||
|
if (name != null){
|
||||||
|
name.setValue(buildName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ReadOnlyDoubleProperty avgBuyProperty() {
|
public ReadOnlyDoubleProperty avgBuyProperty() {
|
||||||
return statBuy.avgProperty();
|
return statBuy.avgProperty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,4 +252,10 @@ public class MarketModel {
|
|||||||
LOG.info("Clear groups");
|
LOG.info("Clear groups");
|
||||||
market.clearGroups();
|
market.clearGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refresh(){
|
||||||
|
LOG.debug("Refresh names");
|
||||||
|
groups.get().forEach(GroupModel::updateName);
|
||||||
|
items.get().forEach(ItemModel::updateName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user