Search in sources :

Example 6 with SplitPane

use of javafx.scene.control.SplitPane in project Gargoyle by callakrsos.

the class DockPane method undock.

/**
	 * Detach the node from this dock pane removing it from the layout.
	 *
	 * @param node The node that is to be removed from this dock pane.
	 */
public void undock(DockNode node) {
    DockNodeEventHandler dockNodeEventHandler = dockNodeEventFilters.get(node);
    node.removeEventFilter(DockEvent.DOCK_OVER, dockNodeEventHandler);
    dockNodeEventFilters.remove(node);
    // depth first search to find the parent of the node
    Stack<Parent> findStack = new Stack<Parent>();
    findStack.push((Parent) root);
    while (!findStack.isEmpty()) {
        Parent parent = findStack.pop();
        ObservableList<Node> children = parent.getChildrenUnmodifiable();
        if (parent instanceof SplitPane) {
            SplitPane split = (SplitPane) parent;
            children = split.getItems();
        }
        for (int i = 0; i < children.size(); i++) {
            if (children.get(i) == node) {
                children.remove(i);
                // start from the root again and remove any SplitPane's with no children in them
                Stack<Parent> clearStack = new Stack<Parent>();
                clearStack.push((Parent) root);
                while (!clearStack.isEmpty()) {
                    parent = clearStack.pop();
                    children = parent.getChildrenUnmodifiable();
                    if (parent instanceof SplitPane) {
                        SplitPane split = (SplitPane) parent;
                        children = split.getItems();
                    }
                    for (i = 0; i < children.size(); i++) {
                        if (children.get(i) instanceof SplitPane) {
                            SplitPane split = (SplitPane) children.get(i);
                            if (split.getItems().size() < 1) {
                                children.remove(i);
                                continue;
                            } else {
                                clearStack.push(split);
                            }
                        }
                    }
                }
                return;
            } else if (children.get(i) instanceof Parent) {
                findStack.push((Parent) children.get(i));
            }
        }
    }
}
Also used : Parent(javafx.scene.Parent) Node(javafx.scene.Node) SplitPane(javafx.scene.control.SplitPane) Stack(java.util.Stack)

Example 7 with SplitPane

use of javafx.scene.control.SplitPane in project Gargoyle by callakrsos.

the class DockPane method dock.

/**
	 * Dock the node into this dock pane at the given docking position relative to the sibling in the
	 * layout. This is used to relatively position the dock nodes to other nodes given their preferred
	 * size.
	 *
	 * @param node The node that is to be docked into this dock pane.
	 * @param dockPos The docking position of the node relative to the sibling.
	 * @param sibling The sibling of this node in the layout.
	 */
