Example usage for javafx.collections FXCollections sort

List of usage examples for javafx.collections FXCollections sort

Introduction

In this page you can find the example usage for javafx.collections FXCollections sort.

Prototype

@SuppressWarnings("unchecked")
public static <T> void sort(ObservableList<T> list, Comparator<? super T> c) 

Source Link

Document

Sorts the provided observable list using the c comparator.

Usage

From source file:org.sleuthkit.autopsy.timeline.ui.detailview.tree.DescriptionTreeItem.java

@Override
void sort(Comparator<TreeItem<TimeLineEvent>> comparator, Boolean recursive) {
    setComparator(comparator);/* w  w w.j  av  a 2  s  . com*/
    FXCollections.sort(getChildren(), comparator); //sort children with new comparator
    if (recursive) {
        //resort children's children
        childMap.values().forEach(ti -> ti.sort(comparator, true));
    }
}

From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.GroupTreeItem.java

/**
 * Recursive method to add a grouping at a given path.
 *
 * @param path Full path (or subset not yet added) to add
 * @param g Group to add/*from w ww .  j  ava 2s. c  o  m*/
 * @param tree True if it is part of a tree (versus a list)
 */
void insert(String path, DrawableGroup g, Boolean tree) {
    if (tree) {
        String cleanPath = StringUtils.stripStart(path, "/");

        // get the first token
        String prefix = StringUtils.substringBefore(cleanPath, "/");

        // Are we at the end of the recursion?
        if ("".equals(prefix)) {
            getValue().setGroup(g);
        } else {
            GroupTreeItem prefixTreeItem = childMap.get(prefix);
            if (prefixTreeItem == null) {
                final GroupTreeItem newTreeItem = new GroupTreeItem(prefix, null, comp);

                prefixTreeItem = newTreeItem;
                childMap.put(prefix, prefixTreeItem);
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        synchronized (getChildren()) {
                            getChildren().add(newTreeItem);
                        }
                    }
                });

            }

            // recursively go into the path
            prefixTreeItem.insert(StringUtils.stripStart(cleanPath, prefix), g, tree);
        }
    } else {
        GroupTreeItem treeItem = childMap.get(path);
        if (treeItem == null) {
            final GroupTreeItem newTreeItem = new GroupTreeItem(path, g, comp);
            newTreeItem.setExpanded(true);
            childMap.put(path, newTreeItem);

            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    synchronized (getChildren()) {
                        getChildren().add(newTreeItem);
                        if (comp != null) {
                            FXCollections.sort(getChildren(), comp);
                        }
                    }
                }
            });

        }
    }
}

From source file:de.rkl.tools.tzconv.model.ApplicationModel.java

public void sortSelectedZoneIds() {
    FXCollections.sort(selectedZoneIds.getValue(), selectedZoneIdOrdering);
}

From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupTreeItem.java

/**
 * Recursive method to add a grouping at a given path.
 *
 * @param path Full path (or subset not yet added) to add
 * @param g    Group to add/*from w w  w  .j  a  v  a 2 s  .  co m*/
 * @param tree True if it is part of a tree (versus a list)
 */
void insert(String path, DrawableGroup g, Boolean tree) {
    if (tree) {
        String cleanPath = StringUtils.stripStart(path, "/");

        // get the first token
        String prefix = StringUtils.substringBefore(cleanPath, "/");

        // Are we at the end of the recursion?
        if ("".equals(prefix)) {
            getValue().setGroup(g);
        } else {
            GroupTreeItem prefixTreeItem = childMap.get(prefix);
            if (prefixTreeItem == null) {
                final GroupTreeItem newTreeItem = new GroupTreeItem(prefix, null, comp);

                prefixTreeItem = newTreeItem;
                childMap.put(prefix, prefixTreeItem);
                Platform.runLater(() -> {
                    synchronized (getChildren()) {
                        getChildren().add(newTreeItem);
                    }
                });

            }

            // recursively go into the path
            prefixTreeItem.insert(StringUtils.stripStart(cleanPath, prefix), g, tree);
        }
    } else {
        GroupTreeItem treeItem = childMap.get(path);
        if (treeItem == null) {
            final GroupTreeItem newTreeItem = new GroupTreeItem(path, g, comp);
            newTreeItem.setExpanded(true);
            childMap.put(path, newTreeItem);

            Platform.runLater(() -> {
                synchronized (getChildren()) {
                    getChildren().add(newTreeItem);
                    if (comp != null) {
                        FXCollections.sort(getChildren(), comp);
                    }
                }
            });

        }
    }
}

From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.GroupTreeItem.java

/**
 * Recursive method to add a grouping at a given path.
 *
 * @param path Full path (or subset not yet added) to add
 * @param g Group to add//from   ww  w  .j ava  2 s  .  co  m
 * @param tree True if it is part of a tree (versus a list)
 */
