List of usage examples for javafx.collections FXCollections sort
@SuppressWarnings("unchecked") public static <T> void sort(ObservableList<T> list, Comparator<? super T> c)
From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java
/** * create a group with the given GroupKey and file ids and add it to the * analyzed group list.//from ww w . j ava 2 s . com * * @param groupKey * @param filesInGroup */ private synchronized <A extends Comparable<A>> void populateAnalyzedGroup(final GroupKey<A> groupKey, List<Long> filesInGroup, ReGroupTask<A> task) { /* if this is not part of a regroup task or it is but the task is not * cancelled... * * this allows us to stop if a regroup task has been cancelled (e.g. the * user picked a different group by attribute, while the current task * was still running) */ if (task == null || (task.isCancelled() == false)) { DrawableGroup g = makeGroup(groupKey, filesInGroup); final boolean groupSeen = db.isGroupSeen(groupKey); Platform.runLater(() -> { if (analyzedGroups.contains(g) == false) { analyzedGroups.add(g); } synchronized (unSeenGroups) { if (groupSeen == false && unSeenGroups.contains(g) == false) { unSeenGroups.add(g); FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); } } }); } }
From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java
/** * regroup all files in the database using given {@link DrawableAttribute} * see {@link ReGroupTask} for more details. * * @param groupBy/*from w ww. j ava 2 s .c o m*/ * @param sortBy * @param sortOrder * @param force true to force a full db query regroup */ public synchronized <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) { if (!Case.isCaseOpen()) { return; } //only re-query the db if the group by attribute changed or it is forced if (groupBy != getGroupBy() || force == true) { setGroupBy(groupBy); setSortBy(sortBy); setSortOrder(sortOrder); if (groupByTask != null) { groupByTask.cancel(true); } groupByTask = new ReGroupTask<A>(groupBy, sortBy, sortOrder); Platform.runLater(() -> { regroupProgress.bind(groupByTask.progressProperty()); }); regroupExecutor.submit(groupByTask); } else { // resort the list of groups setSortBy(sortBy); setSortOrder(sortOrder); Platform.runLater(() -> { FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy)); FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy)); }); } }
From source file:org.sleuthkit.autopsy.imagegallery.grouping.GroupManager.java
/** * regroup all files in the database using given {@link DrawableAttribute} * see {@link ReGroupTask} for more details. * * @param groupBy//from ww w. ja v a 2 s .c o m * @param sortBy * @param sortOrder * @param force true to force a full db query regroup */ public <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) { if (!Case.isCaseOpen()) { return; } //only re-query the db if the group by attribute changed or it is forced if (groupBy != getGroupBy() || force == true) { setGroupBy(groupBy); setSortBy(sortBy); setSortOrder(sortOrder); if (groupByTask != null) { groupByTask.cancel(true); } Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); groupByTask = new ReGroupTask<A>(groupBy, sortBy, sortOrder); Platform.runLater(() -> { regroupProgress.bind(groupByTask.progressProperty()); }); regroupExecutor.submit(groupByTask); } else { // just resort the list of groups setSortBy(sortBy); setSortOrder(sortOrder); Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); FXCollections.sort(analyzedGroups, sortBy.getGrpComparator(sortOrder)); }); } }
From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java
/** * regroup all files in the database using given {@link DrawableAttribute} * see {@link ReGroupTask} for more details. * * @param groupBy//ww w . ja va 2 s .c om * @param sortBy * @param sortOrder * @param force true to force a full db query regroup */ public <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) { //only re-query the db if the group by attribute changed or it is forced if (groupBy != getGroupBy() || force == true) { setGroupBy(groupBy); setSortBy(sortBy); setSortOrder(sortOrder); if (groupByTask != null) { groupByTask.cancel(true); } Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); groupByTask = new ReGroupTask<A>(groupBy, sortBy, sortOrder); Platform.runLater(() -> { regroupProgress.bind(groupByTask.progressProperty()); }); regroupExecutor.submit(groupByTask); } else { // just resort the list of groups setSortBy(sortBy); setSortOrder(sortOrder); Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); } }
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
/** * Parses JSONObject with funds data inside (key = "funds") * * @param fundsObject Funds JSONObject/*from ww w . j av a 2 s . co m*/ */ private void parseFundsObject(JSONObject fundsObject) { fundsData.clear(); for (Iterator iterator = fundsObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); fundsData.add(new Fund(key, fundsObject.optDouble(key))); } FXCollections.sort(fundsData, new Comparator<Fund>() { @Override public int compare(Fund o1, Fund o2) { return o1.getCurrency().compareTo(o2.getCurrency()); } }); }
From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java
private DrawableGroup popuplateIfAnalyzed(GroupKey<?> groupKey, ReGroupTask<?> task) { if (Objects.nonNull(task) && (task.isCancelled())) { /*//from w w w. j ava 2 s . co m * if this method call is part of a ReGroupTask and that task is * cancelled, no-op * * this allows us to stop if a regroup task has been cancelled (e.g. * the user picked a different group by attribute, while the current * task was still running) */ } else { // no task or un-cancelled task if ((groupKey.getAttribute() != DrawableAttribute.PATH) || db.isGroupAnalyzed(groupKey)) { /* * for attributes other than path we can't be sure a group is * fully analyzed because we don't know all the files that will * be a part of that group,. just show them no matter what. */ try { Set<Long> fileIDs = getFileIDsInGroup(groupKey); if (Objects.nonNull(fileIDs)) { DrawableGroup group; final boolean groupSeen = db.isGroupSeen(groupKey); synchronized (groupMap) { if (groupMap.containsKey(groupKey)) { group = groupMap.get(groupKey); group.setFiles(ObjectUtils.defaultIfNull(fileIDs, Collections.emptySet())); } else { group = new DrawableGroup(groupKey, fileIDs, groupSeen); controller.getCategoryManager().registerListener(group); group.seenProperty().addListener((o, oldSeen, newSeen) -> { Platform.runLater(() -> markGroupSeen(group, newSeen)); }); groupMap.put(groupKey, group); } } Platform.runLater(() -> { if (analyzedGroups.contains(group) == false) { analyzedGroups.add(group); if (Objects.isNull(task)) { FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy)); } } markGroupSeen(group, groupSeen); }); return group; } } catch (TskCoreException ex) { LOGGER.log( Level.SEVERE, "failed to get files for group: " + groupKey.getAttribute().attrName.toString() + " = " + groupKey.getValue(), ex); //NON-NLS } } } return null; }