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 @SuppressWarnings(
"PMD.SingularField")
52 public final class
AccountsBrowser extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
54 private static final long serialVersionUID = 1L;
59 private final ExplorerManager messageBrowserEM =
new ExplorerManager();
60 private final ExplorerManager accountsTableEM =
new ExplorerManager();
70 outline = outlineView.getOutline();
71 outlineView.setPropertyColumns(
72 "device", Bundle.AccountNode_device(),
73 "type", Bundle.AccountNode_accountType(),
74 "count", Bundle.AccountNode_messageCount()
77 outline.setRootVisible(
false);
78 ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.AccountNode_accountName());
79 outline.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
80 outline.setColumnSorted(3,
false, 1);
82 accountsTableEM.addPropertyChangeListener(evt -> {
83 if (ExplorerManager.PROP_ROOT_CONTEXT.equals(evt.getPropertyName())) {
84 SwingUtilities.invokeLater(this::setColumnWidths);
85 }
else if (ExplorerManager.PROP_EXPLORED_CONTEXT.equals(evt.getPropertyName())) {
86 SwingUtilities.invokeLater(this::setColumnWidths);
91 jSplitPane1.setRightComponent(messageBrowser);
93 proxyLookup =
new ProxyLookup(
95 ExplorerUtils.createLookup(accountsTableEM, getActionMap()));
102 final int rows = Math.min(100, outline.getRowCount());
104 for (
int column = 0; column < outline.getModel().getColumnCount(); column++) {
105 int columnWidthLimit = 500;
109 for (
int row = 0; row < rows; row++) {
110 TableCellRenderer renderer = outline.getCellRenderer(row, column);
111 Component comp = outline.prepareRenderer(renderer, row, column);
112 columnWidth = Math.max(comp.getPreferredSize().width, columnWidth);
115 columnWidth += 2 * margin + padding;
116 columnWidth = Math.min(columnWidth, columnWidthLimit);
118 outline.getColumnModel().getColumn(column).setPreferredWidth(columnWidth);
126 accountsTableEM.setRootContext(
new AbstractNode(Children.create(
new AccountDeviceInstanceNodeFactory(commsManager, filterChangeEvent.getNewFilter()),
true)));
127 }
catch (TskCoreException ex) {
128 logger.log(Level.SEVERE,
"There was an error getting the CommunicationsManager for the current case.", ex);
139 @SuppressWarnings(
"unchecked")
141 private
void initComponents() {
143 jSplitPane1 =
new javax.swing.JSplitPane();
144 outlineView =
new org.openide.explorer.view.OutlineView();
146 setLayout(
new java.awt.BorderLayout());
148 jSplitPane1.setDividerLocation(500);
149 jSplitPane1.setLeftComponent(outlineView);
151 add(jSplitPane1, java.awt.BorderLayout.CENTER);
162 return accountsTableEM;
ExplorerManager getExplorerManager()
org.openide.explorer.view.OutlineView outlineView
javax.swing.JSplitPane jSplitPane1
SleuthkitCase getSleuthkitCase()
synchronized static Logger getLogger(String name)
void handleFilterEvent(CVTEvents.FilterChangeEvent filterChangeEvent)
static Case getCurrentCaseThrows()
final ProxyLookup proxyLookup