19 package org.sleuthkit.autopsy.ingest;
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 @SuppressWarnings(
"PMD.SingularField")
34 final class IngestSettingsPanel extends IngestModuleGlobalSettingsPanel {
36 IngestSettingsPanel() {
38 int availableProcessors = Runtime.getRuntime().availableProcessors();
39 Integer fileIngestThreadCountChoices[];
40 int recommendedFileIngestThreadCount;
41 if (availableProcessors >= 8) {
42 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8};
43 recommendedFileIngestThreadCount = 4;
44 }
else if (availableProcessors >= 6) {
45 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6};
46 recommendedFileIngestThreadCount = 4;
47 }
else if (availableProcessors >= 4) {
48 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4};
49 recommendedFileIngestThreadCount = 2;
50 }
else if (availableProcessors >= 2) {
51 fileIngestThreadCountChoices =
new Integer[]{1, 2};
52 recommendedFileIngestThreadCount = 1;
54 fileIngestThreadCountChoices =
new Integer[]{1};
55 recommendedFileIngestThreadCount = 1;
57 numberOfFileIngestThreadsComboBox.setModel(
new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
58 restartRequiredLabel.setText(NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
60 DocumentListener docListener =
new DocumentListener() {
63 public void insertUpdate(DocumentEvent e) {
64 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
68 public void removeUpdate(DocumentEvent e) {
69 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
73 public void changedUpdate(DocumentEvent e) {
74 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
77 this.jFormattedTextFieldProcTimeOutHrs.getDocument().addDocumentListener(docListener);
78 this.ingestWarningLabel.setVisible(
false);
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);
105 UserPreferences.setNumberOfFileIngestThreads((Integer) numberOfFileIngestThreadsComboBox.getSelectedItem());
107 UserPreferences.setIsTimeOutEnabled(jCheckBoxEnableProcTimeout.isSelected());
108 if (jCheckBoxEnableProcTimeout.isSelected()) {
110 long timeOutHrs = (long) jFormattedTextFieldProcTimeOutHrs.getValue();
111 UserPreferences.setProcessTimeOutHrs((
int) timeOutHrs);
124 void enableButtons(
boolean isEnabled) {
125 numberOfFileIngestThreadsComboBox.setEnabled(isEnabled);
126 jFormattedTextFieldProcTimeOutHrs.setEnabled(isEnabled);
127 jCheckBoxEnableProcTimeout.setEnabled(isEnabled);
128 ingestWarningLabel.setVisible(!isEnabled);
137 private void initComponents() {
139 jScrollPane1 =
new javax.swing.JScrollPane();
140 jPanel1 =
new javax.swing.JPanel();
141 jLabelNumThreads =
new javax.swing.JLabel();
142 numberOfFileIngestThreadsComboBox =
new javax.swing.JComboBox<>();
143 restartRequiredLabel =
new javax.swing.JLabel();
144 jLabelSetProcessTimeOut =
new javax.swing.JLabel();
145 jCheckBoxEnableProcTimeout =
new javax.swing.JCheckBox();
146 jFormattedTextFieldProcTimeOutHrs =
new JFormattedTextField(NumberFormat.getIntegerInstance());
147 jLabelProcessTimeOutUnits =
new javax.swing.JLabel();
148 ingestWarningLabel =
new javax.swing.JLabel();
150 setPreferredSize(
new java.awt.Dimension(693, 413));
152 jScrollPane1.setBorder(null);
154 jPanel1.setPreferredSize(
new java.awt.Dimension(664, 400));
156 org.openide.awt.Mnemonics.setLocalizedText(jLabelNumThreads,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelNumThreads.text"));
158 numberOfFileIngestThreadsComboBox.addActionListener(
new java.awt.event.ActionListener() {
159 public void actionPerformed(java.awt.event.ActionEvent evt) {
160 numberOfFileIngestThreadsComboBoxActionPerformed(evt);
164 restartRequiredLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
165 org.openide.awt.Mnemonics.setLocalizedText(restartRequiredLabel,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.restartRequiredLabel.text"));
167 org.openide.awt.Mnemonics.setLocalizedText(jLabelSetProcessTimeOut,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelSetProcessTimeOut.text"));
169 org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxEnableProcTimeout,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jCheckBoxEnableProcTimeout.text"));
170 jCheckBoxEnableProcTimeout.addActionListener(
new java.awt.event.ActionListener() {
171 public void actionPerformed(java.awt.event.ActionEvent evt) {
172 jCheckBoxEnableProcTimeoutActionPerformed(evt);
176 jFormattedTextFieldProcTimeOutHrs.setText(
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jFormattedTextFieldProcTimeOutHrs.text"));
177 jFormattedTextFieldProcTimeOutHrs.addActionListener(
new java.awt.event.ActionListener() {
178 public void actionPerformed(java.awt.event.ActionEvent evt) {
179 jFormattedTextFieldProcTimeOutHrsActionPerformed(evt);
183 org.openide.awt.Mnemonics.setLocalizedText(jLabelProcessTimeOutUnits,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelProcessTimeOutUnits.text"));
185 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
186 org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.ingestWarningLabel.text"));
188 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
189 jPanel1.setLayout(jPanel1Layout);
190 jPanel1Layout.setHorizontalGroup(
191 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
192 .addGroup(jPanel1Layout.createSequentialGroup()
194 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
195 .addGroup(jPanel1Layout.createSequentialGroup()
196 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
197 .addGroup(jPanel1Layout.createSequentialGroup()
199 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
201 .addComponent(restartRequiredLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
202 .addGroup(jPanel1Layout.createSequentialGroup()
203 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204 .addComponent(jLabelNumThreads)
205 .addComponent(jLabelSetProcessTimeOut)
206 .addGroup(jPanel1Layout.createSequentialGroup()
208 .addComponent(jCheckBoxEnableProcTimeout)
209 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
210 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
211 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
212 .addComponent(jLabelProcessTimeOutUnits)))
213 .addGap(213, 213, 213)))
214 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
215 .addGroup(jPanel1Layout.createSequentialGroup()
216 .addComponent(ingestWarningLabel)
217 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
219 jPanel1Layout.setVerticalGroup(
220 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
221 .addGroup(jPanel1Layout.createSequentialGroup()
223 .addComponent(jLabelNumThreads)
224 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
226 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
227 .addComponent(restartRequiredLabel))
228 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
229 .addComponent(jLabelSetProcessTimeOut)
230 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
231 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232 .addComponent(jCheckBoxEnableProcTimeout)
233 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
234 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
235 .addComponent(jLabelProcessTimeOutUnits)))
236 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
237 .addComponent(ingestWarningLabel)
238 .addContainerGap(257, Short.MAX_VALUE))
241 jScrollPane1.setViewportView(jPanel1);
243 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
244 this.setLayout(layout);
245 layout.setHorizontalGroup(
246 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE)
249 layout.setVerticalGroup(
250 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
251 .addComponent(jScrollPane1)
255 private void jFormattedTextFieldProcTimeOutHrsActionPerformed(java.awt.event.ActionEvent evt) {
256 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
259 private void jCheckBoxEnableProcTimeoutActionPerformed(java.awt.event.ActionEvent evt) {
260 jFormattedTextFieldProcTimeOutHrs.setEditable(jCheckBoxEnableProcTimeout.isSelected());
261 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
264 private void numberOfFileIngestThreadsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
265 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
269 private javax.swing.JLabel ingestWarningLabel;
270 private javax.swing.JCheckBox jCheckBoxEnableProcTimeout;
271 private javax.swing.JFormattedTextField jFormattedTextFieldProcTimeOutHrs;
272 private javax.swing.JLabel jLabelNumThreads;
273 private javax.swing.JLabel jLabelProcessTimeOutUnits;
274 private javax.swing.JLabel jLabelSetProcessTimeOut;
275 private javax.swing.JPanel jPanel1;
276 private javax.swing.JScrollPane jScrollPane1;
277 private javax.swing.JComboBox<Integer> numberOfFileIngestThreadsComboBox;
278 private javax.swing.JLabel restartRequiredLabel;
282 public void saveSettings() {