diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java index 555562efff..4eb511f604 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java @@ -38,18 +38,18 @@ import org.sleuthkit.datamodel.TskCoreException; * model objects. */ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { - + private static final String NO_COMMENT = ""; - + AddTagAction(String menuText) { super(menuText); } - + @Override public JMenuItem getPopupPresenter() { return new TagMenu(); } - + /** * Subclasses of AddTagAction, should not override actionPerformed, but * instead override addTag. @@ -60,19 +60,19 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { @SuppressWarnings("NoopMethodInAbstractClass") public void actionPerformed(ActionEvent event) { } - + /** * Template method to allow derived classes to provide a string for a menu * item label. */ abstract protected String getActionDisplayName(); - + /** * Template method to allow derived classes to add the indicated tag and * comment to one or more SleuthKit data model objects. */ abstract protected void addTag(TagName tagName, String comment); - + /** * Instances of this class implement a context menu user interface for * creating or selecting a tag name for a tag and specifying an optional tag @@ -81,10 +81,10 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { // @@@ This user interface has some significant usability issues and needs // to be reworked. private class TagMenu extends JMenu { - + TagMenu() { super(getActionDisplayName()); - + // Get the current set of tag names. TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager(); List tagNames = null; @@ -94,11 +94,11 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { } catch (TskCoreException ex) { Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS } - + // Create a "Quick Tag" sub-menu. JMenu quickTagMenu = new JMenu(NbBundle.getMessage(this.getClass(), "AddTagAction.quickTag")); add(quickTagMenu); - + // Each tag name in the current set of tags gets its own menu item in // the "Quick Tags" sub-menu. Selecting one of these menu items adds // a tag with the associated tag name. @@ -115,9 +115,9 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { empty.setEnabled(false); quickTagMenu.add(empty); } - + quickTagMenu.addSeparator(); - + // The "Quick Tag" menu also gets an "Choose Tag..." menu item. // Selecting this item initiates a dialog that can be used to create // or select a tag name and adds a tag with the resulting name. @@ -129,7 +129,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { } }); quickTagMenu.add(newTagMenuItem); - + // Create a "Choose Tag and Comment..." menu item. Selecting this item initiates // a dialog that can be used to create or select a tag name with an // optional comment and adds a tag with the resulting name. @@ -142,7 +142,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { } }); add(tagAndCommentItem); - + } } } diff --git a/Core/src/org/sleuthkit/autopsy/actions/BookmarkFileAction.java b/Core/src/org/sleuthkit/autopsy/actions/BookmarkFileAction.java index 29cb9aa0e0..b866b95899 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/BookmarkFileAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/BookmarkFileAction.java @@ -6,40 +6,26 @@ package org.sleuthkit.autopsy.actions; import java.awt.event.ActionEvent; -import java.util.Collection; -import java.util.HashSet; -import java.util.logging.Level; +import java.util.List; import javax.swing.AbstractAction; -import org.openide.util.Exceptions; -import org.openide.util.Utilities; +import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.casemodule.services.TagsManager; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TagName; -import org.sleuthkit.datamodel.TskCoreException; -public class BookmarkFileAction extends AbstractAction { - +class BookmarkFileAction extends AbstractAction { + private static final String NO_COMMENT = ""; - private static final String BOOKMARK = "Bookmark"; + private static final String BOOKMARK = NbBundle.getMessage(BookmarkFileAction.class, "BookmarkFileAction.bookmark.text"); @Override public void actionPerformed(ActionEvent e) { - TagName tagName = null; - try { - tagName = Case.getCurrentCase().getServices().getTagsManager().addTagName(BOOKMARK); - } catch (TagsManager.TagNameAlreadyExistsException ex) { - try { - tagName = Case.getCurrentCase().getServices().getTagsManager().getTagName(BOOKMARK); - } catch (TagsManager.TagNameDoesNotExistException ex1) { - // already confirmed that tag name does exist + List tagNames = Case.getCurrentCase().getServices().getTagsManager().getPredefinedTagNames(); + for (TagName tagName : tagNames) { + if (tagName.getDisplayName().equals(BOOKMARK)) { + AddContentTagAction.getInstance().addTag(tagName, NO_COMMENT); + return; } - } catch (TskCoreException ex) { - Logger.getLogger(BookmarkFileAction.class.getName()).log(Level.SEVERE, "Error tagging file", ex); //NON-NLS - } finally { - AddContentTagAction.getInstance().addTag(tagName, NO_COMMENT); } } - + } diff --git a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties index e93cb39e05..669af93096 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties @@ -30,6 +30,7 @@ AddTagAction.quickTag=Quick Tag AddTagAction.noTags=No tags AddTagAction.newTag=New Tag... AddTagAction.tagAndComment=Tag and Comment... +BookmarkFileAction.bookmark.text=Bookmark DeleteBlackboardArtifactTagAction.deleteTags=Delete Tag(s) DeleteBlackboardArtifactTagAction.unableToDelTag.msg=Unable to delete tag {0}. DeleteBlackboardArtifactTagAction.tagDelErr=Tag Deletion Error diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java index e0a382be54..d60872a905 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java @@ -93,16 +93,6 @@ public class TagsManager implements Closeable { lazyLoadExistingTagNames(); return caseDb.getTagNamesInUse(); } - - public synchronized TagName getTagName(String tagDisplayName) throws TagNameDoesNotExistException { - lazyLoadExistingTagNames(); - if (tagNameExists(tagDisplayName)) { - return uniqueTagNames.get(tagDisplayName); - } - else { - throw new TagNameDoesNotExistException(); - } - } /** * Checks whether a tag name with a given display name exists. @@ -683,11 +673,4 @@ public class TagsManager implements Closeable { private static final long serialVersionUID = 1L; } - - public static class TagNameDoesNotExistException extends Exception { - - public TagNameDoesNotExistException() { - } - } - }