Merge pull request #478 from SynapticNulship/drp_mods1

DataResultPanel changes and make DataResultViewerTable class public.
This commit is contained in:
Richard Cordovano 2014-02-12 16:23:26 -05:00
commit 271b7688ca
2 changed files with 38 additions and 18 deletions

View File

@ -110,7 +110,6 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
*/ */
DataResultPanel(String title, DataContent customContentViewer) { DataResultPanel(String title, DataContent customContentViewer) {
this(false, title); this(false, title);
setName(title); setName(title);
//custom content viewer tc to setup for every result viewer //custom content viewer tc to setup for every result viewer
@ -152,6 +151,26 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
return newDataResult; return newDataResult;
} }
/**
* Factory method to create, customize and open a new custom data result panel.
* Does NOT call open(). Client must manually initialize by calling open().
*
* @param title Title of the component window
* @param pathText Descriptive text about the source of the nodes displayed
* @param givenNode The new root node
* @param totalMatches Cardinality of root node's children
* @param dataContent a handle to data content to send selection events to
* @return a new DataResultPanel instance representing a custom data result viewer
*/
public static DataResultPanel createInstanceUninitialized(String title, String pathText, Node givenNode, int totalMatches, DataContent dataContent) {
DataResultPanel newDataResult = new DataResultPanel(title, dataContent);
createInstanceCommon(pathText, givenNode, totalMatches, newDataResult);
return newDataResult;
}
/** /**
* Common code for factory helper methods * Common code for factory helper methods
* @param pathText * @param pathText
@ -253,27 +272,28 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
// If a custom DataContent object has not been specified, get the default instance. // If a custom DataContent object has not been specified, get the default instance.
DataContent contentViewer = customContentViewer; DataContent contentViewer = customContentViewer;
if (null == contentViewer) { if (contentViewer == null) {
contentViewer = Lookup.getDefault().lookup(DataContent.class); contentViewer = Lookup.getDefault().lookup(DataContent.class);
} }
try { try {
Node[] selectedNodes = explorerManager.getSelectedNodes(); if (contentViewer != null) {
for (UpdateWrapper drv : viewers) { Node[] selectedNodes = explorerManager.getSelectedNodes();
drv.setSelectedNodes(selectedNodes); for (UpdateWrapper drv : viewers) {
} drv.setSelectedNodes(selectedNodes);
}
// Passing null signals that either multiple nodes are selected, or no nodes are selected. // Passing null signals that either multiple nodes are selected, or no nodes are selected.
// This is important to the DataContent object, since the content mode (area) of the app is designed // This is important to the DataContent object, since the content mode (area) of the app is designed
// to show only the content underlying a single Node. // to show only the content underlying a single Node.
if (selectedNodes.length == 1) { if (selectedNodes.length == 1) {
contentViewer.setNode(selectedNodes[0]); contentViewer.setNode(selectedNodes[0]);
}
else {
contentViewer.setNode(null);
}
} }
else { } finally {
contentViewer.setNode(null);
}
}
finally {
setCursor(null); setCursor(null);
} }
} }

View File

@ -55,7 +55,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
// service provider when DataResultViewers can be made compatible with node // service provider when DataResultViewers can be made compatible with node
// multiple selection actions. // multiple selection actions.
//@ServiceProvider(service = DataResultViewer.class) //@ServiceProvider(service = DataResultViewer.class)
class DataResultViewerTable extends AbstractDataResultViewer { public class DataResultViewerTable extends AbstractDataResultViewer {
private String firstColumnLabel = "Name"; private String firstColumnLabel = "Name";
private Set<Property> propertiesAcc = new LinkedHashSet<>(); private Set<Property> propertiesAcc = new LinkedHashSet<>();