19 package org.sleuthkit.autopsy.corecomponents;
21 import java.text.NumberFormat;
22 import javax.swing.DefaultComboBoxModel;
23 import javax.swing.JFormattedTextField;
24 import javax.swing.event.DocumentEvent;
25 import javax.swing.event.DocumentListener;
26 import org.netbeans.spi.options.OptionsPanelController;
27 import org.openide.util.NbBundle;
33 final class AutopsyOptionsPanel
extends javax.swing.JPanel {
35 AutopsyOptionsPanel() {
37 int availableProcessors = Runtime.getRuntime().availableProcessors();
38 Integer fileIngestThreadCountChoices[];
39 int recommendedFileIngestThreadCount;
40 if (availableProcessors >= 16) {
41 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8, 12, 16};
42 if (availableProcessors >= 18) {
43 recommendedFileIngestThreadCount = 16;
45 recommendedFileIngestThreadCount = 12;
47 }
else if (availableProcessors >= 12 && availableProcessors <= 15) {
48 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8, 12};
49 if (availableProcessors >= 14) {
50 recommendedFileIngestThreadCount = 12;
52 recommendedFileIngestThreadCount = 8;
54 }
else if (availableProcessors >= 8 && availableProcessors <= 11) {
55 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8};
56 if (availableProcessors >= 10) {
57 recommendedFileIngestThreadCount = 8;
59 recommendedFileIngestThreadCount = 6;
61 }
else if (availableProcessors >= 6 && availableProcessors <= 7) {
62 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6};
63 recommendedFileIngestThreadCount = 4;
64 }
else if (availableProcessors >= 4 && availableProcessors <= 5) {
65 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4};
66 recommendedFileIngestThreadCount = 2;
67 }
else if (availableProcessors >= 2 && availableProcessors <= 3) {
68 fileIngestThreadCountChoices =
new Integer[]{1, 2};
69 recommendedFileIngestThreadCount = 1;
71 fileIngestThreadCountChoices =
new Integer[]{1};
72 recommendedFileIngestThreadCount = 1;
74 numberOfFileIngestThreadsComboBox.setModel(
new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
75 restartRequiredLabel.setText(NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
77 DocumentListener docListener =
new DocumentListener() {
80 public void insertUpdate(DocumentEvent e) {
81 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
85 public void removeUpdate(DocumentEvent e) {
86 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
90 public void changedUpdate(DocumentEvent e) {
91 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
94 this.jFormattedTextFieldProcTimeOutHrs.getDocument().addDocumentListener(docListener);
99 boolean keepPreferredViewer = UserPreferences.keepPreferredContentViewer();
100 keepCurrentViewerRB.setSelected(keepPreferredViewer);
101 useBestViewerRB.setSelected(!keepPreferredViewer);
102 dataSourcesHideKnownCB.setSelected(UserPreferences.hideKnownFilesInDataSourcesTree());
103 viewsHideKnownCB.setSelected(UserPreferences.hideKnownFilesInViewsTree());
104 boolean useLocalTime = UserPreferences.displayTimesInLocalTime();
105 useLocalTimeRB.setSelected(useLocalTime);
106 useGMTTimeRB.setSelected(!useLocalTime);
107 numberOfFileIngestThreadsComboBox.setSelectedItem(UserPreferences.numberOfFileIngestThreads());
108 if (UserPreferences.getIsTimeOutEnabled()) {
110 jCheckBoxEnableProcTimeout.setSelected(
true);
111 jFormattedTextFieldProcTimeOutHrs.setEditable(
true);
112 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
113 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
116 jCheckBoxEnableProcTimeout.setSelected(
false);
117 jFormattedTextFieldProcTimeOutHrs.setEditable(
false);
118 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
119 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
124 UserPreferences.setKeepPreferredContentViewer(keepCurrentViewerRB.isSelected());
125 UserPreferences.setHideKnownFilesInDataSourcesTree(dataSourcesHideKnownCB.isSelected());
126 UserPreferences.setHideKnownFilesInViewsTree(viewsHideKnownCB.isSelected());
127 UserPreferences.setDisplayTimesInLocalTime(useLocalTimeRB.isSelected());
128 UserPreferences.setNumberOfFileIngestThreads((Integer) numberOfFileIngestThreadsComboBox.getSelectedItem());
130 UserPreferences.setIsTimeOutEnabled(jCheckBoxEnableProcTimeout.isSelected());
131 if (jCheckBoxEnableProcTimeout.isSelected()) {
133 long timeOutHrs = (long) jFormattedTextFieldProcTimeOutHrs.getValue();
134 UserPreferences.setProcessTimeOutHrs((
int) timeOutHrs);
148 private void initComponents() {
150 buttonGroup1 =
new javax.swing.ButtonGroup();
151 buttonGroup3 =
new javax.swing.ButtonGroup();
152 jScrollPane1 =
new javax.swing.JScrollPane();
153 jPanel1 =
new javax.swing.JPanel();
154 useBestViewerRB =
new javax.swing.JRadioButton();
155 keepCurrentViewerRB =
new javax.swing.JRadioButton();
156 jLabelSelectFile =
new javax.swing.JLabel();
157 jLabelTimeDisplay =
new javax.swing.JLabel();
158 useLocalTimeRB =
new javax.swing.JRadioButton();
159 useGMTTimeRB =
new javax.swing.JRadioButton();
160 jLabelHideKnownFiles =
new javax.swing.JLabel();
161 dataSourcesHideKnownCB =
new javax.swing.JCheckBox();
162 viewsHideKnownCB =
new javax.swing.JCheckBox();
163 jLabelNumThreads =
new javax.swing.JLabel();
164 numberOfFileIngestThreadsComboBox =
new javax.swing.JComboBox<>();
165 restartRequiredLabel =
new javax.swing.JLabel();
166 jLabelSetProcessTimeOut =
new javax.swing.JLabel();
167 jCheckBoxEnableProcTimeout =
new javax.swing.JCheckBox();
168 jLabelProcessTimeOutUnits =
new javax.swing.JLabel();
169 jFormattedTextFieldProcTimeOutHrs =
new JFormattedTextField(NumberFormat.getIntegerInstance());
171 jScrollPane1.setBorder(null);
173 buttonGroup1.add(useBestViewerRB);
174 org.openide.awt.Mnemonics.setLocalizedText(useBestViewerRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useBestViewerRB.text"));
175 useBestViewerRB.setToolTipText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useBestViewerRB.toolTipText"));
176 useBestViewerRB.addActionListener(
new java.awt.event.ActionListener() {
177 public void actionPerformed(java.awt.event.ActionEvent evt) {
178 useBestViewerRBActionPerformed(evt);
182 buttonGroup1.add(keepCurrentViewerRB);
183 org.openide.awt.Mnemonics.setLocalizedText(keepCurrentViewerRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.keepCurrentViewerRB.text"));
184 keepCurrentViewerRB.setToolTipText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.keepCurrentViewerRB.toolTipText"));
185 keepCurrentViewerRB.addActionListener(
new java.awt.event.ActionListener() {
186 public void actionPerformed(java.awt.event.ActionEvent evt) {
187 keepCurrentViewerRBActionPerformed(evt);
191 org.openide.awt.Mnemonics.setLocalizedText(jLabelSelectFile,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelSelectFile.text"));
193 org.openide.awt.Mnemonics.setLocalizedText(jLabelTimeDisplay,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelTimeDisplay.text"));
195 buttonGroup3.add(useLocalTimeRB);
196 org.openide.awt.Mnemonics.setLocalizedText(useLocalTimeRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useLocalTimeRB.text"));
197 useLocalTimeRB.addActionListener(
new java.awt.event.ActionListener() {
198 public void actionPerformed(java.awt.event.ActionEvent evt) {
199 useLocalTimeRBActionPerformed(evt);
203 buttonGroup3.add(useGMTTimeRB);
204 org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useGMTTimeRB.text"));
205 useGMTTimeRB.addActionListener(
new java.awt.event.ActionListener() {
206 public void actionPerformed(java.awt.event.ActionEvent evt) {
207 useGMTTimeRBActionPerformed(evt);
211 org.openide.awt.Mnemonics.setLocalizedText(jLabelHideKnownFiles,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelHideKnownFiles.text"));
213 org.openide.awt.Mnemonics.setLocalizedText(dataSourcesHideKnownCB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.dataSourcesHideKnownCB.text"));
214 dataSourcesHideKnownCB.addActionListener(
new java.awt.event.ActionListener() {
215 public void actionPerformed(java.awt.event.ActionEvent evt) {
216 dataSourcesHideKnownCBActionPerformed(evt);
220 org.openide.awt.Mnemonics.setLocalizedText(viewsHideKnownCB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.viewsHideKnownCB.text"));
221 viewsHideKnownCB.addActionListener(
new java.awt.event.ActionListener() {
222 public void actionPerformed(java.awt.event.ActionEvent evt) {
223 viewsHideKnownCBActionPerformed(evt);
227 org.openide.awt.Mnemonics.setLocalizedText(jLabelNumThreads,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelNumThreads.text"));
229 numberOfFileIngestThreadsComboBox.addActionListener(
new java.awt.event.ActionListener() {
230 public void actionPerformed(java.awt.event.ActionEvent evt) {
231 numberOfFileIngestThreadsComboBoxActionPerformed(evt);
235 restartRequiredLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
236 org.openide.awt.Mnemonics.setLocalizedText(restartRequiredLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartRequiredLabel.text"));
238 org.openide.awt.Mnemonics.setLocalizedText(jLabelSetProcessTimeOut,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelSetProcessTimeOut.text"));
240 org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxEnableProcTimeout,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jCheckBoxEnableProcTimeout.text"));
241 jCheckBoxEnableProcTimeout.addActionListener(
new java.awt.event.ActionListener() {
242 public void actionPerformed(java.awt.event.ActionEvent evt) {
243 jCheckBoxEnableProcTimeoutActionPerformed(evt);
247 org.openide.awt.Mnemonics.setLocalizedText(jLabelProcessTimeOutUnits,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelProcessTimeOutUnits.text"));
249 jFormattedTextFieldProcTimeOutHrs.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jFormattedTextFieldProcTimeOutHrs.text"));
250 jFormattedTextFieldProcTimeOutHrs.addActionListener(
new java.awt.event.ActionListener() {
251 public void actionPerformed(java.awt.event.ActionEvent evt) {
252 jFormattedTextFieldProcTimeOutHrsActionPerformed(evt);
256 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
257 jPanel1.setLayout(jPanel1Layout);
258 jPanel1Layout.setHorizontalGroup(
259 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260 .addGroup(jPanel1Layout.createSequentialGroup()
262 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263 .addGroup(jPanel1Layout.createSequentialGroup()
265 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
266 .addComponent(keepCurrentViewerRB)
267 .addComponent(useBestViewerRB)
268 .addComponent(dataSourcesHideKnownCB)
269 .addComponent(viewsHideKnownCB)
270 .addGroup(jPanel1Layout.createSequentialGroup()
271 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
273 .addComponent(restartRequiredLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
274 .addGroup(jPanel1Layout.createSequentialGroup()
275 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
276 .addComponent(jLabelHideKnownFiles)
277 .addComponent(jLabelTimeDisplay)
278 .addGroup(jPanel1Layout.createSequentialGroup()
280 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
281 .addComponent(useLocalTimeRB)
282 .addComponent(useGMTTimeRB)))
283 .addComponent(jLabelSelectFile)
284 .addComponent(jLabelNumThreads)
285 .addGroup(jPanel1Layout.createSequentialGroup()
287 .addComponent(jCheckBoxEnableProcTimeout)
288 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
289 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
290 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
291 .addComponent(jLabelProcessTimeOutUnits))
292 .addComponent(jLabelSetProcessTimeOut))
293 .addGap(213, 213, 213)))
296 jPanel1Layout.setVerticalGroup(
297 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
298 .addGroup(jPanel1Layout.createSequentialGroup()
300 .addComponent(jLabelSelectFile)
301 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
302 .addComponent(useBestViewerRB)
303 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
304 .addComponent(keepCurrentViewerRB)
305 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
306 .addComponent(jLabelHideKnownFiles)
307 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
308 .addComponent(dataSourcesHideKnownCB)
309 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
310 .addComponent(viewsHideKnownCB)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
312 .addComponent(jLabelTimeDisplay)
313 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
314 .addComponent(useLocalTimeRB)
315 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
316 .addComponent(useGMTTimeRB)
317 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
318 .addComponent(jLabelNumThreads)
319 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
320 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
321 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
322 .addComponent(restartRequiredLabel))
323 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
324 .addComponent(jLabelSetProcessTimeOut)
325 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
326 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
327 .addComponent(jCheckBoxEnableProcTimeout)
328 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
329 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
330 .addComponent(jLabelProcessTimeOutUnits)))
334 jScrollPane1.setViewportView(jPanel1);
336 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
337 this.setLayout(layout);
338 layout.setHorizontalGroup(
339 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
340 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 657, Short.MAX_VALUE)
342 layout.setVerticalGroup(
343 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
344 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
348 private void jCheckBoxEnableProcTimeoutActionPerformed(java.awt.event.ActionEvent evt) {
349 jFormattedTextFieldProcTimeOutHrs.setEditable(jCheckBoxEnableProcTimeout.isSelected());
350 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
353 private void useBestViewerRBActionPerformed(java.awt.event.ActionEvent evt) {
354 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
357 private void keepCurrentViewerRBActionPerformed(java.awt.event.ActionEvent evt) {
358 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
361 private void dataSourcesHideKnownCBActionPerformed(java.awt.event.ActionEvent evt) {
362 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
365 private void viewsHideKnownCBActionPerformed(java.awt.event.ActionEvent evt) {
366 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
369 private void useLocalTimeRBActionPerformed(java.awt.event.ActionEvent evt) {
370 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
373 private void useGMTTimeRBActionPerformed(java.awt.event.ActionEvent evt) {
374 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
377 private void numberOfFileIngestThreadsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
378 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
381 private void jFormattedTextFieldProcTimeOutHrsActionPerformed(java.awt.event.ActionEvent evt) {
382 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
386 private javax.swing.ButtonGroup buttonGroup1;
387 private javax.swing.ButtonGroup buttonGroup3;
388 private javax.swing.JCheckBox dataSourcesHideKnownCB;
389 private javax.swing.JCheckBox jCheckBoxEnableProcTimeout;
390 private javax.swing.JFormattedTextField jFormattedTextFieldProcTimeOutHrs;
391 private javax.swing.JLabel jLabelHideKnownFiles;
392 private javax.swing.JLabel jLabelNumThreads;
393 private javax.swing.JLabel jLabelProcessTimeOutUnits;
394 private javax.swing.JLabel jLabelSelectFile;
395 private javax.swing.JLabel jLabelSetProcessTimeOut;
396 private javax.swing.JLabel jLabelTimeDisplay;
397 private javax.swing.JPanel jPanel1;
398 private javax.swing.JScrollPane jScrollPane1;
399 private javax.swing.JRadioButton keepCurrentViewerRB;
400 private javax.swing.JComboBox<Integer> numberOfFileIngestThreadsComboBox;
401 private javax.swing.JLabel restartRequiredLabel;
402 private javax.swing.JRadioButton useBestViewerRB;
403 private javax.swing.JRadioButton useGMTTimeRB;
404 private javax.swing.JRadioButton useLocalTimeRB;
405 private javax.swing.JCheckBox viewsHideKnownCB;