19 package org.sleuthkit.autopsy.ingest;
21 import java.awt.Cursor;
22 import java.awt.event.ActionEvent;
24 import java.util.TreeMap;
25 import javax.swing.DefaultListModel;
26 import javax.swing.JOptionPane;
27 import javax.swing.event.ListSelectionEvent;
28 import javax.swing.event.ListSelectionListener;
29 import org.netbeans.spi.options.OptionsPanelController;
30 import org.openide.util.NbBundle;
38 class ProfileSettingsPanel
extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
40 @NbBundle.Messages({
"ProfileSettingsPanel.title=Profile Settings",
41 "ProfileSettingsPanel.profileListLabel.text=Profiles:",
42 "ProfileSettingsPanel.profileDescLabel.text=Profile Description:",
43 "ProfileSettingsPanel.filterNameLabel.text=Filter:",
44 "ProfileSettingsPanel.selectedModulesLabel.text=Selected Ingest Modules:",
45 "ProfileSettingsPanel.newProfileButton.text=New Profile",
46 "ProfileSettingsPanel.editProfileButton.text=Edit Profile",
47 "ProfileSettingsPanel.deleteProfileButton.text=Delete Profile",
48 "ProfileSettingsPanel.messages.filterLoadFailed=Failed to load file ingest filter",
49 "# {0} - profile name",
50 "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text=Profile with name {0} already exists.",
51 "ProfileSettingsPanel.infoTextArea.text=An Ingest Profile runs a preconfigured set of ingest modules"
52 +
" on some or all of the files in a data source. Create a profile if you frequently run the same set of modules on a subset of the files."
55 private final DefaultListModel<IngestProfile> profilesListModel;
56 private Map<String, IngestProfile> profiles;
57 private ProfilePanel panel;
58 private boolean canBeEnabled;
59 private int option = JOptionPane.CANCEL_OPTION;
63 ProfileSettingsPanel() {
64 this.profilesListModel =
new DefaultListModel<>();
66 this.profileList.setModel(profilesListModel);
67 this.profileList.addListSelectionListener(
new ProfileSettingsPanel.ProfileListSelectionListener());
68 ingestWarningLabel.setVisible(
false);
69 canBeEnabled = !IngestManager.getInstance().isIngestRunning();
78 @SuppressWarnings(
"unchecked")
80 private
void initComponents() {
82 profileListPane =
new javax.swing.JScrollPane();
83 profileList =
new javax.swing.JList<>();
84 profileListLabel =
new javax.swing.JLabel();
85 newProfileButton =
new javax.swing.JButton();
86 editProfileButton =
new javax.swing.JButton();
87 deleteProfileButton =
new javax.swing.JButton();
88 profileDescPane =
new javax.swing.JScrollPane();
89 profileDescArea =
new javax.swing.JTextArea();
90 profileDescLabel =
new javax.swing.JLabel();
91 filterNameLabel =
new javax.swing.JLabel();
92 filterNameText =
new javax.swing.JLabel();
93 filterDescPane =
new javax.swing.JScrollPane();
94 filterDescArea =
new javax.swing.JTextArea();
95 selectedModulesPane =
new javax.swing.JScrollPane();
96 selectedModulesArea =
new javax.swing.JTextArea();
97 selectedModulesLabel =
new javax.swing.JLabel();
98 ingestWarningLabel =
new javax.swing.JLabel();
99 jSeparator2 =
new javax.swing.JSeparator();
100 jScrollPane2 =
new javax.swing.JScrollPane();
101 infoTextArea =
new javax.swing.JTextArea();
103 setBorder(javax.swing.BorderFactory.createEtchedBorder());
104 setPreferredSize(
new java.awt.Dimension(800, 488));
106 profileList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
107 profileListPane.setViewportView(profileList);
109 org.openide.awt.Mnemonics.setLocalizedText(profileListLabel,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.profileListLabel.text"));
111 newProfileButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/add16.png")));
112 org.openide.awt.Mnemonics.setLocalizedText(newProfileButton,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.newProfileButton.text"));
113 newProfileButton.setMargin(
new java.awt.Insets(2, 6, 2, 6));
114 newProfileButton.setMaximumSize(
new java.awt.Dimension(111, 25));
115 newProfileButton.setMinimumSize(
new java.awt.Dimension(111, 25));
116 newProfileButton.setPreferredSize(
new java.awt.Dimension(111, 25));
117 newProfileButton.addActionListener(
new java.awt.event.ActionListener() {
118 public void actionPerformed(java.awt.event.ActionEvent evt) {
119 newProfileButtonActionPerformed(evt);
123 editProfileButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/edit16.png")));
124 org.openide.awt.Mnemonics.setLocalizedText(editProfileButton,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.editProfileButton.text"));
125 editProfileButton.setMargin(
new java.awt.Insets(2, 6, 2, 6));
126 editProfileButton.setMaximumSize(
new java.awt.Dimension(111, 25));
127 editProfileButton.setMinimumSize(
new java.awt.Dimension(111, 25));
128 editProfileButton.setPreferredSize(
new java.awt.Dimension(111, 25));
129 editProfileButton.addActionListener(
new java.awt.event.ActionListener() {
130 public void actionPerformed(java.awt.event.ActionEvent evt) {
131 editProfileButtonActionPerformed(evt);
135 deleteProfileButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png")));
136 org.openide.awt.Mnemonics.setLocalizedText(deleteProfileButton,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.deleteProfileButton.text"));
137 deleteProfileButton.setMargin(
new java.awt.Insets(2, 6, 2, 6));
138 deleteProfileButton.setMaximumSize(
new java.awt.Dimension(111, 25));
139 deleteProfileButton.setMinimumSize(
new java.awt.Dimension(111, 25));
140 deleteProfileButton.setPreferredSize(
new java.awt.Dimension(111, 25));
141 deleteProfileButton.addActionListener(
new java.awt.event.ActionListener() {
142 public void actionPerformed(java.awt.event.ActionEvent evt) {
143 deleteProfileButtonActionPerformed(evt);
147 profileDescArea.setEditable(
false);
148 profileDescArea.setBackground(
new java.awt.Color(240, 240, 240));
149 profileDescArea.setColumns(20);
150 profileDescArea.setLineWrap(
true);
151 profileDescArea.setRows(5);
152 profileDescArea.setWrapStyleWord(
true);
153 profileDescArea.setMinimumSize(
new java.awt.Dimension(10, 22));
154 profileDescPane.setViewportView(profileDescArea);
156 org.openide.awt.Mnemonics.setLocalizedText(profileDescLabel,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.profileDescLabel.text"));
158 org.openide.awt.Mnemonics.setLocalizedText(filterNameLabel,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.filterNameLabel.text"));
159 filterNameLabel.setMinimumSize(
new java.awt.Dimension(30, 14));
160 filterNameLabel.setPreferredSize(
new java.awt.Dimension(30, 14));
162 filterNameText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
163 filterNameText.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
165 filterDescPane.setAutoscrolls(
true);
167 filterDescArea.setEditable(
false);
168 filterDescArea.setBackground(
new java.awt.Color(240, 240, 240));
169 filterDescArea.setColumns(20);
170 filterDescArea.setLineWrap(
true);
171 filterDescArea.setRows(5);
172 filterDescArea.setWrapStyleWord(
true);
173 filterDescArea.setMinimumSize(
new java.awt.Dimension(10, 40));
174 filterDescPane.setViewportView(filterDescArea);
176 selectedModulesArea.setEditable(
false);
177 selectedModulesArea.setBackground(
new java.awt.Color(240, 240, 240));
178 selectedModulesArea.setColumns(20);
179 selectedModulesArea.setLineWrap(
true);
180 selectedModulesArea.setRows(5);
181 selectedModulesArea.setWrapStyleWord(
true);
182 selectedModulesPane.setViewportView(selectedModulesArea);
184 org.openide.awt.Mnemonics.setLocalizedText(selectedModulesLabel,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.selectedModulesLabel.text"));
186 ingestWarningLabel.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
187 ingestWarningLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png")));
188 org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel,
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.ingestWarningLabel.text"));
190 jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
192 jScrollPane2.setFont(jScrollPane2.getFont().deriveFont(jScrollPane2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
194 infoTextArea.setEditable(
false);
195 infoTextArea.setBackground(
new java.awt.Color(240, 240, 240));
196 infoTextArea.setColumns(20);
197 infoTextArea.setFont(infoTextArea.getFont().deriveFont(infoTextArea.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
198 infoTextArea.setLineWrap(
true);
199 infoTextArea.setRows(3);
200 infoTextArea.setText(
org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.infoTextArea.text"));
201 infoTextArea.setWrapStyleWord(
true);
202 jScrollPane2.setViewportView(infoTextArea);
204 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
205 this.setLayout(layout);
206 layout.setHorizontalGroup(
207 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
208 .addGroup(layout.createSequentialGroup()
210 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
211 .addGroup(layout.createSequentialGroup()
212 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
213 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
214 .addGroup(layout.createSequentialGroup()
215 .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
216 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
217 .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
218 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
219 .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
220 .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE))
221 .addComponent(profileListLabel))
223 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
224 .addComponent(profileListPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
225 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
226 .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
227 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addGroup(layout.createSequentialGroup()
230 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
231 .addGroup(layout.createSequentialGroup()
232 .addComponent(profileDescLabel)
233 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
234 .addGroup(layout.createSequentialGroup()
235 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236 .addGroup(layout.createSequentialGroup()
238 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239 .addGroup(layout.createSequentialGroup()
240 .addComponent(ingestWarningLabel)
241 .addGap(0, 69, Short.MAX_VALUE))
242 .addComponent(profileDescPane, javax.swing.GroupLayout.Alignment.TRAILING)
243 .addComponent(selectedModulesPane, javax.swing.GroupLayout.Alignment.TRAILING)))
244 .addGroup(layout.createSequentialGroup()
246 .addComponent(filterDescPane)))
247 .addContainerGap())))
248 .addGroup(layout.createSequentialGroup()
249 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
250 .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
252 .addComponent(filterNameText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
254 .addGroup(layout.createSequentialGroup()
255 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256 .addComponent(selectedModulesLabel)
257 .addContainerGap())))
260 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {deleteProfileButton, editProfileButton, newProfileButton});
262 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {jScrollPane2, profileListPane});
264 layout.setVerticalGroup(
265 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
266 .addGroup(layout.createSequentialGroup()
268 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
269 .addGroup(layout.createSequentialGroup()
270 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
271 .addGroup(layout.createSequentialGroup()
272 .addComponent(profileDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
273 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
274 .addComponent(profileDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
275 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
276 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
277 .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
278 .addComponent(filterNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
279 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
280 .addComponent(filterDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
281 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
282 .addComponent(selectedModulesLabel)
283 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
284 .addComponent(selectedModulesPane, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE))
285 .addGroup(layout.createSequentialGroup()
286 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
287 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
288 .addComponent(profileListLabel)
289 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
290 .addComponent(profileListPane, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
293 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
294 .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
295 .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
296 .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
297 .addComponent(ingestWarningLabel))
299 .addComponent(jSeparator2)))
303 private void newProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {
304 doProfileDialog(null);
305 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
308 private void deleteProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {
309 IngestProfile selectedProfile = this.profileList.getSelectedValue();
310 this.profilesListModel.removeElement(selectedProfile);
311 profiles.remove(selectedProfile.getName());
312 IngestProfile.deleteProfile(selectedProfile);
316 this.resetComponents();
317 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
326 void enableButtons(
boolean isEnabled) {
327 canBeEnabled = isEnabled;
329 ingestWarningLabel.setVisible(!canBeEnabled);
335 private void resetComponents() {
336 if (!this.profilesListModel.isEmpty()) {
337 this.profileList.setSelectedIndex(0);
339 this.profilesListModel.clear();
340 this.profileDescArea.setText(
"");
341 this.filterDescArea.setText(
"");
342 this.filterNameText.setText(
"");
343 this.selectedModulesArea.setText(
"");
352 private void refreshButtons() {
353 IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
354 boolean profileIsSelected = (selectedProfile != null);
355 newProfileButton.setEnabled(canBeEnabled);
356 editProfileButton.setEnabled(canBeEnabled && profileIsSelected);
357 deleteProfileButton.setEnabled(canBeEnabled && profileIsSelected);
362 private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {
363 IngestProfile selectedProfile = profileList.getSelectedValue();
364 doProfileDialog(selectedProfile);
365 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
373 private void doProfileDialog(IngestProfile selectedProfile) {
375 final AdvancedConfigurationDialog dialog =
new AdvancedConfigurationDialog(
true);
376 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
378 if (selectedProfile != null) {
380 panel =
new ProfilePanel(selectedProfile);
383 panel =
new ProfilePanel();
385 dialog.addApplyButtonListener(
388 option = JOptionPane.OK_OPTION;
395 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
398 option = JOptionPane.CANCEL_OPTION;
399 dialog.display(panel);
400 }
while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
402 if (option == JOptionPane.OK_OPTION) {
406 if (this.profiles.containsKey(panel.getProfileName()) && selectedProfile == null) {
407 MessageNotifyUtil.Message.error(NbBundle.getMessage(
this.getClass(),
408 "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
409 panel.getProfileName()));
412 panel.saveSettings();
418 public void saveSettings() {
422 public void store() {
430 int currentIndex = this.profileList.getSelectedIndex();
431 this.profilesListModel.clear();
432 this.profiles =
new TreeMap<>();
433 for (IngestProfile profile : IngestProfiles.getIngestProfiles()) {
434 profilesListModel.addElement(profile);
435 profiles.put(profile.getName(), profile);
437 if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
441 this.profileList.setSelectedIndex(currentIndex);
448 if (e.getValueIsAdjusting()) {
453 IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
455 if (selectedProfile != null) {
461 fileIngestFilters.put(fSet.getName(), fSet);
463 filterDescArea.setText(fileIngestFilters.get(selectedProfile.
getFileIngestFilter()).getDescription());
465 filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class,
"ProfileSettingsPanel.messages.filterLoadFailed"));
467 selectedModulesArea.setText(
"");
468 for (String moduleName :
IngestJobSettings.getEnabledModules(selectedProfile.getName())) {
469 selectedModulesArea.append(moduleName +
"\n");
476 private javax.swing.JButton deleteProfileButton;
477 private javax.swing.JButton editProfileButton;
478 private javax.swing.JTextArea filterDescArea;
479 private javax.swing.JScrollPane filterDescPane;
480 private javax.swing.JLabel filterNameLabel;
481 private javax.swing.JLabel filterNameText;
482 private javax.swing.JTextArea infoTextArea;
483 private javax.swing.JLabel ingestWarningLabel;
484 private javax.swing.JScrollPane jScrollPane2;
485 private javax.swing.JSeparator jSeparator2;
486 private javax.swing.JButton newProfileButton;
487 private javax.swing.JTextArea profileDescArea;
488 private javax.swing.JLabel profileDescLabel;
489 private javax.swing.JScrollPane profileDescPane;
491 private javax.swing.JLabel profileListLabel;
492 private javax.swing.JScrollPane profileListPane;
493 private javax.swing.JTextArea selectedModulesArea;
494 private javax.swing.JLabel selectedModulesLabel;
495 private javax.swing.JScrollPane selectedModulesPane;
static List< FilesSet > getStandardFileIngestFilters()
static synchronized FilesSetsManager getInstance()
void valueChanged(ListSelectionEvent e)
Map< String, FilesSet > getCustomFileIngestFilters()
String getFileIngestFilter()