Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
MultiUserCasesBrowserPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.casemodule.multiusercasesbrowser;
20 
21 import java.awt.BorderLayout;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javax.swing.ListSelectionModel;
26 import javax.swing.event.ListSelectionListener;
27 import org.netbeans.swing.outline.DefaultOutlineModel;
28 import org.netbeans.swing.outline.Outline;
29 import org.openide.explorer.ExplorerManager;
30 import org.openide.util.NbBundle;
31 import org.openide.explorer.view.OutlineView;
34 
43 @SuppressWarnings("PMD.SingularField") // Matisse-generated UI widgets cause lots of false positives for this in PMD
44 public final class MultiUserCasesBrowserPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
45 
46  private static final long serialVersionUID = 1L;
47  private static final int NAME_COLUMN_INDEX = 0;
48  private static final int NAME_COLUMN_WIDTH = 150;
49  private final ExplorerManager explorerManager;
51  private final OutlineView outlineView;
52  private final Outline outline;
53 
65  public MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer) {
66  this.explorerManager = explorerManager;
67  this.customizer = customizer;
68  initComponents();
69  outlineView = new org.openide.explorer.view.OutlineView();
70  outline = this.outlineView.getOutline();
71  configureOutlineView();
72  add(outlineView, BorderLayout.CENTER);
73  this.setVisible(true);
74  }
75 
76  @Override
77  public ExplorerManager getExplorerManager() {
78  return explorerManager;
79  }
80 
84  private void configureOutlineView() {
85  /*
86  * Set up the outline view columns and sorting.
87  */
88  Map<Column, SortColumn> sortColumns = new HashMap<>();
89  for (SortColumn sortColumn : customizer.getSortColumns()) {
90  sortColumns.put(sortColumn.column(), sortColumn);
91  }
92  ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Column.DISPLAY_NAME.getDisplayName());
93  if (sortColumns.containsKey(Column.DISPLAY_NAME)) {
94  SortColumn sortColumn = sortColumns.get(Column.DISPLAY_NAME);
95  outline.setColumnSorted(0, sortColumn.sortAscending(), sortColumn.sortRank());
96  }
97  List<Column> sheetProperties = customizer.getColumns();
98  for (int index = 0; index < sheetProperties.size(); ++index) {
99  Column property = sheetProperties.get(index);
100  String propertyName = property.getDisplayName();
101  outlineView.addPropertyColumn(propertyName, propertyName, propertyName);
102  if (sortColumns.containsKey(property)) {
103  SortColumn sortColumn = sortColumns.get(property);
104  outline.setColumnSorted(index + 1, sortColumn.sortAscending(), sortColumn.sortRank());
105  }
106  }
107 
108  /*
109  * Give the case name column a greater width.
110  */
111  outline.getColumnModel().getColumn(NAME_COLUMN_INDEX).setPreferredWidth(NAME_COLUMN_WIDTH);
112 
113  /*
114  * Hide the root node and configure the node selection mode.
115  */
116  outline.setRootVisible(false);
117  outline.setSelectionMode(customizer.allowMultiSelect() ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION);
118  }
119 
125  public void addListSelectionListener(ListSelectionListener listener) {
126  outline.getSelectionModel().addListSelectionListener(listener);
127  }
128 
133  @NbBundle.Messages({
134  "MultiUserCasesBrowserPanel.waitNode.message=Please Wait..."
135  })
136  public void displayCases() {
137  explorerManager.setRootContext(new MultiUserCasesRootNode(customizer));
138  }
139 
145  @SuppressWarnings("unchecked")
146  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
147  private void initComponents() {
148 
149  setMinimumSize(new java.awt.Dimension(0, 5));
150  setPreferredSize(new java.awt.Dimension(5, 5));
151  setLayout(new java.awt.BorderLayout());
152  }// </editor-fold>//GEN-END:initComponents
153  // Variables declaration - do not modify//GEN-BEGIN:variables
154  // End of variables declaration//GEN-END:variables
155 
156 }
MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.