public void dock(Node node, DockPos dockPos, Node sibling) {
    DockNodeEventHandler dockNodeEventHandler = new DockNodeEventHandler(node);
    dockNodeEventFilters.put(node, dockNodeEventHandler);
    node.addEventFilter(DockEvent.DOCK_OVER, dockNodeEventHandler);
    SplitPane split = (SplitPane) root;
    if (split == null) {
        split = new SplitPane();
        split.getItems().add(node);
        root = split;
        this.getChildren().add(root);
        return;
    }
    // find the parent of the sibling
    if (sibling != null && sibling != root) {
        Stack<Parent> stack = new Stack<Parent>();
        stack.push((Parent) root);
        while (!stack.isEmpty()) {
            Parent parent = stack.pop();
            ObservableList<Node> children = parent.getChildrenUnmodifiable();
            if (parent instanceof SplitPane) {
                SplitPane splitPane = (SplitPane) parent;
                children = splitPane.getItems();
            }
            for (int i = 0; i < children.size(); i++) {
                if (children.get(i) == sibling) {
                    split = (SplitPane) parent;
                } else if (children.get(i) instanceof Parent) {
                    stack.push((Parent) children.get(i));
                }
            }
        }
    }
    Orientation requestedOrientation = (dockPos == DockPos.LEFT || dockPos == DockPos.RIGHT) ? Orientation.HORIZONTAL : Orientation.VERTICAL;
    // if the orientation is different then reparent the split pane
    if (split.getOrientation() != requestedOrientation) {
        if (split.getItems().size() > 1) {
            SplitPane splitPane = new SplitPane();
            if (split == root && sibling == root) {
                this.getChildren().set(this.getChildren().indexOf(root), splitPane);
                splitPane.getItems().add(split);
                root = splitPane;
            } else {
                split.getItems().set(split.getItems().indexOf(sibling), splitPane);
                splitPane.getItems().add(sibling);
            }
            split = splitPane;
        }
        split.setOrientation(requestedOrientation);
    }
    // finally dock the node to the correct split pane
    ObservableList<Node> splitItems = split.getItems();
    double magnitude = 0;
    if (splitItems.size() > 0) {
        if (split.getOrientation() == Orientation.HORIZONTAL) {
            for (Node splitItem : splitItems) {
                magnitude += splitItem.prefWidth(0);
            }
        } else {
            for (Node splitItem : splitItems) {
                magnitude += splitItem.prefHeight(0);
            }
        }
    }
    if (dockPos == DockPos.LEFT || dockPos == DockPos.TOP) {
        int relativeIndex = 0;
        if (sibling != null && sibling != root) {
            relativeIndex = splitItems.indexOf(sibling);
        }
        splitItems.add(relativeIndex, node);
        if (splitItems.size() > 1) {
            if (split.getOrientation() == Orientation.HORIZONTAL) {
                split.setDividerPosition(relativeIndex, node.prefWidth(0) / (magnitude + node.prefWidth(0)));
            } else {
                split.setDividerPosition(relativeIndex, node.prefHeight(0) / (magnitude + node.prefHeight(0)));
            }
        }
    } else if (dockPos == DockPos.RIGHT || dockPos == DockPos.BOTTOM) {
        int relativeIndex = splitItems.size();
        if (sibling != null && sibling != root) {
            relativeIndex = splitItems.indexOf(sibling) + 1;
        }
        splitItems.add(relativeIndex, node);
        if (splitItems.size() > 1) {
            if (split.getOrientation() == Orientation.HORIZONTAL) {
                split.setDividerPosition(relativeIndex - 1, 1 - node.prefWidth(0) / (magnitude + node.prefWidth(0)));
            } else {
                split.setDividerPosition(relativeIndex - 1, 1 - node.prefHeight(0) / (magnitude + node.prefHeight(0)));
            }
        }
    }
}
Also used : Parent(javafx.scene.Parent) Node(javafx.scene.Node) SplitPane(javafx.scene.control.SplitPane) Orientation(javafx.geometry.Orientation) Stack(java.util.Stack)

Example 8 with SplitPane

use of javafx.scene.control.SplitPane in project Gargoyle by callakrsos.

the class WebViewConsole method init.

private void init() {
    txtCommand = new TextArea();
    txtResult = new TextArea();
    btnExec = new Button(" Apply ");
    SplitPane value = new SplitPane(txtResult, txtCommand);
    value.setOrientation(Orientation.VERTICAL);
    setCenter(value);
    setBottom(btnExec);
    btnExec.setOnMouseClicked(this::btnExecOnMouseClick);
    txtCommand.setOnKeyPressed(this::txtCommandOnKeyClick);
}
Also used : TextArea(javafx.scene.control.TextArea) Button(javafx.scene.control.Button) SplitPane(javafx.scene.control.SplitPane)

Aggregations

SplitPane (javafx.scene.control.SplitPane)8 Scene (javafx.scene.Scene)5 Stack (java.util.Stack)2 Node (javafx.scene.Node)2 Parent (javafx.scene.Parent)2 Button (javafx.scene.control.Button)2 TextArea (javafx.scene.control.TextArea)2 BorderPane (javafx.scene.layout.BorderPane)2 CheckBoxFxControlTreeView (com.kyj.fx.voeditor.visual.component.CheckBoxFxControlTreeView)1 FxControlTreeView (com.kyj.fx.voeditor.visual.component.FxControlTreeView)1 CommonsBaseGridView (com.kyj.fx.voeditor.visual.component.grid.CommonsBaseGridView)1 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)1 TbmSysDaoMethodsHDVO (com.kyj.fx.voeditor.visual.main.model.vo.TbmSysDaoMethodsHDVO)1 EditorController (com.oracle.javafx.scenebuilder.kit.editor.EditorController)1 ContentPanelController (com.oracle.javafx.scenebuilder.kit.editor.panel.content.ContentPanelController)1 HierarchyTreeViewController (com.oracle.javafx.scenebuilder.kit.editor.panel.hierarchy.treeview.HierarchyTreeViewController)1 InspectorPanelController (com.oracle.javafx.scenebuilder.kit.editor.panel.inspector.InspectorPanelController)1 LibraryPanelController (com.oracle.javafx.scenebuilder.kit.editor.panel.library.LibraryPanelController)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1