Merge branch '3201-ManageTagsOptionsPanel' of https://github.com/wschaeferB/autopsy into 3202-TagsMessagingOnStatusChange

boolean isSelected = tagNamesList.getSelectedIndex() != -1;
        boolean enableEdit = !ingestIsRunning && isSelected;
        editTagNameButton.setEnabled(enableEdit);
        boolean enableDelete = enableEdit && !TagNameDefinition.getStandardTagNames().contains(tagNamesList.getSelectedValue().getDisplayName());
        deleteTagNameButton.setEnabled(enableDelete);
        if (isSelected) {

            descriptionTextArea.setText(tagNamesList.getSelectedValue().getDescription());
            if (tagNamesList.getSelectedValue().isNotable()) {
                notableYesOrNoLabel.setText("Yes");
            } else {
                notableYesOrNoLabel.setText("No");
            }
        } else {
            descriptionTextArea.setText("");
            notableYesOrNoLabel.setText("");
        }the commit.
This commit is contained in:
William Schaefer 2017-11-17 15:46:26 -05:00
commit 7cea808fc0
5 changed files with 38 additions and 45 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2016 Basis Technology Corp. * Copyright 2011-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -25,9 +25,14 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TagName;
import org.sleuthkit.autopsy.datamodel.tags.Category; import org.sleuthkit.autopsy.datamodel.tags.Category;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskData;
/** /**
@ -36,11 +41,14 @@ import org.sleuthkit.datamodel.TskData;
@Immutable @Immutable
public final class TagNameDefinition implements Comparable<TagNameDefinition> { public final class TagNameDefinition implements Comparable<TagNameDefinition> {
@NbBundle.Messages({"TagNameDefinition.predefTagNames.bookmark.text=Bookmark",
"TagNameDefinition.predefTagNames.followUp.text=Follow Up",
"TagNameDefinition.predefTagNames.notableItem.text=Notable Item"})
private static final String TAGS_SETTINGS_NAME = "Tags"; //NON-NLS private static final String TAGS_SETTINGS_NAME = "Tags"; //NON-NLS
private static final String TAG_NAMES_SETTING_KEY = "TagNames"; //NON-NLS private static final String TAG_NAMES_SETTING_KEY = "TagNames"; //NON-NLS
private static final List<String> STANDARD_NOTABLE_TAG_DISPLAY_NAMES = Arrays.asList(TagsManager.getNotableItemText(), Category.ONE.getDisplayName(), Category.TWO.getDisplayName(), Category.THREE.getDisplayName()); // NON-NLS private static final List<String> STANDARD_NOTABLE_TAG_DISPLAY_NAMES = Arrays.asList(Bundle.TagNameDefinition_predefTagNames_notableItem_text(), Category.ONE.getDisplayName(), Category.TWO.getDisplayName(), Category.THREE.getDisplayName()); // NON-NLS
static final List<String> STANDARD_TAG_DISPLAY_NAMES = Arrays.asList(TagsManager.getBookmarkText(), TagsManager.getFollowUpText(), private static final List<String> STANDARD_TAG_DISPLAY_NAMES = Arrays.asList(Bundle.TagNameDefinition_predefTagNames_bookmark_text(), Bundle.TagNameDefinition_predefTagNames_followUp_text(),
TagsManager.getNotableItemText(), Category.ONE.getDisplayName(), Bundle.TagNameDefinition_predefTagNames_notableItem_text(), Category.ONE.getDisplayName(),
Category.TWO.getDisplayName(), Category.THREE.getDisplayName(), Category.TWO.getDisplayName(), Category.THREE.getDisplayName(),
Category.FOUR.getDisplayName(), Category.FIVE.getDisplayName()); Category.FOUR.getDisplayName(), Category.FIVE.getDisplayName());
private final String displayName; private final String displayName;
@ -65,6 +73,10 @@ public final class TagNameDefinition implements Comparable<TagNameDefinition> {
this.knownStatus = status; this.knownStatus = status;
} }
static List<String> getStandardTagNames() {
return STANDARD_TAG_DISPLAY_NAMES;
}
/** /**
* Gets the display name for the tag name. * Gets the display name for the tag name.
* *
@ -166,6 +178,16 @@ public final class TagNameDefinition implements Comparable<TagNameDefinition> {
return displayName + "," + description + "," + color.name() + "," + knownStatus.toString(); return displayName + "," + description + "," + color.name() + "," + knownStatus.toString();
} }
private TagName saveToCase(SleuthkitCase caseDb) {
TagName tagName = null;
try {
tagName = caseDb.addTagName(displayName, description, color, knownStatus);
} catch (TskCoreException ex) {
Exceptions.printStackTrace(ex);
}
return tagName;
}
/** /**
* Gets tag name definitions from the tag settings file as well as the * Gets tag name definitions from the tag settings file as well as the
* default tag name definitions. * default tag name definitions.
@ -222,6 +244,10 @@ public final class TagNameDefinition implements Comparable<TagNameDefinition> {
setting.append(";"); setting.append(";");
} }
setting.append(tagName.toSettingsFormat()); setting.append(tagName.toSettingsFormat());
if (Case.isCaseOpen()) {
SleuthkitCase caseDb = Case.getCurrentCase().getSleuthkitCase();
tagName.saveToCase(caseDb);
}
} }
ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY, setting.toString()); ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY, setting.toString());
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2016 Basis Technology Corp. * Copyright 2011-2017 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -137,9 +137,9 @@ final class TagNameDialog extends javax.swing.JDialog {
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return; return;
} }
//if a tag name contains illegal characters and is not the name of one of the standard tags //if a tag name contains illegal characters and is not the name of one of the standard tags
if (TagsManager.containsIllegalCharacters(newTagDisplayName) && !TagNameDefinition.STANDARD_TAG_DISPLAY_NAMES.contains(newTagDisplayName)) { if (TagsManager.containsIllegalCharacters(newTagDisplayName) && !TagNameDefinition.getStandardTagNames().contains(newTagDisplayName)) {
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(null,
NbBundle.getMessage(TagNameDialog.class, "TagNameDialog.JOptionPane.tagNameIllegalCharacters.message"), NbBundle.getMessage(TagNameDialog.class, "TagNameDialog.JOptionPane.tagNameIllegalCharacters.message"),
NbBundle.getMessage(TagNameDialog.class, "TagNameDialog.JOptionPane.tagNameIllegalCharacters.title"), NbBundle.getMessage(TagNameDialog.class, "TagNameDialog.JOptionPane.tagNameIllegalCharacters.title"),

View File

@ -442,7 +442,7 @@ final class TagOptionsPanel extends javax.swing.JPanel implements OptionsPanel {
boolean isSelected = tagNamesList.getSelectedIndex() != -1; boolean isSelected = tagNamesList.getSelectedIndex() != -1;
boolean enableEdit = !ingestIsRunning && isSelected; boolean enableEdit = !ingestIsRunning && isSelected;
editTagNameButton.setEnabled(enableEdit); editTagNameButton.setEnabled(enableEdit);
boolean enableDelete = enableEdit && !TagNameDefinition.STANDARD_TAG_DISPLAY_NAMES.contains(tagNamesList.getSelectedValue().getDisplayName()); boolean enableDelete = enableEdit && !TagNameDefinition.getStandardTagNames().contains(tagNamesList.getSelectedValue().getDisplayName());
deleteTagNameButton.setEnabled(enableDelete); deleteTagNameButton.setEnabled(enableDelete);
if (isSelected) { if (isSelected) {

View File

@ -27,7 +27,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
@ -46,41 +45,9 @@ import org.sleuthkit.datamodel.TskData;
public class TagsManager implements Closeable { public class TagsManager implements Closeable {
private static final Logger LOGGER = Logger.getLogger(TagsManager.class.getName()); private static final Logger LOGGER = Logger.getLogger(TagsManager.class.getName());
@NbBundle.Messages({"TagsManager.predefTagNames.bookmark.text=Bookmark",
"TagsManager.predefTagNames.followUp.text=Follow Up",
"TagsManager.predefTagNames.notableItem.text=Notable Item"})
private static final String FOLLOW_UP = Bundle.TagsManager_predefTagNames_followUp_text();
private static final String BOOKMARK = Bundle.TagsManager_predefTagNames_bookmark_text();
private static final String NOTABLE_ITEM = Bundle.TagsManager_predefTagNames_notableItem_text();
private final SleuthkitCase caseDb; private final SleuthkitCase caseDb;
/**
* Get the text for the Follow Up tag.
*
* @return FOLLOW_UP
*/
public static String getFollowUpText() {
return FOLLOW_UP;
}
/**
* Get the text for the Bookmark tag.
*
* @return BOOKMARK
*/
public static String getBookmarkText() {
return BOOKMARK;
}
/**
* Get the text for the Notable Item tag.
*
* @return NOTABLE_ITEM
*/
static String getNotableItemText() {
return NOTABLE_ITEM;
}
/** /**
* Tests whether or not a given tag display name contains an illegal * Tests whether or not a given tag display name contains an illegal
* character. * character.

View File

@ -138,7 +138,7 @@ public class DrawableTagsManager {
public TagName getFollowUpTagName() throws TskCoreException { public TagName getFollowUpTagName() throws TskCoreException {
synchronized (autopsyTagsManagerLock) { synchronized (autopsyTagsManagerLock) {
if (Objects.isNull(followUpTagName)) { if (Objects.isNull(followUpTagName)) {
followUpTagName = getTagName(TagsManager.getFollowUpText()); followUpTagName = getTagName(NbBundle.getMessage(DrawableTagsManager.class, "DrawableTagsManager.followUp"));
} }
return followUpTagName; return followUpTagName;
} }
@ -147,7 +147,7 @@ public class DrawableTagsManager {
private Object getBookmarkTagName() throws TskCoreException { private Object getBookmarkTagName() throws TskCoreException {
synchronized (autopsyTagsManagerLock) { synchronized (autopsyTagsManagerLock) {
if (Objects.isNull(bookmarkTagName)) { if (Objects.isNull(bookmarkTagName)) {
bookmarkTagName = getTagName(TagsManager.getBookmarkText()); bookmarkTagName = getTagName(NbBundle.getMessage(DrawableTagsManager.class, "DrawableTagsManager.bookMark"));
} }
return bookmarkTagName; return bookmarkTagName;
} }