Package org.apache.pivot.collections.Sequence.Tree

Examples of org.apache.pivot.collections.Sequence.Tree.Path


        }

        int index = selectedPaths.indexOf(path);
        if (index < 0) {
            // Monitor the path's parent
            monitorBranch(new Path(path, path.getLength() - 1));

            // Update the selection
            selectedPaths.add(new ImmutablePath(path));

            // Notify listeners
View Full Code Here


            } else if (showMixedCheckmarkState) {
                // Translate to the insertion index
                index = -(index + 1);

                if (index < checkedPaths.getLength()) {
                    Path nextCheckedPath = checkedPaths.get(index);

                    if (Sequence.Tree.isDescendant(path, nextCheckedPath)) {
                        checkState = NodeCheckState.MIXED;
                    }
                }
View Full Code Here

            if (showMixedCheckmarkState) {
                // Record the check states of our ancestors before we change
                // anything so we know which events to fire after we're done
                ancestorCheckStates = new ArrayList<NodeCheckState>(path.getLength() - 1);

                Path ancestorPath = new Path(path, path.getLength() - 1);

                for (int i = ancestorPath.getLength() - 1; i >= 0; i--) {
                    ancestorCheckStates.insert(getNodeCheckState(ancestorPath), 0);

                    ancestorPath.remove(i, 1);
                }
            }

            if (checked) {
                // Monitor the path's parent
                monitorBranch(new Path(path, path.getLength() - 1));

                // Update the checked paths
                checkedPaths.add(new ImmutablePath(path));
            } else {
                // Update the checked paths
                checkedPaths.remove(index, 1);
            }

            // Notify listeners
            treeViewNodeStateListeners.nodeCheckStateChanged(this, path, previousCheckState);

            if (showMixedCheckmarkState && ancestorCheckStates != null) {
                // Notify listeners of any changes to our ancestors' check states
                Path ancestorPath = new Path(path, path.getLength() - 1);

                for (int i = ancestorPath.getLength() - 1; i >= 0; i--) {
                    NodeCheckState ancestorPreviousCheckState = ancestorCheckStates.get(i);
                    NodeCheckState ancestorCheckState = getNodeCheckState(ancestorPath);

                    if (ancestorCheckState != ancestorPreviousCheckState) {
                        treeViewNodeStateListeners.nodeCheckStateChanged
                            (this, ancestorPath, ancestorPreviousCheckState);
                    }

                    ancestorPath.remove(i, 1);
                }
            }
        }
    }
View Full Code Here

        while (itemIterator.hasNext()) {
            Object node = itemIterator.next();

            if (node instanceof List<?>) {
                Path path = itemIterator.getPath();

                if (path.getLength() > 0) {
                    expandBranch(path);
                }
            }
        }
    }
View Full Code Here

        while (itemIterator.hasNext()) {
            Object node = itemIterator.next();

            if (node instanceof List<?>) {
                Path path = itemIterator.getPath();

                if (path.getLength() > 0) {
                    collapseBranch(path);
                }
            }
        }
    }
View Full Code Here

                        if (previousCheckState == TreeView.NodeCheckState.CHECKED
                            || checkState == TreeView.NodeCheckState.CHECKED) {
                            // Propagate downward
                            List<?> treeBranch = (List<?>)treeNode;

                            Path childPath = new Path(path);
                            int lastIndex = childPath.getLength();
                            childPath.add(0);

                            for (int i = 0, n = treeBranch.getLength(); i < n; i++) {
                                childPath.update(lastIndex, i);
                                treeView.setNodeChecked(childPath, checked);

                                EventNode eventNode = (EventNode)treeBranch.get(i);
                                Method event = eventNode.getEvent();

                                if (checked) {
                                    eventLoggerLocal.getIncludeEvents().add(event);
                                } else {
                                    eventLoggerLocal.getIncludeEvents().remove(event);
                                }
                            }
                        }
                    } else {
                        Path parentPath = new Path(path, path.getLength() - 1);

                        EventNode eventNode = (EventNode)treeNode;
                        Method event = eventNode.getEvent();

                        if (checked) {
                            List<?> treeBranch = (List<?>)Sequence.Tree.get(treeData, parentPath);

                            Path childPath = new Path(path);
                            int lastIndex = parentPath.getLength();

                            int i = 0, n = treeBranch.getLength();
                            while (i < n) {
                                childPath.update(lastIndex, i);

                                if (!treeView.isNodeChecked(childPath)) {
                                    break;
                                }
View Full Code Here

         * branch. Note: <tt>rootBranchHandler.getPath()</tt> will return and
         * empty sequence.
         */
        @SuppressWarnings("unchecked")
        private Path getPath() {
            Path path = new Path();

            BranchHandler handler = this;

            while (handler.parent != null) {
                int index = ((List<Object>)handler.parent.branchData).indexOf(handler.branchData);
                path.insert(index, 0);

                handler = handler.parent;
            }

            return path;
View Full Code Here

            return path;
        }

        @Override
        public void itemInserted(List<Object> list, int index) {
            Path path = getPath();

            // Insert child handler placeholder (lazily loaded)
            insert(null, index);

            // Update our data structures
View Full Code Here

            }
        }

        @Override
        public void itemsRemoved(List<Object> list, int index, Sequence<Object> items) {
            Path path = getPath();

            Path previousSelectedPath;
            if (selectMode == SelectMode.SINGLE
                && selectedPaths.getLength() > 0) {
                previousSelectedPath = selectedPaths.get(0);
            } else {
                previousSelectedPath = null;
View Full Code Here

            }
        }

        @Override
        public void itemUpdated(List<Object> list, int index, Object previousItem) {
            Path path = getPath();

            if (list.get(index) != previousItem) {
                // Release child handler
                BranchHandler handler = update(index, null);
View Full Code Here

TOP

Related Classes of org.apache.pivot.collections.Sequence.Tree.Path

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.