diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java index 411d6ec33b..22b2c1b98b 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java @@ -226,7 +226,22 @@ public class TagsManager implements Closeable { tskCase.deleteContentTag(tag); } - + + /** + * Gets content tags count by tag name. + * @param [in] tagName The tag name of interest. + * @return A count of the content tags with the specified tag name. + * @throws TskCoreException + */ + public synchronized long getContentTagsCountByTagName(TagName tagName) throws TskCoreException { + // @@@ This is a work around to be removed when database access on the EDT is correctly synchronized. + if (!tagNamesInitialized) { + getExistingTagNames(); + } + + return tskCase.getContentTagsCountByTagName(tagName); + } + /** * Gets content tags by tag name. * @param [in] tagName The tag name of interest. @@ -282,6 +297,21 @@ public class TagsManager implements Closeable { tskCase.deleteBlackboardArtifactTag(tag); } + /** + * Gets blackboard artifact tags count by tag name. + * @param [in] tagName The tag name of interest. + * @return A count of the blackboard artifact tags with the specified tag name. + * @throws TskCoreException + */ + public synchronized long getBlackboardArtifactTagsCountByTagName(TagName tagName) throws TskCoreException { + // @@@ This is a work around to be removed when database access on the EDT is correctly synchronized. + if (!tagNamesInitialized) { + getExistingTagNames(); + } + + return tskCase.getBlackboardArtifactTagsCountByTagName(tagName); + } + /** * Gets blackboard artifact tags by tag name. * @param [in] tagName The tag name of interest. diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ContentTagTypeNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/ContentTagTypeNode.java index 92dfa50243..6c1a454357 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ContentTagTypeNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ContentTagTypeNode.java @@ -41,8 +41,17 @@ public class ContentTagTypeNode extends DisplayableItemNode { public ContentTagTypeNode(TagName tagName) { super(Children.create(new ContentTagNodeFactory(tagName), true)); - super.setName(DISPLAY_NAME); - super.setDisplayName(DISPLAY_NAME); + + long tagsCount = 0; + try { + tagsCount = Case.getCurrentCase().getServices().getTagsManager().getContentTagsCountByTagName(tagName); + } + catch (TskCoreException ex) { + Logger.getLogger(ContentTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get content tags count for " + tagName.getDisplayName() + " tag name", ex); + } + + super.setName(DISPLAY_NAME + " (" + tagsCount + ")"); + super.setDisplayName(DISPLAY_NAME + " (" + tagsCount + ")"); this.setIconBaseWithExtension(ICON_PATH); } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/TagNameNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/TagNameNode.java index 3d7783ae98..05f4a00627 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/TagNameNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/TagNameNode.java @@ -19,12 +19,16 @@ package org.sleuthkit.autopsy.datamodel; import java.util.List; +import java.util.logging.Level; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.nodes.Sheet; +import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.directorytree.BlackboardArtifactTagTypeNode; import org.sleuthkit.datamodel.TagName; +import org.sleuthkit.datamodel.TskCoreException; /** * Instances of this class are elements of Node hierarchies consisting of @@ -32,8 +36,6 @@ import org.sleuthkit.datamodel.TagName; * tag name. */ public class TagNameNode extends DisplayableItemNode { - private static final String CONTENT_TAG_TYPE_NODE_KEY = "Content Tags"; - private static final String BLACKBOARD_ARTIFACT_TAG_TYPE_NODE_KEY = "Result Tags"; private static final String ICON_PATH = "org/sleuthkit/autopsy/images/tag-folder-blue-icon-16.png"; private static final String BOOKMARK_TAG_ICON_PATH = "org/sleuthkit/autopsy/images/star-bookmark-icon-16.png"; private final TagName tagName; @@ -41,8 +43,18 @@ public class TagNameNode extends DisplayableItemNode { public TagNameNode(TagName tagName) { super(Children.create(new TagTypeNodeFactory(tagName), true)); this.tagName = tagName; - super.setName(tagName.getDisplayName()); - super.setDisplayName(tagName.getDisplayName()); + + long tagsCount = 0; + try { + tagsCount = Case.getCurrentCase().getServices().getTagsManager().getContentTagsCountByTagName(tagName); + tagsCount += Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsCountByTagName(tagName); + } + catch (TskCoreException ex) { + Logger.getLogger(TagNameNode.class.getName()).log(Level.SEVERE, "Failed to get tags count for " + tagName.getDisplayName() + " tag name", ex); + } + + super.setName(tagName.getDisplayName() + " (" + tagsCount + ")"); + super.setDisplayName(tagName.getDisplayName() + " (" + tagsCount + ")"); if (tagName.getDisplayName().equals("Bookmark")) { setIconBaseWithExtension(BOOKMARK_TAG_ICON_PATH); } @@ -78,6 +90,8 @@ public class TagNameNode extends DisplayableItemNode { } private static class TagTypeNodeFactory extends ChildFactory { + private static final String CONTENT_TAG_TYPE_NODE_KEY = "Content Tags"; + private static final String BLACKBOARD_ARTIFACT_TAG_TYPE_NODE_KEY = "Result Tags"; private final TagName tagName; TagTypeNodeFactory(TagName tagName) { diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/BlackboardArtifactTagTypeNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/BlackboardArtifactTagTypeNode.java index 8c2e904aed..543db96eb0 100755 --- a/Core/src/org/sleuthkit/autopsy/directorytree/BlackboardArtifactTagTypeNode.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/BlackboardArtifactTagTypeNode.java @@ -42,12 +42,21 @@ import org.sleuthkit.datamodel.TskCoreException; */ public class BlackboardArtifactTagTypeNode extends DisplayableItemNode { private static final String DISPLAY_NAME = "Result Tags"; - private static final String ICON_PATH = "org/sleuthkit/autopsy/images/tag-folder-blue-icon-16.png"; // RJCTODO: Different icon? + private static final String ICON_PATH = "org/sleuthkit/autopsy/images/tag-folder-blue-icon-16.png"; public BlackboardArtifactTagTypeNode(TagName tagName) { super(Children.create(new BlackboardArtifactTagNodeFactory(tagName), true)); - super.setName(DISPLAY_NAME); - super.setDisplayName(DISPLAY_NAME); + + long tagsCount = 0; + try { + tagsCount = Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsCountByTagName(tagName); + } + catch (TskCoreException ex) { + Logger.getLogger(BlackboardArtifactTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get blackboard artifact tags count for " + tagName.getDisplayName() + " tag name", ex); + } + + super.setName(DISPLAY_NAME + " (" + tagsCount + ")"); + super.setDisplayName(DISPLAY_NAME + " (" + tagsCount + ")"); this.setIconBaseWithExtension(ICON_PATH); }