use of com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize in project Gargoyle by callakrsos.
the class SkinPreviewViewComposite method buttonTabInit.
@FxPostInitialize
public void buttonTabInit() {
loadButtonStyles();
if (SkinManager.getInstance().isUsedCustomButton()) {
tgbUseBtnDefault.setSelected(false);
tbBtnSkins.setOpacity(1.0d);
} else {
tbBtnSkins.setOpacity(0.5d);
}
tgbUseBtnDefault.selectedProperty().addListener((oba, o, n) -> {
if (n) {
tbBtnSkins.setOpacity(0.5d);
} else
tbBtnSkins.setOpacity(1.0d);
});
colSkinName.setCellValueFactory(param -> {
return new SimpleStringProperty(param.getValue().getName());
});
tbBtnSkins.getSelectionModel().selectedItemProperty().addListener((oba, o, n) -> {
File selectedItem = n;
if (selectedItem != null && selectedItem.exists()) {
String readFile = FileUtil.readFile(selectedItem, true, null);
txtStyle.setText(readFile);
try {
List<Node> findAllByNodes = FxUtil.findAllByNodes(borPreview, node -> node instanceof Button);
String className = String.format("%s", selectedItem.getName().replaceAll(".css", ""));
findAllByNodes.forEach(btn -> {
btn.getStyleClass().add("button");
btn.getStyleClass().add(className);
});
borPreview.getStylesheets().clear();
borPreview.getStylesheets().add(selectedItem.toURI().toURL().toExternalForm());
selectedBtnStyleClassName.set(className);
borPreview.applyCss();
} catch (Exception e) {
e.printStackTrace();
}
} else {
txtStyle.setText("");
selectedBtnStyleClassName.set(null);
}
});
}
Aggregations