Search in sources :

Example 6 with FxPostInitialize

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);
        }
    });
}
Also used : Button(javafx.scene.control.Button) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) Node(javafx.scene.Node) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) File(java.io.File) IOException(java.io.IOException) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Aggregations

FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)6 File (java.io.File)4 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)3 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)3 IOException (java.io.IOException)3 FXML (javafx.fxml.FXML)3 Button (javafx.scene.control.Button)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 JFXToggleButton (com.jfoenix.controls.JFXToggleButton)2 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)2 List (java.util.List)2 Platform (javafx.application.Platform)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 ObservableList (javafx.collections.ObservableList)2 Label (javafx.scene.control.Label)2 ToggleGroup (javafx.scene.control.ToggleGroup)2 BorderPane (javafx.scene.layout.BorderPane)2 HBox (javafx.scene.layout.HBox)2