Autopsy  4.10.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 final ExplorerManager explorerManager;
48  private final OutlineView outlineView;
49  private final Outline outline;
50 
62  public MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer) {
63  this.explorerManager = explorerManager;
64  this.customizer = customizer;
65  initComponents();
66  outlineView = new org.openide.explorer.view.OutlineView();
67  outline = this.outlineView.getOutline();
68  configureOutlineView();
69  caseTableScrollPane.add(outlineView);
70  caseTableScrollPane.setViewportView(outlineView);
71  this.setVisible(true);
72  }
73 
74  @Override
75  public ExplorerManager getExplorerManager() {
76  return explorerManager;
77  }
78 
82  private void configureOutlineView() {
83  /*
84  * Set up the outline view columns and sorting.
85  */
86  Map<Column, SortColumn> sortColumns = new HashMap<>();
87  for (SortColumn sortColumn : customizer.getSortColumns()) {
88  sortColumns.put(sortColumn.column(), sortColumn);
89  }
90  ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Column.DISPLAY_NAME.getDisplayName());
91  if (sortColumns.containsKey(Column.DISPLAY_NAME)) {
92  SortColumn sortColumn = sortColumns.get(Column.DISPLAY_NAME);
93  outline.setColumnSorted(0, sortColumn.sortAscending(), sortColumn.sortRank());
94  }
95  List<Column> sheetProperties = customizer.getColumns();
96  for (int index = 0; index < sheetProperties.size(); ++index) {
97  Column property = sheetProperties.get(index);
98  String propertyName = property.getDisplayName();
99  outlineView.addPropertyColumn(propertyName, propertyName, propertyName);
100  if (sortColumns.containsKey(property)) {
101  SortColumn sortColumn = sortColumns.get(property);
102  outline.setColumnSorted(index + 1, sortColumn.sortAscending(), sortColumn.sortRank());
103  }
104  }
105 
106  /*
107  * Hide the root node and configure the node selection mode.
108  */
109  outline.setRootVisible(false);
110  outline.setSelectionMode(customizer.allowMultiSelect() ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION);
111  }
112 
118  public void addListSelectionListener(ListSelectionListener listener) {
119  outline.getSelectionModel().addListSelectionListener(listener);
120  }
121 
126  @NbBundle.Messages({
127  "MultiUserCasesBrowserPanel.waitNode.message=Please Wait..."
128  })
129  public void displayCases() {
130  explorerManager.setRootContext(new MultiUserCasesRootNode(customizer));
131  }
132 
138  @SuppressWarnings("unchecked")
139  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
140  private void initComponents() {
141 
142  caseTableScrollPane = new javax.swing.JScrollPane();
143 
144  setMinimumSize(new java.awt.Dimension(0, 5));
145  setPreferredSize(new java.awt.Dimension(5, 5));
146  setLayout(new java.awt.BorderLayout());
147 
148  caseTableScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
149  caseTableScrollPane.setMinimumSize(new java.awt.Dimension(0, 5));
150  caseTableScrollPane.setOpaque(false);
151  caseTableScrollPane.setPreferredSize(new java.awt.Dimension(500, 500));
152  add(caseTableScrollPane, java.awt.BorderLayout.CENTER);
153  }// </editor-fold>//GEN-END:initComponents
154  // Variables declaration - do not modify//GEN-BEGIN:variables
155  private javax.swing.JScrollPane caseTableScrollPane;
156  // End of variables declaration//GEN-END:variables
157 
158 }
MultiUserCasesBrowserPanel(ExplorerManager explorerManager, MultiUserCaseBrowserCustomizer customizer)

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.