Autopsy  4.14.0
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-2019 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.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24 import javax.swing.ListSelectionModel;
25 import javax.swing.event.ListSelectionListener;
26 import org.netbeans.swing.outline.DefaultOutlineModel;
27 import org.netbeans.swing.outline.Outline;
28 import org.openide.explorer.ExplorerManager;
29 import org.openide.util.NbBundle;
30 import org.openide.explorer.view.OutlineView;
33 
42 @SuppressWarnings("PMD.SingularField") // Matisse-generated UI widgets cause lots of false positives for this in PMD
43 public final class MultiUserCasesBrowserPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
44 
45  private static final long serialVersionUID = 1L;
46  private static final int NAME_COLUMN_INDEX = 0;
47  private static final int NAME_COLUMN_WIDTH = 150;
48  private final ExplorerManager explorerManager;
50  private final OutlineView outlineView;
51  private final Outline outline;
52 
64  public MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer) {
65  this.explorerManager = explorerManager;
66  this.customizer = customizer;
67  initComponents();
68  outlineView = new org.openide.explorer.view.OutlineView();
69  outline = this.outlineView.getOutline();
70  configureOutlineView();
71  caseTableScrollPane.add(outlineView);
72  caseTableScrollPane.setViewportView(outlineView);
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  caseTableScrollPane = new javax.swing.JScrollPane();
150 
151  setMinimumSize(new java.awt.Dimension(0, 5));
152  setPreferredSize(new java.awt.Dimension(5, 5));
153  setLayout(new java.awt.BorderLayout());
154 
155  caseTableScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
156  caseTableScrollPane.setMinimumSize(new java.awt.Dimension(0, 5));
157  caseTableScrollPane.setOpaque(false);
158  caseTableScrollPane.setPreferredSize(new java.awt.Dimension(500, 500));
159  add(caseTableScrollPane, java.awt.BorderLayout.CENTER);
160  }// </editor-fold>//GEN-END:initComponents
161  // Variables declaration - do not modify//GEN-BEGIN:variables
162  private javax.swing.JScrollPane caseTableScrollPane;
163  // End of variables declaration//GEN-END:variables
164 
165 }
MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.