Package org.apache.pivot.wtk.content

Examples of org.apache.pivot.wtk.content.TreeNode


                    EventLogger eventLogger = (EventLogger)getComponent();

                    boolean checked = (checkState == TreeView.NodeCheckState.CHECKED);

                    List<?> treeData = treeView.getTreeData();
                    TreeNode treeNode = (TreeNode)Sequence.Tree.get(treeData, path);

                    if (treeNode instanceof List<?>) {
                        if (previousCheckState == TreeView.NodeCheckState.CHECKED
                            || checkState == TreeView.NodeCheckState.CHECKED) {
                            // Propagate downward
View Full Code Here


    private void setEventIncluded(Method event, boolean included) {
        List<TreeNode> treeData = (List<TreeNode>)declaredEventsTreeView.getTreeData();

        Sequence.Tree.ItemIterator<TreeNode> iter = Sequence.Tree.depthFirstIterator(treeData);
        while (iter.hasNext()) {
            TreeNode treeNode = iter.next();

            if (treeNode instanceof EventNode) {
                EventNode eventNode = (EventNode)treeNode;

                if (eventNode.getEvent() == event) {
View Full Code Here

        treeView.expandBranch(new Path(0));
    }

    @SuppressWarnings("unchecked")
    private static TreeNode build(Object value) {
        TreeNode treeNode;

        if (value instanceof Map<?, ?>) {
            TreeBranch treeBranch = new TreeBranch("{}");
            treeBranch.setComparator(new Comparator<TreeNode>() {
                @Override
                public int compare(TreeNode treeNode1, TreeNode treeNode2) {
                    return treeNode1.getText().compareTo(treeNode2.getText());
                }
            });

            Map<String, Object> map = (Map<String, Object>)value;
            for (String key : map) {
                TreeNode valueNode = build(map.get(key));

                String text = valueNode.getText();
                if (text == null) {
                    valueNode.setText(key);
                } else {
                    valueNode.setText(key + " : " + text);
                }

                treeBranch.add(valueNode);
            }

            treeNode = treeBranch;
        } else if (value instanceof List<?>) {
            TreeBranch treeBranch = new TreeBranch("[]");

            List<Object> list = (List<Object>)value;
            for (int i = 0, n = list.getLength(); i < n; i++) {
                TreeNode itemNode = build(list.get(i));

                String text = itemNode.getText();
                if (text == null) {
                    itemNode.setText("[" + i + "]");
                } else {
                    itemNode.setText("[" + i + "] " + text);
                }

                treeBranch.add(itemNode);
            }

            treeNode = treeBranch;
        } else if (value instanceof String) {
            treeNode = new TreeNode("\"" + value.toString() + "\"");
        } else if (value instanceof Number) {
            treeNode = new TreeNode(value.toString());
        } else if (value instanceof Boolean) {
            treeNode = new TreeNode(value.toString());
        } else {
            treeNode = new TreeNode("null");
        }

        return treeNode;
    }
View Full Code Here

            this.treeView = treeView;
            this.path = path;

            // Get the data being edited
            List<?> treeData = treeView.getTreeData();
            TreeNode nodeData = (TreeNode)Sequence.Tree.get(treeData, path);

            textInput = new TextInput();
            textInput.setText(nodeData.getText());
            textInput.getComponentKeyListeners().add(textInputKeyHandler);

            popup = new Window(textInput);
            popup.getWindowStateListeners().add(popupStateHandler);
            popup.open(treeView.getWindow());
View Full Code Here

     * Repositions the popup to be located over the node being edited.
     */
    private void reposition() {
        // Get the data being edited
        List<?> treeData = treeView.getTreeData();
        TreeNode nodeData = (TreeNode)Sequence.Tree.get(treeData, path);

        // Get the node bounds
        Bounds nodeBounds = treeView.getNodeBounds(path);
        int nodeIndent = treeView.getNodeIndent(path.getLength());
        nodeBounds = new Bounds(nodeBounds.x + nodeIndent, nodeBounds.y,
View Full Code Here

        Vote vote = nodeEditorListeners.previewSaveChanges(this, treeView, path, text);

        if (vote == Vote.APPROVE) {
            // Update the node data
            List<?> treeData = treeView.getTreeData();
            TreeNode treeNode = (TreeNode)Sequence.Tree.get(treeData, path);
            treeNode.setText(text);

            // Get a reference to the parent of the node data
            int n = path.getLength();
            List<TreeNode> parentData;
View Full Code Here

        treeView.expandBranch(new Path(0));
    }

    @SuppressWarnings("unchecked")
    private static TreeNode build(Object value) {
        TreeNode treeNode;

        if (value instanceof Map<?, ?>) {
            TreeBranch treeBranch = new TreeBranch("{}");

            Map<String, Object> map = (Map<String, Object>)value;
            for (String key : map) {
                TreeNode valueNode = build(map.get(key));

                String text = valueNode.getText();
                if (text == null) {
                    valueNode.setText(key);
                } else {
                    valueNode.setText(key + " : " + text);
                }

                treeBranch.add(valueNode);
            }

            treeNode = treeBranch;
        } else if (value instanceof List<?>) {
            TreeBranch treeBranch = new TreeBranch("[]");

            List<Object> list = (List<Object>)value;
            for (int i = 0, n = list.getLength(); i < n; i++) {
                TreeNode itemNode = build(list.get(i));

                String text = itemNode.getText();
                if (text == null) {
                    itemNode.setText("[" + i + "]");
                } else {
                    itemNode.setText("[" + i + "] " + text);
                }

                treeBranch.add(itemNode);
            }

            treeNode = treeBranch;
        } else if (value instanceof String) {
            treeNode = new TreeNode("\"" + value.toString() + "\"");
        } else if (value instanceof Number) {
            treeNode = new TreeNode(value.toString());
        } else if (value instanceof Boolean) {
            treeNode = new TreeNode(value.toString());
        } else {
            treeNode = new TreeNode("null");
        }

        return treeNode;
    }
View Full Code Here

        this.treeView = treeView;
        this.path = path;

        // Get the data being edited
        List<?> treeData = treeView.getTreeData();
        TreeNode nodeData = (TreeNode)Sequence.Tree.get(treeData, path);

        // Get the node bounds
        Bounds nodeBounds = treeView.getNodeBounds(path);
        int nodeIndent = treeView.getNodeIndent(path.getLength());
        nodeBounds = new Bounds(nodeBounds.x + nodeIndent, nodeBounds.y,
            nodeBounds.width - nodeIndent, nodeBounds.height);

        // Render the node data
        TreeViewNodeRenderer nodeRenderer = (TreeViewNodeRenderer)treeView.getNodeRenderer();
        nodeRenderer.render(nodeData, treeView, false, false,
            TreeView.NodeCheckState.UNCHECKED, false, false);
        nodeRenderer.setSize(nodeBounds.width, nodeBounds.height);

        // Get the text bounds
        Bounds textBounds = nodeRenderer.getTextBounds();

        if (textBounds != null) {
            textInput = new TextInput();
            Insets padding = (Insets)textInput.getStyles().get("padding");

            // Calculate the bounds of what we're editing
            Bounds editBounds = new Bounds(nodeBounds.x + textBounds.x - (padding.left + 1),
                nodeBounds.y, nodeBounds.width - textBounds.x + (padding.left + 1),
                nodeBounds.height);

            // Scroll to make the text as visible as possible
            treeView.scrollAreaToVisible(editBounds.x, editBounds.y,
                textBounds.width + padding.left + 1, editBounds.height);

            // Constrain the bounds by what is visible through Viewport ancestors
            editBounds = treeView.getVisibleArea(editBounds.x, editBounds.y,
                editBounds.width, editBounds.height);

            textInput.setText(nodeData.getText());
            textInput.setPreferredWidth(editBounds.width);
            textInput.getComponentKeyListeners().add(textInputKeyHandler);

            popup = new Window(textInput, true);
            popup.getWindowStateListeners().add(popupStateHandler);
View Full Code Here

        if (!isEditing()) {
            throw new IllegalStateException();
        }

        List<?> treeData = treeView.getTreeData();
        TreeNode treeNode = (TreeNode)Sequence.Tree.get(treeData, path);

        // Update the node data
        String text = textInput.getText();
        treeNode.setText(text);

        // Get a reference to the parent of the node data
        int n = path.getLength();
        List<TreeNode> parentData;
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.content.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.