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 final class IngestSettingsPanel
extends IngestModuleGlobalSettingsPanel {
35 IngestSettingsPanel() {
37 int availableProcessors = Runtime.getRuntime().availableProcessors();
38 Integer fileIngestThreadCountChoices[];
39 int recommendedFileIngestThreadCount;
40 if (availableProcessors >= 8) {
41 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6, 8};
42 recommendedFileIngestThreadCount = 4;
43 }
else if (availableProcessors >= 6) {
44 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4, 6};
45 recommendedFileIngestThreadCount = 4;
46 }
else if (availableProcessors >= 4) {
47 fileIngestThreadCountChoices =
new Integer[]{1, 2, 4};
48 recommendedFileIngestThreadCount = 2;
49 }
else if (availableProcessors >= 2) {
50 fileIngestThreadCountChoices =
new Integer[]{1, 2};
51 recommendedFileIngestThreadCount = 1;
53 fileIngestThreadCountChoices =
new Integer[]{1};
54 recommendedFileIngestThreadCount = 1;
56 numberOfFileIngestThreadsComboBox.setModel(
new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
57 restartRequiredLabel.setText(NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
59 DocumentListener docListener =
new DocumentListener() {
62 public void insertUpdate(DocumentEvent e) {
63 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
67 public void removeUpdate(DocumentEvent e) {
68 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
72 public void changedUpdate(DocumentEvent e) {
73 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
76 this.jFormattedTextFieldProcTimeOutHrs.getDocument().addDocumentListener(docListener);
77 this.ingestWarningLabel.setVisible(
false);
84 numberOfFileIngestThreadsComboBox.setSelectedItem(UserPreferences.numberOfFileIngestThreads());
85 if (UserPreferences.getIsTimeOutEnabled()) {
87 jCheckBoxEnableProcTimeout.setSelected(
true);
88 jFormattedTextFieldProcTimeOutHrs.setEditable(
true);
89 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
90 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
93 jCheckBoxEnableProcTimeout.setSelected(
false);
94 jFormattedTextFieldProcTimeOutHrs.setEditable(
false);
95 int timeOutHrs = UserPreferences.getProcessTimeOutHrs();
96 jFormattedTextFieldProcTimeOutHrs.setValue((
long) timeOutHrs);
104 UserPreferences.setNumberOfFileIngestThreads((Integer) numberOfFileIngestThreadsComboBox.getSelectedItem());
106 UserPreferences.setIsTimeOutEnabled(jCheckBoxEnableProcTimeout.isSelected());
107 if (jCheckBoxEnableProcTimeout.isSelected()) {
109 long timeOutHrs = (long) jFormattedTextFieldProcTimeOutHrs.getValue();
110 UserPreferences.setProcessTimeOutHrs((
int) timeOutHrs);
123 void enableButtons(
boolean isEnabled) {
124 numberOfFileIngestThreadsComboBox.setEnabled(isEnabled);
125 jFormattedTextFieldProcTimeOutHrs.setEnabled(isEnabled);
126 jCheckBoxEnableProcTimeout.setEnabled(isEnabled);
127 ingestWarningLabel.setVisible(!isEnabled);
136 private void initComponents() {
138 jScrollPane1 =
new javax.swing.JScrollPane();
139 jPanel1 =
new javax.swing.JPanel();
140 jLabelNumThreads =
new javax.swing.JLabel();
141 numberOfFileIngestThreadsComboBox =
new javax.swing.JComboBox<>();
142 restartRequiredLabel =
new javax.swing.JLabel();
143 jLabelSetProcessTimeOut =
new javax.swing.JLabel();
144 jCheckBoxEnableProcTimeout =
new javax.swing.JCheckBox();
145 jFormattedTextFieldProcTimeOutHrs =
new JFormattedTextField(NumberFormat.getIntegerInstance());
146 jLabelProcessTimeOutUnits =
new javax.swing.JLabel();
147 ingestWarningLabel =
new javax.swing.JLabel();
149 setPreferredSize(
new java.awt.Dimension(693, 413));
151 jScrollPane1.setBorder(null);
153 jPanel1.setPreferredSize(
new java.awt.Dimension(664, 400));
155 org.openide.awt.Mnemonics.setLocalizedText(jLabelNumThreads,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelNumThreads.text"));
157 numberOfFileIngestThreadsComboBox.addActionListener(
new java.awt.event.ActionListener() {
158 public void actionPerformed(java.awt.event.ActionEvent evt) {
159 numberOfFileIngestThreadsComboBoxActionPerformed(evt);
163 restartRequiredLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/corecomponents/warning16.png")));
164 org.openide.awt.Mnemonics.setLocalizedText(restartRequiredLabel,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.restartRequiredLabel.text"));
166 org.openide.awt.Mnemonics.setLocalizedText(jLabelSetProcessTimeOut,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelSetProcessTimeOut.text"));
168 org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxEnableProcTimeout,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jCheckBoxEnableProcTimeout.text"));
169 jCheckBoxEnableProcTimeout.addActionListener(
new java.awt.event.ActionListener() {
170 public void actionPerformed(java.awt.event.ActionEvent evt) {
171 jCheckBoxEnableProcTimeoutActionPerformed(evt);
175 jFormattedTextFieldProcTimeOutHrs.setText(
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jFormattedTextFieldProcTimeOutHrs.text"));
176 jFormattedTextFieldProcTimeOutHrs.addActionListener(
new java.awt.event.ActionListener() {
177 public void actionPerformed(java.awt.event.ActionEvent evt) {
178 jFormattedTextFieldProcTimeOutHrsActionPerformed(evt);
182 org.openide.awt.Mnemonics.setLocalizedText(jLabelProcessTimeOutUnits,
org.openide.util.NbBundle.getMessage(IngestSettingsPanel.class,
"IngestSettingsPanel.jLabelProcessTimeOutUnits.text"));
184 ingestWarningLabel.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
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() {