mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Got rid of unnecessary methods and code
This commit is contained in:
parent
708e2f641c
commit
1009514a05
@ -38,18 +38,18 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
* model objects.
|
* model objects.
|
||||||
*/
|
*/
|
||||||
abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
||||||
|
|
||||||
private static final String NO_COMMENT = "";
|
private static final String NO_COMMENT = "";
|
||||||
|
|
||||||
AddTagAction(String menuText) {
|
AddTagAction(String menuText) {
|
||||||
super(menuText);
|
super(menuText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JMenuItem getPopupPresenter() {
|
public JMenuItem getPopupPresenter() {
|
||||||
return new TagMenu();
|
return new TagMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses of AddTagAction, should not override actionPerformed, but
|
* Subclasses of AddTagAction, should not override actionPerformed, but
|
||||||
* instead override addTag.
|
* instead override addTag.
|
||||||
@ -60,19 +60,19 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
|||||||
@SuppressWarnings("NoopMethodInAbstractClass")
|
@SuppressWarnings("NoopMethodInAbstractClass")
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template method to allow derived classes to provide a string for a menu
|
* Template method to allow derived classes to provide a string for a menu
|
||||||
* item label.
|
* item label.
|
||||||
*/
|
*/
|
||||||
abstract protected String getActionDisplayName();
|
abstract protected String getActionDisplayName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template method to allow derived classes to add the indicated tag and
|
* Template method to allow derived classes to add the indicated tag and
|
||||||
* comment to one or more SleuthKit data model objects.
|
* comment to one or more SleuthKit data model objects.
|
||||||
*/
|
*/
|
||||||
abstract protected void addTag(TagName tagName, String comment);
|
abstract protected void addTag(TagName tagName, String comment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of this class implement a context menu user interface for
|
* 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
|
* 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
|
// @@@ This user interface has some significant usability issues and needs
|
||||||
// to be reworked.
|
// to be reworked.
|
||||||
private class TagMenu extends JMenu {
|
private class TagMenu extends JMenu {
|
||||||
|
|
||||||
TagMenu() {
|
TagMenu() {
|
||||||
super(getActionDisplayName());
|
super(getActionDisplayName());
|
||||||
|
|
||||||
// Get the current set of tag names.
|
// Get the current set of tag names.
|
||||||
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
|
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
|
||||||
List<TagName> tagNames = null;
|
List<TagName> tagNames = null;
|
||||||
@ -94,11 +94,11 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
|||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
|
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a "Quick Tag" sub-menu.
|
// Create a "Quick Tag" sub-menu.
|
||||||
JMenu quickTagMenu = new JMenu(NbBundle.getMessage(this.getClass(), "AddTagAction.quickTag"));
|
JMenu quickTagMenu = new JMenu(NbBundle.getMessage(this.getClass(), "AddTagAction.quickTag"));
|
||||||
add(quickTagMenu);
|
add(quickTagMenu);
|
||||||
|
|
||||||
// Each tag name in the current set of tags gets its own menu item in
|
// 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
|
// the "Quick Tags" sub-menu. Selecting one of these menu items adds
|
||||||
// a tag with the associated tag name.
|
// a tag with the associated tag name.
|
||||||
@ -115,9 +115,9 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
|||||||
empty.setEnabled(false);
|
empty.setEnabled(false);
|
||||||
quickTagMenu.add(empty);
|
quickTagMenu.add(empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
quickTagMenu.addSeparator();
|
quickTagMenu.addSeparator();
|
||||||
|
|
||||||
// The "Quick Tag" menu also gets an "Choose Tag..." menu item.
|
// The "Quick Tag" menu also gets an "Choose Tag..." menu item.
|
||||||
// Selecting this item initiates a dialog that can be used to create
|
// 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.
|
// 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);
|
quickTagMenu.add(newTagMenuItem);
|
||||||
|
|
||||||
// Create a "Choose Tag and Comment..." menu item. Selecting this item initiates
|
// 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
|
// 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.
|
// optional comment and adds a tag with the resulting name.
|
||||||
@ -142,7 +142,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(tagAndCommentItem);
|
add(tagAndCommentItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,40 +6,26 @@
|
|||||||
package org.sleuthkit.autopsy.actions;
|
package org.sleuthkit.autopsy.actions;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.util.Collection;
|
import java.util.List;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.Utilities;
|
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
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.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 NO_COMMENT = "";
|
||||||
private static final String BOOKMARK = "Bookmark";
|
private static final String BOOKMARK = NbBundle.getMessage(BookmarkFileAction.class, "BookmarkFileAction.bookmark.text");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
TagName tagName = null;
|
List<TagName> tagNames = Case.getCurrentCase().getServices().getTagsManager().getPredefinedTagNames();
|
||||||
try {
|
for (TagName tagName : tagNames) {
|
||||||
tagName = Case.getCurrentCase().getServices().getTagsManager().addTagName(BOOKMARK);
|
if (tagName.getDisplayName().equals(BOOKMARK)) {
|
||||||
} catch (TagsManager.TagNameAlreadyExistsException ex) {
|
AddContentTagAction.getInstance().addTag(tagName, NO_COMMENT);
|
||||||
try {
|
return;
|
||||||
tagName = Case.getCurrentCase().getServices().getTagsManager().getTagName(BOOKMARK);
|
|
||||||
} catch (TagsManager.TagNameDoesNotExistException ex1) {
|
|
||||||
// already confirmed that tag name does exist
|
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
Logger.getLogger(BookmarkFileAction.class.getName()).log(Level.SEVERE, "Error tagging file", ex); //NON-NLS
|
|
||||||
} finally {
|
|
||||||
AddContentTagAction.getInstance().addTag(tagName, NO_COMMENT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ AddTagAction.quickTag=Quick Tag
|
|||||||
AddTagAction.noTags=No tags
|
AddTagAction.noTags=No tags
|
||||||
AddTagAction.newTag=New Tag...
|
AddTagAction.newTag=New Tag...
|
||||||
AddTagAction.tagAndComment=Tag and Comment...
|
AddTagAction.tagAndComment=Tag and Comment...
|
||||||
|
BookmarkFileAction.bookmark.text=Bookmark
|
||||||
DeleteBlackboardArtifactTagAction.deleteTags=Delete Tag(s)
|
DeleteBlackboardArtifactTagAction.deleteTags=Delete Tag(s)
|
||||||
DeleteBlackboardArtifactTagAction.unableToDelTag.msg=Unable to delete tag {0}.
|
DeleteBlackboardArtifactTagAction.unableToDelTag.msg=Unable to delete tag {0}.
|
||||||
DeleteBlackboardArtifactTagAction.tagDelErr=Tag Deletion Error
|
DeleteBlackboardArtifactTagAction.tagDelErr=Tag Deletion Error
|
||||||
|
@ -93,16 +93,6 @@ public class TagsManager implements Closeable {
|
|||||||
lazyLoadExistingTagNames();
|
lazyLoadExistingTagNames();
|
||||||
return caseDb.getTagNamesInUse();
|
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.
|
* 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;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TagNameDoesNotExistException extends Exception {
|
|
||||||
|
|
||||||
public TagNameDoesNotExistException() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user