Search in sources :

Example 1 with ConfigurationTreeItem

use of com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem in project Gargoyle by callakrsos.

the class ConfigurationViewController method initialize.

@FXML
public void initialize() {
    ConfigItemTreeItem configItemTreeItem = new ConfigItemTreeItem();
    TreeItem<ConfigurationTreeItem> createNode = configItemTreeItem.createNode(root);
    tvItems.setRoot(createNode);
    createNode.setExpanded(true);
    tvItems.setShowRoot(true);
    tvItems.getSelectionModel().selectedItemProperty().addListener((oba, o, n) -> {
        if (o != n) {
            change(n);
        }
    });
}
Also used : ConfigItemTreeItem(com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) FXML(javafx.fxml.FXML)

Example 2 with ConfigurationTreeItem

use of com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem in project Gargoyle by callakrsos.

the class CustomSkinConfigView method initialize.

@FXML
public void initialize() {
    ttvIConfig.setRowFactory(new Callback<TreeTableView<ConfigurationTreeItem>, TreeTableRow<ConfigurationTreeItem>>() {

        @Override
        public TreeTableRow<ConfigurationTreeItem> call(TreeTableView<ConfigurationTreeItem> param) {
            TreeTableRow<ConfigurationTreeItem> treeTableRow = new TreeTableRow<>();
            treeTableRow.setOnMouseClicked(ev -> {
                ConfigurationTreeItem item = treeTableRow.getItem();
                selectedItem.set(item);
            });
            return treeTableRow;
        }
    });
    ttcConfig.setCellValueFactory(param -> param.getValue().getValue().itemNameProperty());
    ConfigurationTreeItem root = new ConfigurationTreeItem();
    root.setItemName("Basic");
    {
        ConfigurationLeafNodeItem fontConfigItem = new ConfigurationLeafNodeItem();
        fontConfigItem.setItemName("Font Management");
        fontConfigItem.setContentNode(FontViewComposite.class);
        ConfigurationLeafNodeItem backgroundConfigItem = new ConfigurationLeafNodeItem();
        backgroundConfigItem.setItemName("Color Management");
        backgroundConfigItem.setContentNode(SkinPreviewViewComposite.class);
        root.setChildrens(Arrays.asList(fontConfigItem, backgroundConfigItem));
    }
    TreeItem<ConfigurationTreeItem> createNode = new ConfigItemTreeItem().createNode(root);
    createNode.setExpanded(true);
    ttvIConfig.setRoot(createNode);
    ttvIConfig.setOnMouseClicked(ev -> {
        if (ev.getClickCount() == 2) {
            load(selectedItem.get());
        }
    });
    selectedItem.addListener((oba, o, n) -> {
        btnEdit.setDisable(true);
        if (n instanceof ConfigurationLeafNodeItem) {
            if (((ConfigurationLeafNodeItem) n).getContentNode() != null) {
                btnEdit.setDisable(false);
            }
        }
    });
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) TreeItem(javafx.scene.control.TreeItem) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) TreeTableRow(javafx.scene.control.TreeTableRow) Parent(javafx.scene.Parent) TreeTableView(javafx.scene.control.TreeTableView) Callback(javafx.util.Callback) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) FontViewComposite(com.kyj.fx.voeditor.visual.component.font.FontViewComposite) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) ConfigItemTreeItem(com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Consumer(java.util.function.Consumer) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) TreeTableColumn(javafx.scene.control.TreeTableColumn) ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) BorderPane(javafx.scene.layout.BorderPane) FontViewComposite(com.kyj.fx.voeditor.visual.component.font.FontViewComposite) TreeTableView(javafx.scene.control.TreeTableView) ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) TreeTableRow(javafx.scene.control.TreeTableRow) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) ConfigItemTreeItem(com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem) FXML(javafx.fxml.FXML)

Example 3 with ConfigurationTreeItem

use of com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem in project Gargoyle by callakrsos.

the class ConfigItemTreeItem method createNode.

/**
	 * 파일 트리를 생성하기 위한 노드를 반환한다.
	 *
	 * @Date 2015. 10. 14.
	 * @param f
	 * @return
	 * @User KYJ
	 */
public TreeItem<ConfigurationTreeItem> createNode(final ConfigurationTreeItem f) {
    TreeItem<ConfigurationTreeItem> treeItem = new TreeItem<ConfigurationTreeItem>(f) {

        private boolean isLeaf;

        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

        @Override
        public ObservableList<TreeItem<ConfigurationTreeItem>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this));
            }
            return super.getChildren();
        }

        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                ConfigurationTreeItem f = getValue();
                if (f instanceof ConfigurationLeafNodeItem)
                    isLeaf = true;
                else
                    isLeaf = false;
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<ConfigurationTreeItem>> buildChildren(TreeItem<ConfigurationTreeItem> treeItem) {
            ConfigurationTreeItem f = treeItem.getValue();
            if (f == null) {
                return FXCollections.emptyObservableList();
            }
            List<ConfigurationTreeItem> childrens = f.getChildrens();
            if (childrens == null || childrens.isEmpty() || f instanceof ConfigurationLeafNodeItem) {
                return FXCollections.emptyObservableList();
            } else {
                ObservableList<TreeItem<ConfigurationTreeItem>> children = FXCollections.observableArrayList();
                for (ConfigurationTreeItem child : childrens) {
                    TreeItem<ConfigurationTreeItem> createNode = createNode(child);
                    createNode.setExpanded(true);
                    children.add(createNode);
                }
                return children;
            }
        }
    };
    return treeItem;
}
Also used : ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) TreeItem(javafx.scene.control.TreeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem)

