Autopsy  4.12.0
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  jScrollPane2 = 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.setFont(ingestWarningLabel.getFont().deriveFont(ingestWarningLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
155  ingestWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/hashdatabase/warning16.png"))); // NOI18N
156  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.ingestWarningLabel.text")); // NOI18N
157 
158  jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
159 
160  jScrollPane2.setFont(jScrollPane2.getFont().deriveFont(jScrollPane2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
161 
162  infoTextArea.setEditable(false);
163  infoTextArea.setBackground(new java.awt.Color(240, 240, 240));
164  infoTextArea.setColumns(20);
165  infoTextArea.setFont(infoTextArea.getFont().deriveFont(infoTextArea.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
166  infoTextArea.setLineWrap(true);
167  infoTextArea.setRows(3);
168  infoTextArea.setText(org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.infoTextArea.text")); // NOI18N
169  infoTextArea.setWrapStyleWord(true);
170  jScrollPane2.setViewportView(infoTextArea);
171 
172  editProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
173  org.openide.awt.Mnemonics.setLocalizedText(editProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.editProfileButton.text")); // NOI18N
174  editProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
175  editProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
176  editProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
177  editProfileButton.addActionListener(new java.awt.event.ActionListener() {
178  public void actionPerformed(java.awt.event.ActionEvent evt) {
179  editProfileButtonActionPerformed(evt);
180  }
181  });
182 
183  newProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
184  org.openide.awt.Mnemonics.setLocalizedText(newProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.newProfileButton.text")); // NOI18N
185  newProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
186  newProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
187  newProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
188  newProfileButton.addActionListener(new java.awt.event.ActionListener() {
189  public void actionPerformed(java.awt.event.ActionEvent evt) {
190  newProfileButtonActionPerformed(evt);
191  }
192  });
193 
194  deleteProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
195  org.openide.awt.Mnemonics.setLocalizedText(deleteProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.deleteProfileButton.text")); // NOI18N
196  deleteProfileButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
197  deleteProfileButton.setMaximumSize(new java.awt.Dimension(111, 25));
198  deleteProfileButton.setMinimumSize(new java.awt.Dimension(111, 25));
199  deleteProfileButton.addActionListener(new java.awt.event.ActionListener() {
200  public void actionPerformed(java.awt.event.ActionEvent evt) {
201  deleteProfileButtonActionPerformed(evt);
202  }
203  });
204 
205  javax.swing.GroupLayout buttonEnclosingPanelLayout = new javax.swing.GroupLayout(buttonEnclosingPanel);
206  buttonEnclosingPanel.setLayout(buttonEnclosingPanelLayout);
207  buttonEnclosingPanelLayout.setHorizontalGroup(
208  buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
209  .addGroup(buttonEnclosingPanelLayout.createSequentialGroup()
210  .addContainerGap()
211  .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
212  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
213  .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
214  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
215  .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
216  .addContainerGap())
217  );
218 
219  buttonEnclosingPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteProfileButton, editProfileButton, newProfileButton});
220 
221  buttonEnclosingPanelLayout.setVerticalGroup(
222  buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223  .addGroup(buttonEnclosingPanelLayout.createSequentialGroup()
224  .addContainerGap()
225  .addGroup(buttonEnclosingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
226  .addComponent(newProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
227  .addComponent(editProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
228  .addComponent(deleteProfileButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
229  .addContainerGap())
230  );
231 
232  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
233  this.setLayout(layout);
234  layout.setHorizontalGroup(
235  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236  .addGroup(layout.createSequentialGroup()
237  .addContainerGap()
238  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
240  .addGroup(layout.createSequentialGroup()
241  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
242  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
243  .addComponent(profileListLabel))
244  .addGap(6, 6, 6))
245  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
246  .addComponent(profileListPane, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
247  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
248  .addGroup(layout.createSequentialGroup()
249  .addComponent(buttonEnclosingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
250  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
251  .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
252  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
253  .addGroup(layout.createSequentialGroup()
254  .addGap(6, 6, 6)
255  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256  .addGroup(layout.createSequentialGroup()
257  .addComponent(profileDescLabel)
258  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
259  .addGroup(layout.createSequentialGroup()
260  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
261  .addGroup(layout.createSequentialGroup()
262  .addGap(8, 8, 8)
263  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
264  .addGroup(layout.createSequentialGroup()
265  .addComponent(ingestWarningLabel)
266  .addGap(0, 0, Short.MAX_VALUE))
267  .addComponent(profileDescPane, javax.swing.GroupLayout.Alignment.TRAILING)
268  .addComponent(selectedModulesPane, javax.swing.GroupLayout.Alignment.TRAILING)))
269  .addGroup(layout.createSequentialGroup()
270  .addGap(10, 10, 10)
271  .addComponent(filterDescPane)))
272  .addContainerGap())))
273  .addGroup(layout.createSequentialGroup()
274  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
275  .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
276  .addGap(0, 0, 0)
277  .addComponent(filterNameText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
278  .addContainerGap())
279  .addGroup(layout.createSequentialGroup()
280  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
281  .addComponent(selectedModulesLabel)
282  .addContainerGap())))
283  );
284 
285  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonEnclosingPanel, jScrollPane2, profileListPane});
286 
287  layout.setVerticalGroup(
288  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289  .addGroup(layout.createSequentialGroup()
290  .addContainerGap()
291  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292  .addGroup(layout.createSequentialGroup()
293  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294  .addGroup(layout.createSequentialGroup()
295  .addComponent(profileDescLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
296  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
297  .addComponent(profileDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
298  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
299  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
300  .addComponent(filterNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
301  .addComponent(filterNameText, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
302  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
303  .addComponent(filterDescPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
304  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
305  .addComponent(selectedModulesLabel)
306  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
307  .addComponent(selectedModulesPane, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE))
308  .addGroup(layout.createSequentialGroup()
309  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
310  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
311  .addComponent(profileListLabel)
312  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
313  .addComponent(profileListPane, javax.swing.GroupLayout.DEFAULT_SIZE, 332, Short.MAX_VALUE)))
314  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
315  .addGroup(layout.createSequentialGroup()
316  .addGap(11, 11, 11)
317  .addComponent(ingestWarningLabel))
318  .addGroup(layout.createSequentialGroup()
319  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
320  .addComponent(buttonEnclosingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
321  .addContainerGap())
322  .addComponent(jSeparator2)))
323  );
324  }// </editor-fold>//GEN-END:initComponents
325 
326  private void newProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newProfileButtonActionPerformed
327  doProfileDialog(null);
328  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
329  }//GEN-LAST:event_newProfileButtonActionPerformed
330 
331  private void deleteProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteProfileButtonActionPerformed
332  IngestProfile selectedProfile = this.profileList.getSelectedValue();
333  this.profilesListModel.removeElement(selectedProfile);
334  profiles.remove(selectedProfile.getName());
335  IngestProfile.deleteProfile(selectedProfile);
336 
337  // Select the first of the remaining set definitions. This will cause
338  // the selection listeners to repopulate the subordinate components.
339  this.resetComponents();
340  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
341  }//GEN-LAST:event_deleteProfileButtonActionPerformed
342 
349  void enableButtons(boolean isEnabled) {
350  canBeEnabled = isEnabled; //update value of canBeEnabled to be used by refresh
351  refreshButtons();
352  ingestWarningLabel.setVisible(!canBeEnabled);
353  }
354 
358  private void resetComponents() {
359  if (!this.profilesListModel.isEmpty()) {
360  this.profileList.setSelectedIndex(0);
361  } else {
362  this.profilesListModel.clear();
363  this.profileDescArea.setText("");
364  this.filterDescArea.setText("");
365  this.filterNameText.setText("");
366  this.selectedModulesArea.setText("");
367  }
368  refreshButtons();
369  }
370 
375  private void refreshButtons() {
376  IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
377  boolean profileIsSelected = (selectedProfile != null);
378  newProfileButton.setEnabled(canBeEnabled);
379  editProfileButton.setEnabled(canBeEnabled && profileIsSelected);
380  deleteProfileButton.setEnabled(canBeEnabled && profileIsSelected);
381 
382  }
383 
384 
385  private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editProfileButtonActionPerformed
386  IngestProfile selectedProfile = profileList.getSelectedValue();
387  doProfileDialog(selectedProfile);
388  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
389  }//GEN-LAST:event_editProfileButtonActionPerformed
390 
396  private void doProfileDialog(IngestProfile selectedProfile) {
397  // Create a files set defintion panel.
398  final AdvancedConfigurationDialog dialog = new AdvancedConfigurationDialog(true);
399  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
400  //start wait cursor for ingest job settings construction
401  if (selectedProfile != null) {
402  // Editing an existing set definition.
403  panel = new ProfilePanel(selectedProfile);
404  } else {
405  // Creating a new set definition.
406  panel = new ProfilePanel();
407  }
408  dialog.addApplyButtonListener(
409  (ActionEvent e) -> {
410  panel.store();
411  option = JOptionPane.OK_OPTION;
412  dialog.close();
413  }
414  );
415 
416 
417  //end wait Cursor for ingest job settings construction
418  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
419  // Do a dialog box with the profilePanel till the user enters a name or chooses cancel
420  do {
421  option = JOptionPane.CANCEL_OPTION;
422  dialog.display(panel);
423  } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
424 
425  if (option == JOptionPane.OK_OPTION) {
426 
427  // While adding new profile(selectedPRofile == null), if a profile with same name already exists, do not add to the profiles hashMap.
428  // In case of editing an existing profile(selectedProfile != null), following check is not performed.
429  if (this.profiles.containsKey(panel.getProfileName()) && selectedProfile == null) {
430  MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
431  "ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
432  panel.getProfileName()));
433  return;
434  }
435  panel.saveSettings();
436  load();
437  }
438  }
439 
440  @Override
441  public void saveSettings() {
442  }
443 
444  @Override
445  public void store() {
446  }
447 
451  @Override
452  public void load() {
453  int currentIndex = this.profileList.getSelectedIndex();
454  this.profilesListModel.clear();
455  this.profiles = new TreeMap<>();
456  for (IngestProfile profile : IngestProfiles.getIngestProfiles()) {
457  profilesListModel.addElement(profile);
458  profiles.put(profile.getName(), profile);
459  }
460  if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
461  currentIndex = 0;
462  }
463  refreshButtons();
464  this.profileList.setSelectedIndex(currentIndex);
465  }
466 
467  private final class ProfileListSelectionListener implements ListSelectionListener {
468 
469  @Override
470  public void valueChanged(ListSelectionEvent e) {
471  if (e.getValueIsAdjusting()) {
472  return;
473  }
474  // Get the selected interesting files set and populate the set
475  // components.
476  IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
477  refreshButtons();
478  if (selectedProfile != null) {
479  profileDescArea.setText(selectedProfile.getDescription());
480  filterNameText.setText(selectedProfile.getFileIngestFilter());
481  try {
482  Map<String, FilesSet> fileIngestFilters = FilesSetsManager.getInstance().getCustomFileIngestFilters();
484  fileIngestFilters.put(fSet.getName(), fSet);
485  }
486  filterDescArea.setText(fileIngestFilters.get(selectedProfile.getFileIngestFilter()).getDescription());
488  filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
489  }
490  selectedModulesArea.setText("");
491  for (String moduleName : IngestJobSettings.getEnabledModules(selectedProfile.getName())) {
492  selectedModulesArea.append(moduleName + "\n");
493  }
494  }
495  }
496  }
497 
498  // Variables declaration - do not modify//GEN-BEGIN:variables
499  private javax.swing.JPanel buttonEnclosingPanel;
500  private javax.swing.JButton deleteProfileButton;
501  private javax.swing.JButton editProfileButton;
502  private javax.swing.JTextArea filterDescArea;
503  private javax.swing.JScrollPane filterDescPane;
504  private javax.swing.JLabel filterNameLabel;
505  private javax.swing.JLabel filterNameText;
506  private javax.swing.JTextArea infoTextArea;
507  private javax.swing.JLabel ingestWarningLabel;
508  private javax.swing.JScrollPane jScrollPane2;
509  private javax.swing.JSeparator jSeparator2;
510  private javax.swing.JButton newProfileButton;
511  private javax.swing.JTextArea profileDescArea;
512  private javax.swing.JLabel profileDescLabel;
513  private javax.swing.JScrollPane profileDescPane;
514  private javax.swing.JList<IngestProfile> profileList;
515  private javax.swing.JLabel profileListLabel;
516  private javax.swing.JScrollPane profileListPane;
517  private javax.swing.JTextArea selectedModulesArea;
518  private javax.swing.JLabel selectedModulesLabel;
519  private javax.swing.JScrollPane selectedModulesPane;
520  // End of variables declaration//GEN-END:variables
521 }

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.