Package pivot.collections.Sequence.Tree

Examples of pivot.collections.Sequence.Tree.Path


                // No-op
            }

            public void selectedPathsChanged(TreeView treeView,
                Sequence<Path> previousSelectedPaths) {
                Path selectedPath = treeView.getSelectedPath();

                if (selectedNode != null) {
                    selectedNode.getNodeListeners().remove(selectedNodeListener);
                }
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;
        }

        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

            // Notify listeners
            treeViewNodeListeners.nodeInserted(TreeView.this, path, index);
        }

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

            // Remove child handlers
            int count = items.getLength();
            Sequence<BranchHandler> removed = remove(index, count);
View Full Code Here

            // Notify listeners
            treeViewNodeListeners.nodesRemoved(TreeView.this, path, index, count);
        }

        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

            // Notify listeners
            treeViewNodeListeners.nodeUpdated(TreeView.this, path, index);
        }

        public void listCleared(List<Object> list) {
            Path path = getPath();

            // Release each child handler
            for (int i = 0, n = getLength(); i < n; i++) {
                BranchHandler handler = get(i);
View Full Code Here

        }

        public void comparatorChanged(List<Object> list,
            Comparator<Object> previousComparator) {
            if (list.getComparator() != null) {
                Path path = getPath();

                // Release all child handlers. This is safe because of the
                // calls to clearPaths(). Failure to do this would result in
                // the indices of our child handlers not matching those of the
                // backing data structures, which would yield very hard to find
View Full Code Here

         * @param index
         * The index of the inserted item within its parent.
         */
        private void incrementPaths(Sequence<Path> paths, Path basePath, int index) {
            // Calculate the child's path
            Path childPath = new Path(basePath);
            childPath.add(index);

            // Find the child path's place in our sorted paths sequence
            int i = Sequence.Search.binarySearch(paths, childPath, PATH_COMPARATOR);
            if (i < 0) {
                i = -(i + 1);
            }

            // Update all affected paths by incrementing the appropriate path element
            for (int depth = basePath.getLength(), n = paths.getLength(); i < n; i++) {
                Path affectedPath = paths.get(i);

                if (!Sequence.Tree.isDescendant(basePath, affectedPath)) {
                    // All paths from here forward are guaranteed to be unaffected
                    break;
                }

                affectedPath.update(depth, affectedPath.get(depth) + 1);
            }
        }
View Full Code Here

         */
        private void clearAndDecrementPaths(Sequence<Path> paths, Path basePath, int index, int count) {
            int depth = basePath.getLength();

            // Find the index of the first path to clear (inclusive)
            Path testPath = new Path(basePath);
            testPath.add(index);

            int start = Sequence.Search.binarySearch(paths, testPath, PATH_COMPARATOR);
            if (start < 0) {
                start = -(start + 1);
            }

            // Find the index of the last path to clear (exclusive)
            testPath.update(depth, index + count);

            int end = Sequence.Search.binarySearch(paths, testPath, PATH_COMPARATOR);
            if (end < 0) {
                end = -(end + 1);
            }

            // Clear affected paths
            if (end > start) {
                paths.remove(start, end - start);
            }

            // Decrement paths as necessary
            for (int i = start, n = paths.getLength(); i < n; i++) {
                Path affectedPath = paths.get(i);

                if (!Sequence.Tree.isDescendant(basePath, affectedPath)) {
                    // All paths from here forward are guaranteed to be unaffected
                    break;
                }

                affectedPath.update(depth, affectedPath.get(depth) - count);
            }
        }
View Full Code Here

         * @param index
         * The index of the updated item within its parent.
         */
        private void clearPaths(Sequence<Path> paths, Path basePath, int index) {
            // Calculate the child's path
            Path childPath = new Path(basePath);
            childPath.add(index);

            // Find the child path's place in our sorted paths sequence
            int clearIndex = Sequence.Search.binarySearch(paths, childPath, PATH_COMPARATOR);
            if (clearIndex < 0) {
                clearIndex = -(clearIndex + 1);
            }

            // Remove the child and all descendants from the paths list
            for (int i = clearIndex, n = paths.getLength(); i < n; i++) {
                Path affectedPath = paths.get(clearIndex);

                if (!Sequence.Tree.isDescendant(childPath, affectedPath)) {
                    break;
                }

View Full Code Here

TOP

Related Classes of 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.