Example 4 with ConfigurationTreeItem

use of com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem in project Gargoyle by callakrsos.

the class CustomSkinConfigView method load.

/**
	 * Load TreeItem
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 2.
	 * @param item
	 */
private void load(ConfigurationTreeItem item) {
    if (item != null) {
        if (item instanceof ConfigurationGraphicsNodeItem) {
            ConfigurationGraphicsNodeItem node = (ConfigurationGraphicsNodeItem) item;
            if (node.getCustomOpenStyle() != null) {
                Consumer<Class<?>> customOpenStyle = node.getCustomOpenStyle();
                customOpenStyle.accept(node.getContentNode());
            } else if (node.getContentNode() != null) {
                Class<?> cont = node.getContentNode();
                try {
                    Object newInstance = cont.newInstance();
                    if (newInstance instanceof Parent) {
                        FxUtil.createStageAndShow((Parent) newInstance, stage -> {
                            stage.initOwner(CustomSkinConfigView.this.getScene().getWindow());
                            stage.setTitle(node.getItemName());
                        });
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) TreeItem(javafx.scene.control.TreeItem) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) TreeTableRow(javafx.scene.control.TreeTableRow) Parent(javafx.scene.Parent) TreeTableView(javafx.scene.control.TreeTableView) Callback(javafx.util.Callback) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) FontViewComposite(com.kyj.fx.voeditor.visual.component.font.FontViewComposite) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) ConfigItemTreeItem(com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Consumer(java.util.function.Consumer) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) TreeTableColumn(javafx.scene.control.TreeTableColumn) ConfigurationLeafNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem) ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) BorderPane(javafx.scene.layout.BorderPane) ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) Parent(javafx.scene.Parent) URISyntaxException(java.net.URISyntaxException)

Example 5 with ConfigurationTreeItem

use of com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem in project Gargoyle by callakrsos.

the class ConfigurationViewController method change.

/**
	 * 트리를 더블클릭할때 처리되는 이벤트 함수이다.
	 *
	 * ConfigurationLeafNodeItem 타입의 트리노드인 경우에 ConfigurationLeafNodeItem 클래스안의
	 * ContentNode에 존재하는 Class를 읽은후 객체를 생성하며, 객체생성에 문제가 없는 경우 화면에 불러들인다.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2015. 11. 4.
	 * @param e
	 */
//	@FXML
//	public void tvItemsMouseClick(MouseEvent e) {
//		if (e.getClickCount() == 1) {
//			TreeItem<ConfigurationTreeItem> selectedItem = tvItems.getSelectionModel().getSelectedItem();
//			if (selectedItem == null) {
//				return;
//			}
//
//			change(selectedItem);
//		}
//	}
/**
	 *  선택 아이템 변경시 처리.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 1.
	 * @param selectedItem
	 */
private void change(TreeItem<ConfigurationTreeItem> selectedItem) {
    ConfigurationTreeItem value = selectedItem.getValue();
    if (value == null) {
        return;
    }
    if (value instanceof ConfigurationGraphicsNodeItem) {
        ConfigurationGraphicsNodeItem node = (ConfigurationGraphicsNodeItem) value;
        Class<?> contentNode = node.getContentNode();
        if (contentNode == null)
            return;
        try {
            Node newInstance = (Node) contentNode.newInstance();
            borContent.setCenter(newInstance);
        } catch (Exception e1) {
            LOGGER.error(ValueUtil.toString(e1));
        }
    }
}
Also used : ConfigurationGraphicsNodeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem) Node(javafx.scene.Node) ConfigurationTreeItem(com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem)

Aggregations

ConfigurationTreeItem (com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationTreeItem)5 ConfigItemTreeItem (com.kyj.fx.voeditor.visual.component.ConfigItemTreeItem)3 ConfigurationGraphicsNodeItem (com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationGraphicsNodeItem)3 ConfigurationLeafNodeItem (com.kyj.fx.voeditor.visual.main.model.vo.ConfigurationLeafNodeItem)3 FXML (javafx.fxml.FXML)3 TreeItem (javafx.scene.control.TreeItem)3 FontViewComposite (com.kyj.fx.voeditor.visual.component.font.FontViewComposite)2 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)2 SkinManager (com.kyj.fx.voeditor.visual.momory.SkinManager)2 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)2 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)2 URISyntaxException (java.net.URISyntaxException)2 Arrays (java.util.Arrays)2 Consumer (java.util.function.Consumer)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 Parent (javafx.scene.Parent)2 Button (javafx.scene.control.Button)2 TreeTableColumn (javafx.scene.control.TreeTableColumn)2 TreeTableRow (javafx.scene.control.TreeTableRow)2