19 package org.sleuthkit.autopsy.corecomponents;
21 import java.text.NumberFormat;
22 import javax.swing.DefaultComboBoxModel;
23 import javax.swing.JFormattedTextField;
24 import org.openide.util.NbBundle;
30 final class AutopsyOptionsPanel
extends javax.swing.JPanel {
32 AutopsyOptionsPanel(AutopsyOptionsPanelController controller) {
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;
42 recommendedFileIngestThreadCount = 12;
44 }
else if (availableProcessors >= 12 && availableProcessors <= 15) {
45 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8, 12};
46 if (availableProcessors >= 14) {
47 recommendedFileIngestThreadCount = 12;
49 recommendedFileIngestThreadCount = 8;
51 }
else if (availableProcessors >= 8 && availableProcessors <= 11) {
52 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8};
53 if (availableProcessors >= 10) {
54 recommendedFileIngestThreadCount = 8;
56 recommendedFileIngestThreadCount = 6;
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;
68 fileIngestThreadCountChoices =
new Integer[]{1};
69 recommendedFileIngestThreadCount = 1;
71 numberOfFileIngestThreadsComboBox.setModel(
new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
72 restartRequiredLabel.setText(NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
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()) {
88 jCheckBoxEnableProcTimeout.setSelected(
true);
89 jFormattedTextFieldProcTimeOutHrs.setEditable(
true);
90 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
91 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
94 jCheckBoxEnableProcTimeout.setSelected(
false);
95 jFormattedTextFieldProcTimeOutHrs.setEditable(
false);
96 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
97 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
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());
108 UserPreferences.setIsTimeOutEnabled(jCheckBoxEnableProcTimeout.isSelected());
109 if (jCheckBoxEnableProcTimeout.isSelected()) {
111 long timeOutHrs = (long) jFormattedTextFieldProcTimeOutHrs.getValue();
112 UserPreferences.setProcessTimeOutHrs((
int) timeOutHrs);
126 private void initComponents() {
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());
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"));
150 useBestViewerRB.setToolTipText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useBestViewerRB.toolTipText"));
152 buttonGroup1.add(keepCurrentViewerRB);
153 org.openide.awt.Mnemonics.setLocalizedText(keepCurrentViewerRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.keepCurrentViewerRB.text"));
154 keepCurrentViewerRB.setToolTipText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.keepCurrentViewerRB.toolTipText"));
156 org.openide.awt.Mnemonics.setLocalizedText(jLabelSelectFile,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelSelectFile.text"));
158 org.openide.awt.Mnemonics.setLocalizedText(jLabelTimeDisplay,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelTimeDisplay.text"));
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"));
164 buttonGroup3.add(useGMTTimeRB);
165 org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.useGMTTimeRB.text"));
167 org.openide.awt.Mnemonics.setLocalizedText(jLabelHideKnownFiles,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelHideKnownFiles.text"));
169 org.openide.awt.Mnemonics.setLocalizedText(dataSourcesHideKnownCB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.dataSourcesHideKnownCB.text"));
171 org.openide.awt.Mnemonics.setLocalizedText(viewsHideKnownCB,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.viewsHideKnownCB.text"));
173 org.openide.awt.Mnemonics.setLocalizedText(jLabelNumThreads,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelNumThreads.text"));
175 restartRequiredLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
176 org.openide.awt.Mnemonics.setLocalizedText(restartRequiredLabel,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.restartRequiredLabel.text"));
178 org.openide.awt.Mnemonics.setLocalizedText(jLabelSetProcessTimeOut,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelSetProcessTimeOut.text"));
180 org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxEnableProcTimeout,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jCheckBoxEnableProcTimeout.text"));
181 jCheckBoxEnableProcTimeout.addActionListener(
new java.awt.event.ActionListener() {
182 public void actionPerformed(java.awt.event.ActionEvent evt) {
183 jCheckBoxEnableProcTimeoutActionPerformed(evt);
187 org.openide.awt.Mnemonics.setLocalizedText(jLabelProcessTimeOutUnits,
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jLabelProcessTimeOutUnits.text"));
189 jFormattedTextFieldProcTimeOutHrs.setText(
org.openide.util.NbBundle.getMessage(AutopsyOptionsPanel.class,
"AutopsyOptionsPanel.jFormattedTextFieldProcTimeOutHrs.text"));
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()
197 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198 .addGroup(layout.createSequentialGroup()
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)
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()
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()
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))))
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))
272 private void jCheckBoxEnableProcTimeoutActionPerformed(java.awt.event.ActionEvent evt) {
273 jFormattedTextFieldProcTimeOutHrs.setEditable(jCheckBoxEnableProcTimeout.isSelected());
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;