Autopsy  4.1
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-2017 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 
38 class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
39 
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."
53  })
54 
55  private final DefaultListModel<IngestProfile> profilesListModel;
56  private Map<String, IngestProfile> profiles;
57  private ProfilePanel panel;
58  private boolean canBeEnabled; //if something can be enabled ingest is not running
59  private int option = JOptionPane.CANCEL_OPTION;
63  ProfileSettingsPanel() {
64  this.profilesListModel = new DefaultListModel<>();
65  initComponents();
66  this.profileList.setModel(profilesListModel);
67  this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener());
68  ingestWarningLabel.setVisible(false);
69  canBeEnabled = !IngestManager.getInstance().isIngestRunning();
70  refreshButtons();
71  }
72 
78  @SuppressWarnings("unchecked")
79  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
80  private void initComponents() {
81 
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();
102 
103  setBorder(javax.swing.BorderFactory.createEtchedBorder());
104  setPreferredSize(new java.awt.Dimension(800, 488));
105 
106  profileList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
107  profileListPane.setViewportView(profileList);
108 
109  org.openide.awt.Mnemonics.setLocalizedText(profileListLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.profileListLabel.text")); // NOI18N
110 
111  newProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
112  org.openide.awt.Mnemonics.setLocalizedText(newProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.newProfileButton.text")); // NOI18N
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);
120  }
121  });
122 
123  editProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
124  org.openide.awt.Mnemonics.setLocalizedText(editProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.editProfileButton.text")); // NOI18N
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);
132  }
133  });
134 
135  deleteProfileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
136  org.openide.awt.Mnemonics.setLocalizedText(deleteProfileButton, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.deleteProfileButton.text")); // NOI18N
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);
144  }
145  });
146 
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);
155 
156  org.openide.awt.Mnemonics.setLocalizedText(profileDescLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.profileDescLabel.text")); // NOI18N
157 
158  org.openide.awt.Mnemonics.setLocalizedText(filterNameLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.filterNameLabel.text")); // NOI18N
159  filterNameLabel.setMinimumSize(new java.awt.Dimension(30, 14));
160  filterNameLabel.setPreferredSize(new java.awt.Dimension(30, 14));
161 
162  filterNameText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
163  filterNameText.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
164 
165  filterDescPane.setAutoscrolls(true);
166 
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);
175 
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);
183 
184  org.openide.awt.Mnemonics.setLocalizedText(selectedModulesLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.selectedModulesLabel.text")); // NOI18N
185 
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"))); // NOI18N
188  org.openide.awt.Mnemonics.setLocalizedText(ingestWarningLabel, org.openide.util.NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.ingestWarningLabel.text")); // NOI18N
189 
190  jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
191 
192  jScrollPane2.setFont(jScrollPane2.getFont().deriveFont(jScrollPane2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
193 
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")); // NOI18N
201  infoTextArea.setWrapStyleWord(true);
202  jScrollPane2.setViewportView(infoTextArea);
203 
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()
209  .addContainerGap()
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))
222  .addGap(6, 6, 6))
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()
229  .addGap(6, 6, 6)
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()
237  .addGap(8, 8, 8)
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()
245  .addGap(10, 10, 10)
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)
251  .addGap(0, 0, 0)
252  .addComponent(filterNameText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
253  .addContainerGap())
254  .addGroup(layout.createSequentialGroup()
255  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256  .addComponent(selectedModulesLabel)
257  .addContainerGap())))
258  );
259 
260  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteProfileButton, editProfileButton, newProfileButton});
261 
262  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane2, profileListPane});
263 
264  layout.setVerticalGroup(
265  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
266  .addGroup(layout.createSequentialGroup()
267  .addContainerGap()
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)
291  .addGap(0, 0, 0)))
292  .addGap(6, 6, 6)
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))
298  .addGap(6, 6, 6))
299  .addComponent(jSeparator2)))
300  );
301  }// </editor-fold>//GEN-END:initComponents
302 
303  private void newProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newProfileButtonActionPerformed
304  doProfileDialog(null);
305  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
306  }//GEN-LAST:event_newProfileButtonActionPerformed
307 
308  private void deleteProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteProfileButtonActionPerformed
309  IngestProfile selectedProfile = this.profileList.getSelectedValue();
310  this.profilesListModel.removeElement(selectedProfile);
311  profiles.remove(selectedProfile.getName());
312  IngestProfile.deleteProfile(selectedProfile);
313 
314  // Select the first of the remaining set definitions. This will cause
315  // the selection listeners to repopulate the subordinate components.
316  this.resetComponents();
317  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
318  }//GEN-LAST:event_deleteProfileButtonActionPerformed
319 
326  void enableButtons(boolean isEnabled) {
327  canBeEnabled = isEnabled; //update value of canBeEnabled to be used by refresh
328  refreshButtons();
329  ingestWarningLabel.setVisible(!canBeEnabled);
330  }
331 
335  private void resetComponents() {
336  if (!this.profilesListModel.isEmpty()) {
337  this.profileList.setSelectedIndex(0);
338  } else {
339  this.profilesListModel.clear();
340  this.profileDescArea.setText("");
341  this.filterDescArea.setText("");
342  this.filterNameText.setText("");
343  this.selectedModulesArea.setText("");
344  }
345  refreshButtons();
346  }
347 
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);
358 
359  }
360 
361 
362  private void editProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editProfileButtonActionPerformed
363  IngestProfile selectedProfile = profileList.getSelectedValue();
364  doProfileDialog(selectedProfile);
365  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
366  }//GEN-LAST:event_editProfileButtonActionPerformed
367 
373  private void doProfileDialog(IngestProfile selectedProfile) {
374  // Create a files set defintion panel.
375  final AdvancedConfigurationDialog dialog = new AdvancedConfigurationDialog(true);
376  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
377  //start wait cursor for ingest job settings construction
378  if (selectedProfile != null) {
379  // Editing an existing set definition.
380  panel = new ProfilePanel(selectedProfile);
381  } else {
382  // Creating a new set definition.
383  panel = new ProfilePanel();
384  }
385  dialog.addApplyButtonListener(
386  (ActionEvent e) -> {
387  panel.store();
388  option = JOptionPane.OK_OPTION;
389  dialog.close();
390  }
391  );
392 
393 
394  //end wait Cursor for ingest job settings construction
395  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
396  // Do a dialog box with the profilePanel till the user enters a name or chooses cancel
397  do {
398  option = JOptionPane.CANCEL_OPTION;
399  dialog.display(panel);
400  } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
401 
402  if (option == JOptionPane.OK_OPTION) {
403 
404  // While adding new profile(selectedPRofile == null), if a profile with same name already exists, do not add to the profiles hashMap.
405  // In case of editing an existing profile(selectedProfile != null), following check is not performed.
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()));
410  return;
411  }
412  panel.saveSettings();
413  load();
414  }
415  }
416 
417  @Override
418  public void saveSettings() {
419  }
420 
421  @Override
422  public void store() {
423  }
424 
428  @Override
429  public void load() {
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);
436  }
437  if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
438  currentIndex = 0;
439  }
440  refreshButtons();
441  this.profileList.setSelectedIndex(currentIndex);
442  }
443 
444  private final class ProfileListSelectionListener implements ListSelectionListener {
445 
446  @Override
447  public void valueChanged(ListSelectionEvent e) {
448  if (e.getValueIsAdjusting()) {
449  return;
450  }
451  // Get the selected interesting files set and populate the set
452  // components.
453  IngestProfile selectedProfile = ProfileSettingsPanel.this.profileList.getSelectedValue();
454  refreshButtons();
455  if (selectedProfile != null) {
456  profileDescArea.setText(selectedProfile.getDescription());
457  filterNameText.setText(selectedProfile.getFileIngestFilter());
458  try {
459  Map<String, FilesSet> fileIngestFilters = FilesSetsManager.getInstance().getCustomFileIngestFilters();
461  fileIngestFilters.put(fSet.getName(), fSet);
462  }
463  filterDescArea.setText(fileIngestFilters.get(selectedProfile.getFileIngestFilter()).getDescription());
465  filterDescArea.setText(NbBundle.getMessage(ProfileSettingsPanel.class, "ProfileSettingsPanel.messages.filterLoadFailed"));
466  }
467  selectedModulesArea.setText("");
468  for (String moduleName : IngestJobSettings.getEnabledModules(selectedProfile.getName())) {
469  selectedModulesArea.append(moduleName + "\n");
470  }
471  }
472  }
473  }
474 
475  // Variables declaration - do not modify//GEN-BEGIN:variables
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;
490  private javax.swing.JList<IngestProfile> profileList;
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;
496  // End of variables declaration//GEN-END:variables
497 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.