Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OutlineViewPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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 obt ain 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.communications.relationships;
20 
21 import java.awt.CardLayout;
22 import javax.swing.JTable;
23 import javax.swing.SwingUtilities;
24 import javax.swing.table.TableColumn;
25 import org.openide.explorer.ExplorerManager;
26 import static org.openide.explorer.ExplorerUtils.createLookup;
27 import org.openide.explorer.view.OutlineView;
28 import org.openide.nodes.Node;;
29 import org.openide.util.Lookup;
30 
38 public class OutlineViewPanel extends javax.swing.JPanel implements ExplorerManager.Provider, Lookup.Provider{
39 
40  private final ExplorerManager tableEm;
41  private final Lookup lookup;
45  public OutlineViewPanel() {
46  tableEm = new ExplorerManager();
47  lookup = createLookup(tableEm, getActionMap());
48 
50  }
51 
52  @Override
53  public ExplorerManager getExplorerManager() {
54  return tableEm;
55  }
56 
57  @Override
58  public Lookup getLookup() {
59  return lookup;
60  }
61 
67  public void hideOutlineView(String message) {
68  SwingUtilities.invokeLater(() -> {
69  CardLayout layout = (CardLayout)this.getLayout();
70  layout.show(this, "messageCard"); //NON-NLS
71  messageLabel.setText(message);
72  });
73  }
74 
78  public void showOutlineView() {
79  SwingUtilities.invokeLater(() -> {
80  CardLayout layout = (CardLayout)this.getLayout();
81  layout.show(this, "outlineCard"); //NON-NLS
82  });
83  }
84 
90  public OutlineView getOutlineView() {
91  return outlineView;
92  }
93 
94  public void setNode(Node node) {
95  tableEm.setRootContext(node);
96  }
97 
98  @Override
99  public void setEnabled(boolean enabled) {
100  super.setEnabled(enabled);
101  outlineView.setEnabled(enabled);
102  }
103 
113  public void setTableColumnsWidth(double... percentages) {
114  JTable table = outlineView.getOutline();
115  double total = 0;
116  for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
117  total += percentages[i];
118  }
119 
120  for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
121  TableColumn column = table.getColumnModel().getColumn(i);
122  column.setPreferredWidth((int) (table.getPreferredSize().width * (percentages[i] / total)));
123  }
124  }
125 
131  @SuppressWarnings("unchecked")
132  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
133  private void initComponents() {
134 
135  outlineView = new org.openide.explorer.view.OutlineView();
136  messagePanel = new javax.swing.JPanel();
137  messageLabel = new javax.swing.JLabel();
138 
139  setLayout(new java.awt.CardLayout(5, 5));
140  add(outlineView, "outlineCard");
141 
142  messagePanel.setLayout(new java.awt.BorderLayout());
143 
144  messageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
145  org.openide.awt.Mnemonics.setLocalizedText(messageLabel, org.openide.util.NbBundle.getMessage(OutlineViewPanel.class, "OutlineViewPanel.messageLabel.text")); // NOI18N
146  messageLabel.setEnabled(false);
147  messagePanel.add(messageLabel, java.awt.BorderLayout.CENTER);
148 
149  add(messagePanel, "messageCard");
150  }// </editor-fold>//GEN-END:initComponents
151 
152 
153  // Variables declaration - do not modify//GEN-BEGIN:variables
154  private javax.swing.JLabel messageLabel;
155  private javax.swing.JPanel messagePanel;
156  private org.openide.explorer.view.OutlineView outlineView;
157  // End of variables declaration//GEN-END:variables
158 
159 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.