Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
ProfileSettingsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest;
20 
21 import java.awt.Cursor;
22 import java.awt.event.ActionEvent;
23 import java.util.Map;
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;
37 
41 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
42 class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
43 
44  @NbBundle.Messages({"ProfileSettingsPanel.title=Profile Settings",
45  "ProfileSettingsPanel.profileListLabel.text=Profiles:",
46  "ProfileSettingsPanel.profileDescLabel.text=Profile Description:",
47  "ProfileSettingsPanel.filterNameLabel.text=Filter:",
48  "ProfileSettingsPanel.selectedModulesLabel.text=Selected Ingest Modules:",
49  "ProfileSettingsPanel.newProfileButton.text=New Profile",
50  "ProfileSettingsPanel.editProfileButton.text=Edit Profile",
51  "ProfileSettingsPanel.deleteProfileButton.text=Delete Profile",
52  "ProfileSettingsPanel.messages.filterLoadFailed=Failed to load file ingest filter",
53  "# {0} - profile name",
54  "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text=Profile with name {0} already exists.",
55  "ProfileSettingsPanel.infoTextArea.text=An Ingest Profile runs a preconfigured set of ingest modules"
56  + " 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."
57  })
58 
59  private final DefaultListModel<IngestProfile> profilesListModel;
60  private Map<String, IngestProfile> profiles;
61  private ProfilePanel panel;
62  private boolean canBeEnabled; //if something can be enabled ingest is not running
63  private int option = JOptionPane.CANCEL_OPTION;
67  ProfileSettingsPanel() {
68  this.profilesListModel = new DefaultListModel<>();
69  initComponents();
70  this.profileList.setModel(profilesListModel);
71  this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener());
72  ingestWarningLabel.setVisible(false);
73  canBeEnabled = !IngestManager.getInstance().isIngestRunning();
74  refreshButtons();
75  }
76 
82  @SuppressWarnings("unchecked")
83  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
84  private void initComponents() {
85 
86  profileListPane = new javax.swing.JScrollPane();
87  profileList = new javax.swing.JList<>();
88  profileListLabel = new javax.swing.JLabel();
89  profileDescPane = new javax.swing.JScrollPane();
90  profileDescArea = new javax.swing.JTextArea();
91  profileDescLabel = new javax.swing.JLabel();
92  filterNameLabel = new javax.swing.JLabel();
93  filterNameText = new javax.swing.JLabel();
94  filterDescPane = new javax.swing.JScrollPane();
95  filterDescArea = new javax.swing.JTextArea();
96  selectedModulesPane = new javax.swing.JScrollPane();
97  selectedModulesArea = new javax.swing.JTextArea();
98  selectedModulesLabel = new javax.swing.JLabel();
99  ingestWarningLabel = new javax.swing.JLabel();
100  jSeparator2 = new javax.swing.JSeparator();
101  infoScrollPane = new javax.swing.JScrollPane();
102  infoTextArea = new javax.swing.JTextArea();
103  buttonEnclosingPanel = new javax.swing.JPanel();
104  editProfileButton = new javax.swing.JButton();
105  newProfileButton = new javax.swing.JButton();
106  deleteProfileButton = new javax.swing.JButton();
107 
108  setBorder(javax.swing.BorderFactory.createEtchedBorder());
109  setPreferredSize(new java.awt.Dimension(800, 488));
110 
111  profileList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
112  profileListPane.setViewportView(profileList);
113 
114  org.openide.awt.Mnemonics.setLocalizedText(profileListLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.profileListLabel.text")); // NOI18N
115 
116  profileDescArea.setEditable(false);
117  profileDescArea.setBackground(new java.awt.Color(240, 240, 240));
118  profileDescArea.setColumns(20);
119  profileDescArea.setLineWrap(true);
120  profileDescArea.setRows(5);
121  profileDescArea.setWrapStyleWord(true);
122  profileDescArea.setMinimumSize(new java.awt.Dimension(10, 22));
123  profileDescPane.setViewportView(profileDescArea);
124 
125  org.openide.awt.Mnemonics.setLocalizedText(profileDescLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.profileDescLabel.text")); // NOI18N
126 
127  org.openide.awt.Mnemonics.setLocalizedText(filterNameLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.filterNameLabel.text")); // NOI18N
128  filterNameLabel.setMinimumSize(new java.awt.Dimension(30, 14));
129 
130  filterNameText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
131  filterNameText.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
132 
133  filterDescPane.setAutoscrolls(true);
134 
135  filterDescArea.setEditable(false);
136  filterDescArea.setBackground(new java.awt.Color(240, 240, 240));
137  filterDescArea.setColumns(20);
138  filterDescArea.setLineWrap(true);
139  filterDescArea.setRows(5);
140  filterDescArea.setWrapStyleWord(true);
141  filterDescArea.setMinimumSize(new java.awt.Dimension(10, 40));
142  filterDescPane.setViewportView(filterDescArea);
143 
144  selectedModulesArea.setEditable(false);
145  selectedModulesArea.setBackground(new java.awt.Color(240, 240, 240));
146  selectedModulesArea.setColumns(20);
147  selectedModulesArea.setLineWrap(true);
148  selectedModulesArea.setRows(5);
149  selectedModulesArea.setWrapStyleWord(true);
150  selectedModulesPane.setViewportView(selectedModulesArea);
151 
152  org.openide.awt.Mnemonics.setLocalizedText(selectedModulesLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.selectedModulesLabel.text")); // NOI18N
153 
154  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
155  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.ingestWarningLabel.text")); // NOI18N
156 
157  jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
158 
159  infoTextArea.setEditable(false);
160  infoTextArea.setBackground(new java.awt.Color(240, 240, 240));
161  infoTextArea.setColumns(20);
162  infoTextArea.setLineWrap(true);
163  infoTextArea.setRows(3);
164  infoTextArea.setText(org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.infoTextArea.text")); // NOI18N
165  infoTextArea.setWrapStyleWord(true);
166  infoScrollPane.setViewportView(infoTextArea);
167 
168  editProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
169  org.openide.awt.Mnemonics.setLocalizedText(editProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.editProfileButton.text")); // NOI18N
170  editProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
171  editProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
172  editProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
173  editProfileButton.addActionListener(new java.awt.event.ActionListener() {
174  public void actionPerformed(java.awt.event.ActionEvent evt) {
175  editProfileButtonActionPerformed(evt);
176  }
177  });
178 
179  newProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
180  org.openide.awt.Mnemonics.setLocalizedText(newProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.newProfileButton.text")); // NOI18N
181  newProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
182  newProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
183  newProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
184  newProfileButton.addActionListener(new java.awt.event.ActionListener() {
185  public void actionPerformed(java.awt.event.ActionEvent evt) {
186  newProfileButtonActionPerformed(evt);
187  }
188  });
189 
190  deleteProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
191  org.openide.awt.Mnemonics.setLocalizedText(deleteProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.deleteProfileButton.text")); // NOI18N
192  deleteProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
193  deleteProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
194  deleteProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
195  deleteProfileButton.addActionListener(new java.awt.event.ActionListener() {
196  public void actionPerformed(java.awt.event.ActionEvent evt) {
197  deleteProfileButtonActionPerformed(evt);
198  }
199  });
200 
201  javax.swing.GroupLayout buttonEnclosingPanelLayout = new javax.swing.GroupLayout(buttonEnclosingPanel);
202  buttonEnclosingPanel.setLayout(buttonEnclosingPanelLayout);
203  buttonEnclosingPanelLayout.setHorizontalGroup(
204  buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
205  .addGroup(buttonEnclosingPanelLayout.createSequentialGroup()
206  .addContainerGap()
207  .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
208  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
209  .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
210  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
211  .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
212  .addContainerGap())
213  );
214 
215  buttonEnclosingPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteProfileButton, editProfileButton, newProfileButton});
216 
217  buttonEnclosingPanelLayout.setVerticalGroup(
218  buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219  .addGroup(buttonEnclosingPanelLayout.createSequentialGroup()
220  .addContainerGap()
221  .addGroup(buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
222  .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
223  .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
224  .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
225  .addContainerGap())
226  );
227 
228  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
229  this.setLayout(layout);
230  layout.setHorizontalGroup(
231  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232  .addGroup(layout.createSequentialGroup()
233  .addContainerGap()
234  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236  .addGroup(layout.createSequentialGroup()
237  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238  .addComponent(infoScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
239  .addComponent(profileListLabel))
240  .addGap(6, 6, 6))
241  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
242  .addComponent(profileListPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
243  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
244  .addGroup(layout.createSequentialGroup()
245  .addComponent(buttonEnclosingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
246  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
247  .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
248  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249  .addGroup(layout.createSequentialGroup()
250  .addGap(6, 6, 6)
251  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
252  .addGroup(layout.createSequentialGroup()
253  .addComponent(profileDescLabel)
254  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
255  .addGroup(layout.createSequentialGroup()
256  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
257  .addGroup(layout.createSequentialGroup()
258  .addGap(8, 8, 8)
259  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260  .addGroup(layout.createSequentialGroup()
261  .addComponent(ingestWarningLabel)
262  .addGap(0, 0, Short.MAX_VALUE))
263  .addComponent(profileDescPane, javax.swing.GroupLayout.Alignment.TRAILING)
264  .addComponent(selectedModulesPane, javax.swing.GroupLayout.Alignment.TRAILING)))
265  .addGroup(layout.createSequentialGroup()
266  .addGap(10, 10, 10)
267  .addComponent(filterDescPane)))
268  .addContainerGap())))
269  .addGroup(layout.createSequentialGroup()
270  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271  .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
272  .addGap(0, 0, 0)
273  .addComponent(filterNameText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
274  .addContainerGap())
275  .addGroup(layout.createSequentialGroup()
276  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
277  .addComponent(selectedModulesLabel)
278  .addContainerGap())))
279  );
280 
281  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonEnclosingPanel, infoScrollPane, profileListPane});
282 
283  layout.setVerticalGroup(
284  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285  .addGroup(layout.createSequentialGroup()
286  .addContainerGap()
287  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
288  .addGroup(layout.createSequentialGroup()
289  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
290  .addGroup(layout.createSequentialGroup()
291  .addComponent(profileDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
292  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
293  .addComponent(profileDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
294  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
295  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
296  .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
297  .addComponent(filterNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
298  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
299  .addComponent(filterDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
300  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
301  .addComponent(selectedModulesLabel)
302  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
303  .addComponent(selectedModulesPane, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE))
304  .addGroup(layout.createSequentialGroup()
305  .addComponent(infoScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
306  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
307  .addComponent(profileListLabel)
308  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
309  .addComponent(profileListPane, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)))
310  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
311  .addGroup(layout.createSequentialGroup()
312  .addGap(11, 11, 11)
313  .addComponent(ingestWarningLabel))
314  .addGroup(layout.createSequentialGroup()
315  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
316  .addComponent(buttonEnclosingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
317  .addContainerGap())
318  .addComponent(jSeparator2)))
319  );
320  }// </editor-fold>//GEN-END:initComponents
321 
322  private void newProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newProfileButtonActionPerformed
323  doProfileDialog(null);
324  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
325  }//GEN-LAST:event_newProfileButtonActionPerformed
326 
327  private void deleteProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteProfileButtonActionPerformed
328  IngestProfile selectedProfile = this.profileList.getSelectedValue();
329  this.profilesListModel.removeElement(selectedProfile);
330  profiles.remove(selectedProfile.getName());
331  IngestProfile.deleteProfile(selectedProfile);
332 
333  // Select the first of the remaining set definitions. This will cause
334  // the selection listeners to repopulate the subordinate components.
335  this.resetComponents();
336  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
337  }//GEN-LAST:event_deleteProfileButtonActionPerformed
338 
345  void enableButtons(boolean isEnabled) {
346  canBeEnabled = isEnabled; //update value of canBeEnabled to be used by refresh
347  refreshButtons();
348  ingestWarningLabel.setVisible(!canBeEnabled);
349  }
350 
354  private void resetComponents() {
355  if (!this.profilesListModel.isEmpty()) {
356  this.profileList.setSelectedIndex(0);
357  } else {
358  this.profilesListModel.clear();
359  this.profileDescArea.setText("");
360  this.filterDescArea.setText("");
361  this.filterNameText.setText("");
362  this.selectedModulesArea.setText("");
363  }
364  refreshButtons();
365  }
366 
371  private void refreshButtons() {
372  IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
373  boolean profileIsSelected = (selectedProfile != null);
374  newProfileButton.setEnabled(canBeEnabled);
375  editProfileButton.setEnabled(canBeEnabled && profileIsSelected);
376  deleteProfileButton.setEnabled(canBeEnabled && profileIsSelected);
377 
378  }
379 
380 
381  private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editProfileButtonActionPerformed
382  IngestProfile selectedProfile = profileList.getSelectedValue();
383  doProfileDialog(selectedProfile);
384  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
385  }//GEN-LAST:event_editProfileButtonActionPerformed
386 
392  private void doProfileDialog(IngestProfile selectedProfile) {
393  // Create a files set defintion panel.
394  final AdvancedConfigurationDialog dialog = new AdvancedConfigurationDialog(true);
395  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
396  //start wait cursor for ingest job settings construction
397  if (selectedProfile != null) {
398  // Editing an existing set definition.
399  panel = new ProfilePanel(selectedProfile);
400  } else {
401  // Creating a new set definition.
402  panel = new ProfilePanel();
403  }
404  dialog.addApplyButtonListener(
405  (ActionEvent e) -> {
406  panel.store();
407  option = JOptionPane.OK_OPTION;
408  dialog.close();
409  }
410  );
411 
412 
413  //end wait Cursor for ingest job settings construction
414  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
415  // Do a dialog box with the profilePanel till the user enters a name or chooses cancel
416  do {
417  option = JOptionPane.CANCEL_OPTION;
418  dialog.display(panel);
419  } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition(true));
420 
421  if (option == JOptionPane.OK_OPTION) {
422 
423  // While adding new profile(selectedPRofile == null), if a profile with same name already exists, do not add to the profiles hashMap.
424  // In case of editing an existing profile(selectedProfile != null), following check is not performed.
425  if (this.profiles.containsKey(panel.getProfileName()) && selectedProfile == null) {
426  MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
427  "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
428  panel.getProfileName()));
429  return;
430  }
431  panel.saveSettings();
432  load();
433  } else if (option == JOptionPane.CANCEL_OPTION) {
434  if (selectedProfile == null) {
435  // for new profiles, if user canlessed a profile create/edit then delete the temp empty profile that was created.
436  // Otherwise it will remain in "config/ModuleSettings/IngestSettings" and then will get loaded
437  // next time we open ProfilePanel(), causing an NPE (JIRA-8404). This only needs to be done when creating
438  // a new ingest profile. If user cancelled editing of an existing profile, then we should not delete
439  // that profile.
440  IngestProfile.deleteProfile(panel.getIngestProfileName());
441  }
442  }
443  }
444 
445  @Override
446  public void saveSettings() {
447  }
448 
449  @Override
450  public void store() {
451  }
452 
456  @Override
457  public void load() {
458  int currentIndex = this.profileList.getSelectedIndex();
459  this.profilesListModel.clear();
460  this.profiles = new TreeMap<>();
461  for (IngestProfile profile : IngestProfiles.getIngestProfiles()) {
462  profilesListModel.addElement(profile);
463  profiles.put(profile.getName(), profile);
464  }
465  if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
466  currentIndex = 0;
467  }
468  refreshButtons();
469  this.profileList.setSelectedIndex(currentIndex);
470  }
471 
472  private final class ProfileListSelectionListener implements ListSelectionListener {
473 
474  @Override
475  public void valueChanged(ListSelectionEvent e) {
476  if (e.getValueIsAdjusting()) {
477  return;
478  }
479  // Get the selected interesting files set and populate the set
480  // components.
481  IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
482  refreshButtons();
483  if (selectedProfile != null) {
484  profileDescArea.setText(selectedProfile.getDescription());
485  filterNameText.setText(selectedProfile.getFileIngestFilter());
486  try {
487  Map<String, FilesSet> fileIngestFilters = FilesSetsManager.getInstance().getCustomFileIngestFilters();
489  fileIngestFilters.put(fSet.getName(), fSet);
490  }
491  String selectedFilter = selectedProfile.getFileIngestFilter();
492  if (selectedFilter == null) {
493  filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
494  } else {
495  filterDescArea.setText(fileIngestFilters.get(selectedFilter).getDescription());
496  }
498  filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
499  }
500  selectedModulesArea.setText("");
501  for (String moduleName : IngestJobSettings.getEnabledModules(IngestProfiles.getExecutionContext(selectedProfile.getName()))) {
502  selectedModulesArea.append(moduleName + "\n");
503  }
504  }
505  }
506  }
507 
508  // Variables declaration - do not modify//GEN-BEGIN:variables
509  private javax.swing.JPanel buttonEnclosingPanel;
510  private javax.swing.JButton deleteProfileButton;
511  private javax.swing.JButton editProfileButton;
512  private javax.swing.JTextArea filterDescArea;
513  private javax.swing.JScrollPane filterDescPane;
514  private javax.swing.JLabel filterNameLabel;
515  private javax.swing.JLabel filterNameText;
516  private javax.swing.JScrollPane infoScrollPane;
517  private javax.swing.JTextArea infoTextArea;
518  private javax.swing.JLabel ingestWarningLabel;
519  private javax.swing.JSeparator jSeparator2;
520  private javax.swing.JButton newProfileButton;
521  private javax.swing.JTextArea profileDescArea;
522  private javax.swing.JLabel profileDescLabel;
523  private javax.swing.JScrollPane profileDescPane;
524  private javax.swing.JList<IngestProfile> profileList;
525  private javax.swing.JLabel profileListLabel;
526  private javax.swing.JScrollPane profileListPane;
527  private javax.swing.JTextArea selectedModulesArea;
528  private javax.swing.JLabel selectedModulesLabel;
529  private javax.swing.JScrollPane selectedModulesPane;
530  // End of variables declaration//GEN-END:variables
531 }

Copyright © 2012-2022 Basis Technology. Generated on: Thu Sep 29 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.