Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AutopsyOptionsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2014 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.corecomponents;
20 
21 import java.text.NumberFormat;
22 import javax.swing.DefaultComboBoxModel;
23 import javax.swing.JFormattedTextField;
24 import org.openide.util.NbBundle;
26 
30 final class AutopsyOptionsPanel extends javax.swing.JPanel {
31 
32  AutopsyOptionsPanel(AutopsyOptionsPanelController controller) {
33  initComponents();
34  int availableProcessors = Runtime.getRuntime().availableProcessors();
35  Integer fileIngestThreadCountChoices[];
36  int recommendedFileIngestThreadCount;
37  if (availableProcessors >= 16) {
38  fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8, 12, 16};
39  if (availableProcessors >= 18) {
40  recommendedFileIngestThreadCount = 16;
41  } else {
42  recommendedFileIngestThreadCount = 12;
43  }
44  } else if (availableProcessors >= 12 && availableProcessors <= 15) {
45  fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8, 12};
46  if (availableProcessors >= 14) {
47  recommendedFileIngestThreadCount = 12;
48  } else {
49  recommendedFileIngestThreadCount = 8;
50  }
51  } else if (availableProcessors >= 8 && availableProcessors <= 11) {
52  fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8};
53  if (availableProcessors >= 10) {
54  recommendedFileIngestThreadCount = 8;
55  } else {
56  recommendedFileIngestThreadCount = 6;
57  }
58  } else if (availableProcessors >= 6 && availableProcessors <= 7) {
59  fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6};
60  recommendedFileIngestThreadCount = 4;
61  } else if (availableProcessors >= 4 && availableProcessors <= 5) {
62  fileIngestThreadCountChoices = new Integer[]{1, 2, 4};
63  recommendedFileIngestThreadCount = 2;
64  } else if (availableProcessors >= 2 && availableProcessors <= 3) {
65  fileIngestThreadCountChoices = new Integer[]{1, 2};
66  recommendedFileIngestThreadCount = 1;
67  } else {
68  fileIngestThreadCountChoices = new Integer[]{1};
69  recommendedFileIngestThreadCount = 1;
70  }
71  numberOfFileIngestThreadsComboBox.setModel(new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
72  restartRequiredLabel.setText(NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
73  // TODO listen to changes in form fields and call controller.changed()
74  }
75 
76  void load() {
77  boolean keepPreferredViewer = UserPreferences.keepPreferredContentViewer();
78  keepCurrentViewerRB.setSelected(keepPreferredViewer);
79  useBestViewerRB.setSelected(!keepPreferredViewer);
80  dataSourcesHideKnownCB.setSelected(UserPreferences.hideKnownFilesInDataSourcesTree());
81  viewsHideKnownCB.setSelected(UserPreferences.hideKnownFilesInViewsTree());
82  boolean useLocalTime = UserPreferences.displayTimesInLocalTime();
83  useLocalTimeRB.setSelected(useLocalTime);
84  useGMTTimeRB.setSelected(!useLocalTime);
85  numberOfFileIngestThreadsComboBox.setSelectedItem(UserPreferences.numberOfFileIngestThreads());
86  if (UserPreferences.getIsTimeOutEnabled()) {
87  // user specified time out
88  jCheckBoxEnableProcTimeout.setSelected(true);
89  jFormattedTextFieldProcTimeOutHrs.setEditable(true);
90  int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
91  jFormattedTextFieldProcTimeOutHrs.setValue((long) timeOutHrs);
92  } else {
93  // never time out
94  jCheckBoxEnableProcTimeout.setSelected(false);
95  jFormattedTextFieldProcTimeOutHrs.setEditable(false);
96  int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
97  jFormattedTextFieldProcTimeOutHrs.setValue((long) timeOutHrs);
98  }
99  }
100 
101  void store() {
102  UserPreferences.setKeepPreferredContentViewer(keepCurrentViewerRB.isSelected());
103  UserPreferences.setHideKnownFilesInDataSourcesTree(dataSourcesHideKnownCB.isSelected());
104  UserPreferences.setHideKnownFilesInViewsTree(viewsHideKnownCB.isSelected());
105  UserPreferences.setDisplayTimesInLocalTime(useLocalTimeRB.isSelected());
106  UserPreferences.setNumberOfFileIngestThreads((Integer) numberOfFileIngestThreadsComboBox.getSelectedItem());
107 
108  UserPreferences.setIsTimeOutEnabled(jCheckBoxEnableProcTimeout.isSelected());
109  if (jCheckBoxEnableProcTimeout.isSelected()) {
110  // only store time out if it is enabled
111  long timeOutHrs = (long) jFormattedTextFieldProcTimeOutHrs.getValue();
112  UserPreferences.setProcessTimeOutHrs((int) timeOutHrs);
113  }
114  }
115 
116  boolean valid() {
117  return true;
118  }
119 
125  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
126  private void initComponents() {
127 
128  buttonGroup1 = new javax.swing.ButtonGroup();
129  buttonGroup3 = new javax.swing.ButtonGroup();
130  useBestViewerRB = new javax.swing.JRadioButton();
131  keepCurrentViewerRB = new javax.swing.JRadioButton();
132  jLabelSelectFile = new javax.swing.JLabel();
133  jLabelTimeDisplay = new javax.swing.JLabel();
134  useLocalTimeRB = new javax.swing.JRadioButton();
135  useGMTTimeRB = new javax.swing.JRadioButton();
136  jLabelHideKnownFiles = new javax.swing.JLabel();
137  dataSourcesHideKnownCB = new javax.swing.JCheckBox();
138  viewsHideKnownCB = new javax.swing.JCheckBox();
139  jLabelNumThreads = new javax.swing.JLabel();
140  numberOfFileIngestThreadsComboBox = new javax.swing.JComboBox<Integer>();
141  restartRequiredLabel = new javax.swing.JLabel();
142  jLabelSetProcessTimeOut = new javax.swing.JLabel();
143  jCheckBoxEnableProcTimeout = new javax.swing.JCheckBox();
144  jLabelProcessTimeOutUnits = new javax.swing.JLabel();
145  jFormattedTextFieldProcTimeOutHrs = new JFormattedTextField(NumberFormat.getIntegerInstance());
146 
147  buttonGroup1.add(useBestViewerRB);
148  useBestViewerRB.setSelected(true);
149  org.openide.awt.Mnemonics.setLocalizedText(useBestViewerRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useBestViewerRB.text")); // NOI18N
150  useBestViewerRB.setToolTipText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useBestViewerRB.toolTipText")); // NOI18N
151 
152  buttonGroup1.add(keepCurrentViewerRB);
153  org.openide.awt.Mnemonics.setLocalizedText(keepCurrentViewerRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.keepCurrentViewerRB.text")); // NOI18N
154  keepCurrentViewerRB.setToolTipText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.keepCurrentViewerRB.toolTipText")); // NOI18N
155 
156  org.openide.awt.Mnemonics.setLocalizedText(jLabelSelectFile, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelSelectFile.text")); // NOI18N
157 
158  org.openide.awt.Mnemonics.setLocalizedText(jLabelTimeDisplay, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelTimeDisplay.text")); // NOI18N
159 
160  buttonGroup3.add(useLocalTimeRB);
161  useLocalTimeRB.setSelected(true);
162  org.openide.awt.Mnemonics.setLocalizedText(useLocalTimeRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useLocalTimeRB.text")); // NOI18N
163 
164  buttonGroup3.add(useGMTTimeRB);
165  org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.useGMTTimeRB.text")); // NOI18N
166 
167  org.openide.awt.Mnemonics.setLocalizedText(jLabelHideKnownFiles, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelHideKnownFiles.text")); // NOI18N
168 
169  org.openide.awt.Mnemonics.setLocalizedText(dataSourcesHideKnownCB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.dataSourcesHideKnownCB.text")); // NOI18N
170 
171  org.openide.awt.Mnemonics.setLocalizedText(viewsHideKnownCB, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.viewsHideKnownCB.text")); // NOI18N
172 
173  org.openide.awt.Mnemonics.setLocalizedText(jLabelNumThreads, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelNumThreads.text")); // NOI18N
174 
175  restartRequiredLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/warning16.png"))); // NOI18N
176  org.openide.awt.Mnemonics.setLocalizedText(restartRequiredLabel, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.restartRequiredLabel.text")); // NOI18N
177 
178  org.openide.awt.Mnemonics.setLocalizedText(jLabelSetProcessTimeOut, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelSetProcessTimeOut.text")); // NOI18N
179 
180  org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxEnableProcTimeout, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jCheckBoxEnableProcTimeout.text")); // NOI18N
181  jCheckBoxEnableProcTimeout.addActionListener(new java.awt.event.ActionListener() {
182  public void actionPerformed(java.awt.event.ActionEvent evt) {
183  jCheckBoxEnableProcTimeoutActionPerformed(evt);
184  }
185  });
186 
187  org.openide.awt.Mnemonics.setLocalizedText(jLabelProcessTimeOutUnits, org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jLabelProcessTimeOutUnits.text")); // NOI18N
188 
189  jFormattedTextFieldProcTimeOutHrs.setText(org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.jFormattedTextFieldProcTimeOutHrs.text")); // NOI18N
190 
191  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
192  this.setLayout(layout);
193  layout.setHorizontalGroup(
194  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
195  .addGroup(layout.createSequentialGroup()
196  .addContainerGap()
197  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198  .addGroup(layout.createSequentialGroup()
199  .addGap(10, 10, 10)
200  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
201  .addComponent(keepCurrentViewerRB)
202  .addComponent(useBestViewerRB)
203  .addComponent(dataSourcesHideKnownCB)
204  .addComponent(viewsHideKnownCB)
205  .addGroup(layout.createSequentialGroup()
206  .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
207  .addGap(18, 18, 18)
208  .addComponent(restartRequiredLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
209  .addContainerGap())))
210  .addGroup(layout.createSequentialGroup()
211  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212  .addComponent(jLabelHideKnownFiles)
213  .addComponent(jLabelTimeDisplay)
214  .addGroup(layout.createSequentialGroup()
215  .addGap(10, 10, 10)
216  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
217  .addComponent(useLocalTimeRB)
218  .addComponent(useGMTTimeRB)))
219  .addComponent(jLabelSelectFile)
220  .addComponent(jLabelNumThreads))
221  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
222  .addGroup(layout.createSequentialGroup()
223  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224  .addGroup(layout.createSequentialGroup()
225  .addGap(10, 10, 10)
226  .addComponent(jCheckBoxEnableProcTimeout)
227  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228  .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
229  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
230  .addComponent(jLabelProcessTimeOutUnits))
231  .addComponent(jLabelSetProcessTimeOut))
232  .addGap(0, 0, Short.MAX_VALUE))))
233  );
234  layout.setVerticalGroup(
235  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236  .addGroup(layout.createSequentialGroup()
237  .addComponent(jLabelSelectFile)
238  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
239  .addComponent(useBestViewerRB)
240  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
241  .addComponent(keepCurrentViewerRB)
242  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
243  .addComponent(jLabelHideKnownFiles)
244  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245  .addComponent(dataSourcesHideKnownCB)
246  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
247  .addComponent(viewsHideKnownCB)
248  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
249  .addComponent(jLabelTimeDisplay)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251  .addComponent(useLocalTimeRB)
252  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253  .addComponent(useGMTTimeRB)
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
255  .addComponent(jLabelNumThreads)
256  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
258  .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
259  .addComponent(restartRequiredLabel))
260  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
261  .addComponent(jLabelSetProcessTimeOut)
262  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
263  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
264  .addComponent(jCheckBoxEnableProcTimeout)
265  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
266  .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
267  .addComponent(jLabelProcessTimeOutUnits)))
268  .addContainerGap(103, Short.MAX_VALUE))
269  );
270  }// </editor-fold>//GEN-END:initComponents
271 
272  private void jCheckBoxEnableProcTimeoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxEnableProcTimeoutActionPerformed
273  jFormattedTextFieldProcTimeOutHrs.setEditable(jCheckBoxEnableProcTimeout.isSelected());
274  }//GEN-LAST:event_jCheckBoxEnableProcTimeoutActionPerformed
275 
276  // Variables declaration - do not modify//GEN-BEGIN:variables
277  private javax.swing.ButtonGroup buttonGroup1;
278  private javax.swing.ButtonGroup buttonGroup3;
279  private javax.swing.JCheckBox dataSourcesHideKnownCB;
280  private javax.swing.JCheckBox jCheckBoxEnableProcTimeout;
281  private javax.swing.JFormattedTextField jFormattedTextFieldProcTimeOutHrs;
282  private javax.swing.JLabel jLabelHideKnownFiles;
283  private javax.swing.JLabel jLabelNumThreads;
284  private javax.swing.JLabel jLabelProcessTimeOutUnits;
285  private javax.swing.JLabel jLabelSelectFile;
286  private javax.swing.JLabel jLabelSetProcessTimeOut;
287  private javax.swing.JLabel jLabelTimeDisplay;
288  private javax.swing.JRadioButton keepCurrentViewerRB;
289  private javax.swing.JComboBox<Integer> numberOfFileIngestThreadsComboBox;
290  private javax.swing.JLabel restartRequiredLabel;
291  private javax.swing.JRadioButton useBestViewerRB;
292  private javax.swing.JRadioButton useGMTTimeRB;
293  private javax.swing.JRadioButton useLocalTimeRB;
294  private javax.swing.JCheckBox viewsHideKnownCB;
295  // End of variables declaration//GEN-END:variables
296 }

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