mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Rows initially colored, does not update upon tag addition or reordering
This commit is contained in:
parent
b8d43eefc6
commit
a60dd92384
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.corecomponents;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.FontMetrics;
|
||||
@ -41,6 +42,7 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.TableColumnModelEvent;
|
||||
import javax.swing.event.TableColumnModelListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import org.netbeans.swing.outline.DefaultOutlineModel;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
@ -55,6 +57,7 @@ import org.openide.nodes.NodeListener;
|
||||
import org.openide.nodes.NodeMemberEvent;
|
||||
import org.openide.nodes.NodeReorderEvent;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbPreferences;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
|
||||
@ -413,7 +416,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
|
||||
|
||||
for (int column = 0; column < ov.getOutline().getModel().getColumnCount(); column++) {
|
||||
int firstColumnPadding = (column == 0) ? 32 : 0;
|
||||
int columnWidthLimit = (column == 0) ? 250 : 350;
|
||||
int columnWidthLimit = (column == 0) ? 250 : 300;
|
||||
int valuesWidth = 0;
|
||||
|
||||
// find the maximum width needed to fit the values for the first 30 rows, at most
|
||||
@ -439,6 +442,41 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
|
||||
ov.getOutline().setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
||||
}
|
||||
}
|
||||
// Node[] childrenNodes = currentRoot.getChildren().getNodes();
|
||||
final TableCellRenderer DEFAULT_RENDERER = ov.getOutline().getDefaultRenderer(Object.class);
|
||||
final Color TAGGED_COLOR = new Color(230, 235, 240);
|
||||
final Color SELECTED_COLOR = new Color(51, 153, 255);
|
||||
|
||||
|
||||
class CustomRenderer extends DefaultTableCellRenderer {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row, int col) {
|
||||
Component component = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
|
||||
if (col != 0) {
|
||||
try {
|
||||
int tag_col = ov.getOutline().getColumnModel().getColumnIndex("Tags");
|
||||
Property cellProp = (Property)(table.getModel().getValueAt(row, tag_col));
|
||||
if (cellProp != null) {
|
||||
String valueString = cellProp.getValue().toString();//((Property) value).getValue().toString();
|
||||
if (!valueString.equals("")) {
|
||||
component.setBackground(TAGGED_COLOR);
|
||||
if (isSelected) {
|
||||
component.setBackground(SELECTED_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
ov.getOutline().setDefaultRenderer(Object.class, new CustomRenderer());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,13 @@ package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
import org.openide.nodes.Children;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -31,6 +34,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -278,6 +282,18 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
map.put(AbstractFilePropertyType.MIMETYPE.toString(), content.getMIMEType() == null ? "" : content.getMIMEType());
|
||||
}
|
||||
|
||||
static void addTagProperty(Sheet.Set ss, Content content) {
|
||||
final String NO_DESCR = NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.desc");
|
||||
try {
|
||||
List<ContentTag> tags = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(content);
|
||||
ss.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.tags.name"),
|
||||
NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.tags.displayName"),
|
||||
NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", "))));
|
||||
} catch (TskCoreException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to get tags for content " + content.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
static String getContentDisplayName(AbstractFile file) {
|
||||
String name = file.getName();
|
||||
switch (name) {
|
||||
|
@ -84,6 +84,9 @@ public abstract class AbstractFsContentNode<T extends AbstractFile> extends Abst
|
||||
ss.put(new NodeProperty<>(HIDE_PARENT, HIDE_PARENT, HIDE_PARENT, HIDE_PARENT));
|
||||
}
|
||||
|
||||
// add tags property to the sheet
|
||||
AbstractAbstractFileNode.addTagProperty(ss, content);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.Action;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Children;
|
||||
@ -40,9 +41,12 @@ import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifactTag;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.Tag;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -209,6 +213,20 @@ public class BlackboardArtifactNode extends DisplayableItemNode {
|
||||
ss.put(np);
|
||||
}
|
||||
}
|
||||
|
||||
// add properties for tags
|
||||
try {
|
||||
List<BlackboardArtifactTag> artifactTags = Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact);
|
||||
List<ContentTag> contentTags = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(associated);
|
||||
List<Tag> tags = new ArrayList<>(artifactTags);
|
||||
tags.addAll(contentTags);
|
||||
ss.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "BlackboardArtifactNode.createSheet.tags.name"),
|
||||
NbBundle.getMessage(AbstractAbstractFileNode.class, "BlackboardArtifactNode.createSheet.tags.displayName"),
|
||||
NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", "))));
|
||||
} catch (TskCoreException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to get tags for artifact " + artifact.getDisplayName(), ex);
|
||||
}
|
||||
|
||||
final int artifactTypeId = artifact.getArtifactTypeID();
|
||||
|
||||
// If mismatch, add props for extension and file type
|
||||
|
@ -281,3 +281,8 @@ DeleteReportAction.actionDisplayName.multipleReports=Delete Reports
|
||||
DeleteReportAction.actionPerformed.showConfirmDialog.title=Confirm Deletion
|
||||
DeleteReportAction.actionPerformed.showConfirmDialog.single.msg=Do you want to delete 1 report from the case?
|
||||
DeleteReportAction.actionPerformed.showConfirmDialog.multiple.msg=Do you want to delete {0} reports from the case?
|
||||
AbstractAbstractFileNode.addFileProperty.desc=no description
|
||||
AbstractAbstractFileNode.addFileProperty.tags.name=Tags
|
||||
AbstractAbstractFileNode.addFileProperty.tags.displayName=Tags
|
||||
BlackboardArtifactNode.createSheet.tags.name=Tags
|
||||
BlackboardArtifactNode.createSheet.tags.displayName=Tags
|
@ -86,6 +86,9 @@ public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
|
||||
ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
|
||||
}
|
||||
|
||||
// add tags property to the sheet
|
||||
AbstractAbstractFileNode.addTagProperty(ss, content);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,9 @@ public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
ss.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
|
||||
}
|
||||
// @@@ add more properties here...
|
||||
|
||||
// add tags property to the sheet
|
||||
AbstractAbstractFileNode.addTagProperty(ss, content);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user