void insert(List<String> path, DrawableGroup g, Boolean tree) {
    if (tree) {
        // Are we at the end of the recursion?
        if (path.isEmpty()) {
            getValue().setGroup(g);
        } else {
            String prefix = path.get(0);

            GroupTreeItem prefixTreeItem = childMap.get(prefix);
            if (prefixTreeItem == null) {
                final GroupTreeItem newTreeItem = new GroupTreeItem(prefix, null, comp);

                prefixTreeItem = newTreeItem;
                childMap.put(prefix, prefixTreeItem);

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        synchronized (getChildren()) {
                            getChildren().add(newTreeItem);
                        }
                    }
                });

            }

            // recursively go into the path
            prefixTreeItem.insert(path.subList(1, path.size()), g, tree);
        }
    } else {
        //flat list
        GroupTreeItem treeItem = childMap.get(StringUtils.join(path, "/"));
        if (treeItem == null) {
            final GroupTreeItem newTreeItem = new GroupTreeItem(StringUtils.join(path, "/"), g, comp);
            newTreeItem.setExpanded(true);
            childMap.put(path.get(0), newTreeItem);

            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    synchronized (getChildren()) {
                        getChildren().add(newTreeItem);
                        if (comp != null) {
                            FXCollections.sort(getChildren(), comp);
                        }
                    }
                }
            });
        }
    }
}

From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupTreeItem.java

/**
 * Recursive method to add a grouping at a given path.
 *
 * @param path Full path (or subset not yet added) to add
 * @param g    Group to add/*  w  ww.  ja v a2s.  co  m*/
 * @param tree True if it is part of a tree (versus a list)
 */
void insert(List<String> path, DrawableGroup g, Boolean tree) {
    if (tree) {
        // Are we at the end of the recursion?
        if (path.isEmpty()) {
            getValue().setGroup(g);
        } else {
            String prefix = path.get(0);

            GroupTreeItem prefixTreeItem = childMap.get(prefix);
            if (prefixTreeItem == null) {
                final GroupTreeItem newTreeItem = new GroupTreeItem(prefix, null, comp);

                prefixTreeItem = newTreeItem;
                childMap.put(prefix, prefixTreeItem);

                Platform.runLater(() -> {
                    synchronized (getChildren()) {
                        getChildren().add(newTreeItem);
                    }
                });

            }

            // recursively go into the path
            prefixTreeItem.insert(path.subList(1, path.size()), g, tree);
        }
    } else {
        //flat list
        GroupTreeItem treeItem = childMap.get(StringUtils.join(path, "/"));
        if (treeItem == null) {
            final GroupTreeItem newTreeItem = new GroupTreeItem(StringUtils.join(path, "/"), g, comp);
            newTreeItem.setExpanded(true);
            childMap.put(path.get(0), newTreeItem);

            Platform.runLater(() -> {
                synchronized (getChildren()) {
                    getChildren().add(newTreeItem);
                    if (comp != null) {
                        FXCollections.sort(getChildren(), comp);
                    }
                }
            });
        }
    }
}

From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.GroupTreeItem.java

void resortChildren(TreeNodeComparators newComp) {
    this.comp = newComp;
    synchronized (getChildren()) {
        FXCollections.sort(getChildren(), comp);
    }//from  www .ja v  a 2 s. c o m
    for (GroupTreeItem ti : childMap.values()) {
        ti.resortChildren(comp);
    }
}

From source file:org.sleuthkit.autopsy.imagegallery.grouping.GroupManager.java

/**
 * 'mark' the given group as seen. This removes it from the queue of groups
 * to review, and is persisted in the drawable db.
 *
 * @param group the {@link  DrawableGroup} to mark as seen
 *//*from  w  w  w  .ja  v a 2s.co  m*/
@ThreadConfined(type = ThreadType.JFX)
public void markGroupSeen(DrawableGroup group, boolean seen) {
    db.markGroupSeen(group.getGroupKey(), seen);
    group.setSeen(seen);
    if (seen) {
        unSeenGroups.removeAll(group);
    } else if (unSeenGroups.contains(group) == false) {
        unSeenGroups.add(group);
        FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder));
    }
}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java

/**
 * 'mark' the given group as seen. This removes it from the queue of groups
 * to review, and is persisted in the drawable db.
 *
 * @param group the {@link  DrawableGroup} to mark as seen
 *//*ww w . j a va  2s .c  o  m*/
@ThreadConfined(type = ThreadType.JFX)
public void markGroupSeen(DrawableGroup group, boolean seen) {

    db.markGroupSeen(group.getGroupKey(), seen);
    group.setSeen(seen);
    if (seen) {
        unSeenGroups.removeAll(group);
    } else if (unSeenGroups.contains(group) == false) {
        unSeenGroups.add(group);
    }
    FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy));
}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java

/**
 * remove the given file from the group with the given key. If the group
 * doesn't exist or doesn't already contain this file, this method is a
 * no-op/*from  ww w  . j  a va2  s .com*/
 *
 * @param groupKey the value of groupKey
 * @param fileID   the value of file
 */
public synchronized DrawableGroup removeFromGroup(GroupKey<?> groupKey, final Long fileID) {
    //get grouping this file would be in
    final DrawableGroup group = getGroupForKey(groupKey);
    if (group != null) {
        Platform.runLater(() -> {
            group.removeFile(fileID);
        });

        // If we're grouping by category, we don't want to remove empty groups.
        if (groupKey.getAttribute() != DrawableAttribute.CATEGORY) {
            if (group.getFileIDs().isEmpty()) {
                Platform.runLater(() -> {
                    if (analyzedGroups.contains(group)) {
                        analyzedGroups.remove(group);
                        FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy));
                    }
                    if (unSeenGroups.contains(group)) {
                        unSeenGroups.remove(group);
                        FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy));
                    }
                });
            }
        } else { //group == null
            // It may be that this was the last unanalyzed file in the group, so test
            // whether the group is now fully analyzed.
            popuplateIfAnalyzed(groupKey, null);
        }
    }
    return group;
}