19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.Component;
23 import java.util.logging.Level;
24 import javax.swing.JPanel;
25 import javax.swing.ListSelectionModel;
26 import javax.swing.SwingUtilities;
27 import javax.swing.table.TableCellRenderer;
28 import org.netbeans.swing.outline.DefaultOutlineModel;
29 import org.netbeans.swing.outline.Outline;
30 import org.openide.explorer.ExplorerManager;
31 import org.openide.explorer.ExplorerUtils;
32 import org.openide.nodes.AbstractNode;
33 import org.openide.nodes.Children;
34 import org.openide.util.Lookup;
35 import org.openide.util.lookup.ProxyLookup;
51 public final class AccountsBrowser extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
71 "device", Bundle.AccountNode_device(),
72 "type", Bundle.AccountNode_accountType(),
73 "count", Bundle.AccountNode_messageCount()
76 outline.setRootVisible(
false);
77 ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.AccountNode_accountName());
78 outline.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
79 outline.setColumnSorted(3,
false, 1);
81 accountsTableEM.addPropertyChangeListener(evt -> {
82 if (ExplorerManager.PROP_ROOT_CONTEXT.equals(evt.getPropertyName())) {
83 SwingUtilities.invokeLater(this::setColumnWidths);
84 }
else if (ExplorerManager.PROP_EXPLORED_CONTEXT.equals(evt.getPropertyName())) {
85 SwingUtilities.invokeLater(this::setColumnWidths);
92 proxyLookup =
new ProxyLookup(
94 ExplorerUtils.createLookup(accountsTableEM, getActionMap()));
101 final int rows = Math.min(100, outline.getRowCount());
103 for (
int column = 0; column < outline.getModel().getColumnCount(); column++) {
104 int columnWidthLimit = 500;
108 for (
int row = 0; row < rows; row++) {
109 TableCellRenderer renderer = outline.getCellRenderer(row, column);
110 Component comp = outline.prepareRenderer(renderer, row, column);
111 columnWidth = Math.max(comp.getPreferredSize().width, columnWidth);
114 columnWidth += 2 * margin + padding;
115 columnWidth = Math.min(columnWidth, columnWidthLimit);
117 outline.getColumnModel().getColumn(column).setPreferredWidth(columnWidth);
125 accountsTableEM.setRootContext(
new AbstractNode(Children.create(
new AccountDeviceInstanceNodeFactory(commsManager, filterChangeEvent.getNewFilter()),
true)));
126 }
catch (TskCoreException ex) {
127 logger.log(Level.SEVERE,
"There was an error getting the CommunicationsManager for the current case.", ex);
138 @SuppressWarnings(
"unchecked")
145 setLayout(
new java.awt.BorderLayout());
ExplorerManager getExplorerManager()
org.openide.explorer.view.OutlineView outlineView
javax.swing.JSplitPane jSplitPane1
final ExplorerManager messageBrowserEM
static Case getOpenCase()
SleuthkitCase getSleuthkitCase()
final ExplorerManager accountsTableEM
static final Logger logger
synchronized static Logger getLogger(String name)
void handleFilterEvent(CVTEvents.FilterChangeEvent filterChangeEvent)
static final long serialVersionUID
final ProxyLookup proxyLookup