mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
rename method in CategoryManager to be more descriptive; fix tag and category grouping when tags aer added / removed
This commit is contained in:
parent
ff11258e9c
commit
68d28db500
@ -211,7 +211,7 @@ public class CategoryManager {
|
||||
|
||||
}
|
||||
|
||||
public static Category fromTagName(TagName tagName) {
|
||||
public static Category categoryFromTagName(TagName tagName) {
|
||||
return Category.fromDisplayName(tagName.getDisplayName());
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ public class CategoryManager {
|
||||
} catch (TskCoreException tskException) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to get content tags for content. Unable to maintain category in a consistent state.", tskException);
|
||||
}
|
||||
Category newCat = CategoryManager.fromTagName(addedTag.getName());
|
||||
Category newCat = CategoryManager.categoryFromTagName(addedTag.getName());
|
||||
if (newCat != Category.ZERO) {
|
||||
incrementCategoryCount(newCat);
|
||||
}
|
||||
@ -259,7 +259,7 @@ public class CategoryManager {
|
||||
ContentTag deleted = event.getDeletedTag();
|
||||
if (isCategoryTagName(deleted.getName())) {
|
||||
|
||||
Category deletedCat = CategoryManager.fromTagName(deleted.getName());
|
||||
Category deletedCat = CategoryManager.categoryFromTagName(deleted.getName());
|
||||
if (deletedCat != Category.ZERO) {
|
||||
decrementCategoryCount(deletedCat);
|
||||
}
|
||||
|
@ -539,20 +539,25 @@ public class GroupManager implements FileUpdateEvent.FileUpdateListener {
|
||||
|
||||
@Subscribe
|
||||
public void handleTagAdded(ContentTagAddedEvent evt) {
|
||||
if (groupBy == DrawableAttribute.TAGS || groupBy == DrawableAttribute.CATEGORY) {
|
||||
final GroupKey<TagName> groupKey = new GroupKey<>(DrawableAttribute.TAGS, evt.getAddedTag().getName());
|
||||
final long fileID = evt.getAddedTag().getContent().getId();
|
||||
DrawableGroup g = getGroupForKey(groupKey);
|
||||
addFileToGroup(g, groupKey, fileID);
|
||||
GroupKey<?> groupKey = null;
|
||||
if (groupBy == DrawableAttribute.TAGS) {
|
||||
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getAddedTag().getName());
|
||||
} else if (groupBy == DrawableAttribute.CATEGORY) {
|
||||
groupKey = new GroupKey<Category>(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getAddedTag().getName()));
|
||||
}
|
||||
final long fileID = evt.getAddedTag().getContent().getId();
|
||||
DrawableGroup g = getGroupForKey(groupKey);
|
||||
addFileToGroup(g, groupKey, fileID);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("AssignmentToMethodParameter")
|
||||
private void addFileToGroup(DrawableGroup g, final GroupKey<?> groupKey, final long fileID) {
|
||||
if (g == null) {
|
||||
//if there wasn't already a group check if there should be one now
|
||||
popuplateIfAnalyzed(groupKey, null);
|
||||
} else {
|
||||
g = popuplateIfAnalyzed(groupKey, null);
|
||||
}
|
||||
if (g != null) {
|
||||
//if there is aleady a group that was previously deemed fully analyzed, then add this newly analyzed file to it.
|
||||
g.addFile(fileID);
|
||||
}
|
||||
@ -560,11 +565,14 @@ public class GroupManager implements FileUpdateEvent.FileUpdateListener {
|
||||
|
||||
@Subscribe
|
||||
public void handleTagDeleted(ContentTagDeletedEvent evt) {
|
||||
if (groupBy == DrawableAttribute.TAGS || groupBy == DrawableAttribute.CATEGORY) {
|
||||
final GroupKey<TagName> groupKey = new GroupKey<>(DrawableAttribute.TAGS, evt.getDeletedTag().getName());
|
||||
final long fileID = evt.getDeletedTag().getContent().getId();
|
||||
DrawableGroup g = removeFromGroup(groupKey, fileID);
|
||||
GroupKey<?> groupKey = null;
|
||||
if (groupBy == DrawableAttribute.TAGS) {
|
||||
groupKey = new GroupKey<TagName>(DrawableAttribute.TAGS, evt.getDeletedTag().getName());
|
||||
} else if (groupBy == DrawableAttribute.CATEGORY) {
|
||||
groupKey = new GroupKey<Category>(DrawableAttribute.CATEGORY, CategoryManager.categoryFromTagName(evt.getDeletedTag().getName()));
|
||||
}
|
||||
final long fileID = evt.getDeletedTag().getContent().getId();
|
||||
DrawableGroup g = removeFromGroup(groupKey, fileID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -631,7 +639,7 @@ public class GroupManager implements FileUpdateEvent.FileUpdateListener {
|
||||
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 */
|
||||
* will be a part of that group,. just show them no matter what. */
|
||||
|
||||
try {
|
||||
Set<Long> fileIDs = getFileIDsInGroup(groupKey);
|
||||
@ -643,9 +651,8 @@ public class GroupManager implements FileUpdateEvent.FileUpdateListener {
|
||||
group = groupMap.get(groupKey);
|
||||
group.setFiles(ObjectUtils.defaultIfNull(fileIDs, Collections.emptySet()));
|
||||
} else {
|
||||
|
||||
group = new DrawableGroup(groupKey, fileIDs, groupSeen);
|
||||
group.seenProperty().addListener((observable, oldSeen, newSeen) -> {
|
||||
group.seenProperty().addListener((o, oldSeen, newSeen) -> {
|
||||
markGroupSeen(group, newSeen);
|
||||
});
|
||||
groupMap.put(groupKey, group);
|
||||
|
@ -25,6 +25,7 @@ import javafx.application.Platform;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
@ -282,24 +283,20 @@ public class SlideShowView extends DrawableTileBase {
|
||||
|
||||
@Override
|
||||
protected String getTextForLabel() {
|
||||
return getFile().map(file -> file.getName() + " " + getSupplementalText()).orElse("");
|
||||
return getFile().map(file -> file.getName()).orElse("") + " " + getSupplementalText();
|
||||
}
|
||||
|
||||
@ThreadConfined(type = ThreadType.JFX)
|
||||
private void cycleSlideShowImage(int d) {
|
||||
private void cycleSlideShowImage(int direction) {
|
||||
stopVideo();
|
||||
if (getFileID().isPresent()) {
|
||||
int index = getGroupPane().getGrouping().fileIds().indexOf(getFileID());
|
||||
final int size = getGroupPane().getGrouping().fileIds().size();
|
||||
index = (index + d) % size;
|
||||
if (index < 0) {
|
||||
index += size;
|
||||
}
|
||||
setFile(getGroupPane().getGrouping().fileIds().get(index));
|
||||
final int groupSize = getGroupPane().getGrouping().fileIds().size();
|
||||
final Integer nextIndex = getFileID().map(fileID -> {
|
||||
final int currentIndex = getGroupPane().getGrouping().fileIds().indexOf(fileID);
|
||||
return (currentIndex + direction + groupSize) % groupSize;
|
||||
}).orElse(0);
|
||||
setFile(getGroupPane().getGrouping().fileIds().get(nextIndex)
|
||||
);
|
||||
|
||||
} else {
|
||||
setFile(getGroupPane().getGrouping().fileIds().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,7 +304,10 @@ public class SlideShowView extends DrawableTileBase {
|
||||
* of y"
|
||||
*/
|
||||
private String getSupplementalText() {
|
||||
return " ( " + (getGroupPane().getGrouping().fileIds().indexOf(getFileID()) + 1) + " of " + getGroupPane().getGrouping().fileIds().size() + " in group )";
|
||||
final ObservableList<Long> fileIds = getGroupPane().getGrouping().fileIds();
|
||||
return getFileID().map(fileID -> " ( " + (fileIds.indexOf(fileID) + 1) + " of " + fileIds.size() + " in group )")
|
||||
.orElse("");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user