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.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
186 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
187 org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.ingestWarningLabel.text"));
189 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
190 jPanel1.setLayout(jPanel1Layout);
191 jPanel1Layout.setHorizontalGroup(
192 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193 .addGroup(jPanel1Layout.createSequentialGroup()
195 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addGroup(jPanel1Layout.createSequentialGroup()
197 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
198 .addGroup(jPanel1Layout.createSequentialGroup()
200 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
202 .addComponent(restartRequiredLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
203 .addGroup(jPanel1Layout.createSequentialGroup()
204 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205 .addComponent(jLabelNumThreads)
206 .addComponent(jLabelSetProcessTimeOut)
207 .addGroup(jPanel1Layout.createSequentialGroup()
209 .addComponent(jCheckBoxEnableProcTimeout)
210 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
211 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
212 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
213 .addComponent(jLabelProcessTimeOutUnits)))
214 .addGap(213, 213, 213)))
215 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
216 .addGroup(jPanel1Layout.createSequentialGroup()
217 .addComponent(ingestWarningLabel)
218 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
220 jPanel1Layout.setVerticalGroup(
221 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
222 .addGroup(jPanel1Layout.createSequentialGroup()
224 .addComponent(jLabelNumThreads)
225 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
226 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
227 .addComponent(numberOfFileIngestThreadsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
228 .addComponent(restartRequiredLabel))
229 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
230 .addComponent(jLabelSetProcessTimeOut)
231 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
232 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233 .addComponent(jCheckBoxEnableProcTimeout)
234 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
235 .addComponent(jFormattedTextFieldProcTimeOutHrs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
236 .addComponent(jLabelProcessTimeOutUnits)))
237 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238 .addComponent(ingestWarningLabel)
239 .addContainerGap(257, Short.MAX_VALUE))
242 jScrollPane1.setViewportView(jPanel1);
244 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
245 this.setLayout(layout);
246 layout.setHorizontalGroup(
247 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
248 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE)
250 layout.setVerticalGroup(
251 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
252 .addComponent(jScrollPane1)
256 private void jFormattedTextFieldProcTimeOutHrsActionPerformed(java.awt.event.ActionEvent evt) {
257 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
260 private void jCheckBoxEnableProcTimeoutActionPerformed(java.awt.event.ActionEvent evt) {
261 jFormattedTextFieldProcTimeOutHrs.setEditable(jCheckBoxEnableProcTimeout.isSelected());
262 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
265 private void numberOfFileIngestThreadsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
266 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
270 private javax.swing.JLabel ingestWarningLabel;
271 private javax.swing.JCheckBox jCheckBoxEnableProcTimeout;
272 private javax.swing.JFormattedTextField jFormattedTextFieldProcTimeOutHrs;
273 private javax.swing.JLabel jLabelNumThreads;
274 private javax.swing.JLabel jLabelProcessTimeOutUnits;
275 private javax.swing.JLabel jLabelSetProcessTimeOut;
276 private javax.swing.JPanel jPanel1;
277 private javax.swing.JScrollPane jScrollPane1;
278 private javax.swing.JComboBox<Integer> numberOfFileIngestThreadsComboBox;
279 private javax.swing.JLabel restartRequiredLabel;
283 public void saveSettings() {