Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
TagOptionsPanel.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.casemodule.services;
20 
21 import java.awt.EventQueue;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.HashSet;
25 import java.util.Set;
26 import java.util.TreeSet;
27 import java.util.logging.Level;
28 import javax.swing.DefaultListModel;
29 import javax.swing.JOptionPane;
30 import javax.swing.event.ListSelectionEvent;
31 import org.netbeans.spi.options.OptionsPanelController;
32 import org.openide.util.NbBundle;
33 import org.openide.util.NbBundle.Messages;
38 import org.sleuthkit.datamodel.TagName;
39 import org.sleuthkit.datamodel.TskData;
41 
45 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
46 final class TagOptionsPanel extends javax.swing.JPanel implements OptionsPanel {
47 
48  private static final long serialVersionUID = 1L;
49  private static final TagName.HTML_COLOR DEFAULT_COLOR = TagName.HTML_COLOR.NONE;
50  private final DefaultListModel<TagNameDefinition> tagTypesListModel;
51  private Set<TagNameDefinition> tagTypes;
52  private IngestJobEventPropertyChangeListener ingestJobEventsListener;
53  private Set<String> updatedStatusTags;
54 
58  TagOptionsPanel() {
59  tagTypesListModel = new DefaultListModel<>();
60  tagTypes = new TreeSet<>(TagNameDefinition.getTagNameDefinitions());
61  updatedStatusTags = new HashSet<>();
62  initComponents();
63  customizeComponents();
64  }
65 
66  @Messages({"TagOptionsPanel.panelDescriptionTextArea.text=Create and manage tags. "
67  + "Tags can be applied to files and results in the case. Notable tags will cause "
68  + "items tagged with them to be flagged as notable when using a central repository. "
69  + "Changing the status of a tag will only effect items in the current case.",
70  "TagOptionsPanel.ingestRunningWarningLabel.text=Cannot make changes to existing tags when ingest is running!",
71  "TagOptionsPanel.descriptionLabel.text=Tag Description:",
72  "TagOptionsPanel.notableYesOrNoLabel.text=",
73  "TagOptionsPanel.isNotableLabel.text=Tag indicates item is notable: ",
74  "TagOptionsPanel.editTagNameButton.text=Edit Tag"})
75 
76  private void customizeComponents() {
77  tagNamesList.setModel(tagTypesListModel);
78  tagNamesList.addListSelectionListener((ListSelectionEvent event) -> {
79  updatePanel();
80  });
81  addIngestJobEventsListener();
82  }
83 
90  private void addIngestJobEventsListener() {
91  ingestJobEventsListener = new IngestJobEventPropertyChangeListener();
92  IngestManager.getInstance().addIngestJobEventListener(ingestJobEventsListener);
93  }
94 
100  @SuppressWarnings("unchecked")
101  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
102  private void initComponents() {
103 
104  jPanel1 = new javax.swing.JPanel();
105  jScrollPane2 = new javax.swing.JScrollPane();
106  jSplitPane1 = new javax.swing.JSplitPane();
107  modifyTagTypesListPanel = new javax.swing.JPanel();
108  tagTypesListLabel = new javax.swing.JLabel();
109  TagNameScrollPane = new javax.swing.JScrollPane();
110  tagNamesList = new javax.swing.JList<>();
111  newTagNameButton = new javax.swing.JButton();
112  deleteTagNameButton = new javax.swing.JButton();
113  editTagNameButton = new javax.swing.JButton();
114  panelDescriptionScrollPane = new javax.swing.JScrollPane();
115  panelDescriptionTextArea = new javax.swing.JTextArea();
116  tagTypesAdditionalPanel = new javax.swing.JPanel();
117  descriptionLabel = new javax.swing.JLabel();
118  descriptionScrollPane = new javax.swing.JScrollPane();
119  descriptionTextArea = new javax.swing.JTextArea();
120  isNotableLabel = new javax.swing.JLabel();
121  notableYesOrNoLabel = new javax.swing.JLabel();
122  ingestRunningWarningLabel = new javax.swing.JLabel();
123 
124  jPanel1.setPreferredSize(new java.awt.Dimension(750, 490));
125 
126  jScrollPane2.setPreferredSize(new java.awt.Dimension(750, 490));
127 
128  jSplitPane1.setDividerLocation(450);
129  jSplitPane1.setDividerSize(1);
130  jSplitPane1.setPreferredSize(new java.awt.Dimension(748, 488));
131 
132  org.openide.awt.Mnemonics.setLocalizedText(tagTypesListLabel, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.tagTypesListLabel.text")); // NOI18N
133 
134  tagNamesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
135  TagNameScrollPane.setViewportView(tagNamesList);
136 
137  newTagNameButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add-tag.png"))); // NOI18N
138  org.openide.awt.Mnemonics.setLocalizedText(newTagNameButton, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.newTagNameButton.text")); // NOI18N
139  newTagNameButton.setMaximumSize(new java.awt.Dimension(111, 25));
140  newTagNameButton.setMinimumSize(new java.awt.Dimension(111, 25));
141  newTagNameButton.setPreferredSize(new java.awt.Dimension(111, 25));
142  newTagNameButton.addActionListener(new java.awt.event.ActionListener() {
143  public void actionPerformed(java.awt.event.ActionEvent evt) {
144  newTagNameButtonActionPerformed(evt);
145  }
146  });
147 
148  deleteTagNameButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete-tag.png"))); // NOI18N
149  org.openide.awt.Mnemonics.setLocalizedText(deleteTagNameButton, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.deleteTagNameButton.text")); // NOI18N
150  deleteTagNameButton.setMaximumSize(new java.awt.Dimension(111, 25));
151  deleteTagNameButton.setMinimumSize(new java.awt.Dimension(111, 25));
152  deleteTagNameButton.setPreferredSize(new java.awt.Dimension(111, 25));
153  deleteTagNameButton.addActionListener(new java.awt.event.ActionListener() {
154  public void actionPerformed(java.awt.event.ActionEvent evt) {
155  deleteTagNameButtonActionPerformed(evt);
156  }
157  });
158 
159  editTagNameButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit-tag.png"))); // NOI18N
160  org.openide.awt.Mnemonics.setLocalizedText(editTagNameButton, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.editTagNameButton.text")); // NOI18N
161  editTagNameButton.setMaximumSize(new java.awt.Dimension(111, 25));
162  editTagNameButton.setMinimumSize(new java.awt.Dimension(111, 25));
163  editTagNameButton.setPreferredSize(new java.awt.Dimension(111, 25));
164  editTagNameButton.addActionListener(new java.awt.event.ActionListener() {
165  public void actionPerformed(java.awt.event.ActionEvent evt) {
166  editTagNameButtonActionPerformed(evt);
167  }
168  });
169 
170  panelDescriptionTextArea.setEditable(false);
171  panelDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
172  panelDescriptionTextArea.setColumns(20);
173  panelDescriptionTextArea.setLineWrap(true);
174  panelDescriptionTextArea.setRows(3);
175  panelDescriptionTextArea.setText(org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.panelDescriptionTextArea.text")); // NOI18N
176  panelDescriptionTextArea.setWrapStyleWord(true);
177  panelDescriptionTextArea.setFocusable(false);
178  panelDescriptionTextArea.setOpaque(false);
179  panelDescriptionScrollPane.setViewportView(panelDescriptionTextArea);
180 
181  javax.swing.GroupLayout modifyTagTypesListPanelLayout = new javax.swing.GroupLayout(modifyTagTypesListPanel);
182  modifyTagTypesListPanel.setLayout(modifyTagTypesListPanelLayout);
183  modifyTagTypesListPanelLayout.setHorizontalGroup(
184  modifyTagTypesListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185  .addGroup(modifyTagTypesListPanelLayout.createSequentialGroup()
186  .addContainerGap()
187  .addGroup(modifyTagTypesListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
188  .addComponent(tagTypesListLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
189  .addGroup(modifyTagTypesListPanelLayout.createSequentialGroup()
190  .addComponent(newTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
191  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
192  .addComponent(editTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
193  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
194  .addComponent(deleteTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
195  .addComponent(TagNameScrollPane)
196  .addComponent(panelDescriptionScrollPane))
197  .addContainerGap())
198  );
199 
200  modifyTagTypesListPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteTagNameButton, editTagNameButton, newTagNameButton});
201 
202  modifyTagTypesListPanelLayout.setVerticalGroup(
203  modifyTagTypesListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204  .addGroup(modifyTagTypesListPanelLayout.createSequentialGroup()
205  .addGap(10, 10, 10)
206  .addComponent(panelDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
207  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208  .addComponent(tagTypesListLabel)
209  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
210  .addComponent(TagNameScrollPane)
211  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
212  .addGroup(modifyTagTypesListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
213  .addComponent(newTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
214  .addComponent(editTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
215  .addComponent(deleteTagNameButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
216  .addContainerGap())
217  );
218 
219  modifyTagTypesListPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deleteTagNameButton, editTagNameButton, newTagNameButton});
220 
221  jSplitPane1.setLeftComponent(modifyTagTypesListPanel);
222 
223  org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.descriptionLabel.text")); // NOI18N
224 
225  descriptionTextArea.setEditable(false);
226  descriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
227  descriptionTextArea.setColumns(20);
228  descriptionTextArea.setLineWrap(true);
229  descriptionTextArea.setRows(5);
230  descriptionTextArea.setWrapStyleWord(true);
231  descriptionTextArea.setFocusable(false);
232  descriptionTextArea.setOpaque(false);
233  descriptionScrollPane.setViewportView(descriptionTextArea);
234 
235  org.openide.awt.Mnemonics.setLocalizedText(isNotableLabel, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.isNotableLabel.text")); // NOI18N
236 
237  org.openide.awt.Mnemonics.setLocalizedText(notableYesOrNoLabel, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.notableYesOrNoLabel.text")); // NOI18N
238 
239  ingestRunningWarningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/modules/filetypeid/warning16.png"))); // NOI18N
240  org.openide.awt.Mnemonics.setLocalizedText(ingestRunningWarningLabel, org.openide.util.NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.ingestRunningWarningLabel.text")); // NOI18N
241 
242  javax.swing.GroupLayout tagTypesAdditionalPanelLayout = new javax.swing.GroupLayout(tagTypesAdditionalPanel);
243  tagTypesAdditionalPanel.setLayout(tagTypesAdditionalPanelLayout);
244  tagTypesAdditionalPanelLayout.setHorizontalGroup(
245  tagTypesAdditionalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246  .addGroup(tagTypesAdditionalPanelLayout.createSequentialGroup()
247  .addContainerGap()
248  .addGroup(tagTypesAdditionalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249  .addComponent(descriptionScrollPane)
250  .addGroup(tagTypesAdditionalPanelLayout.createSequentialGroup()
251  .addGroup(tagTypesAdditionalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
252  .addComponent(descriptionLabel)
253  .addGroup(tagTypesAdditionalPanelLayout.createSequentialGroup()
254  .addComponent(isNotableLabel)
255  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
256  .addComponent(notableYesOrNoLabel))
257  .addComponent(ingestRunningWarningLabel))
258  .addGap(0, 0, Short.MAX_VALUE)))
259  .addContainerGap())
260  );
261  tagTypesAdditionalPanelLayout.setVerticalGroup(
262  tagTypesAdditionalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
263  .addGroup(tagTypesAdditionalPanelLayout.createSequentialGroup()
264  .addContainerGap()
265  .addComponent(descriptionLabel)
266  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
267  .addComponent(descriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
268  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
269  .addGroup(tagTypesAdditionalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
270  .addComponent(isNotableLabel)
271  .addComponent(notableYesOrNoLabel))
272  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 292, Short.MAX_VALUE)
273  .addComponent(ingestRunningWarningLabel)
274  .addGap(31, 31, 31))
275  );
276 
277  jSplitPane1.setRightComponent(tagTypesAdditionalPanel);
278 
279  jScrollPane2.setViewportView(jSplitPane1);
280 
281  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
282  jPanel1.setLayout(jPanel1Layout);
283  jPanel1Layout.setHorizontalGroup(
284  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
285  .addGroup(jPanel1Layout.createSequentialGroup()
286  .addGap(0, 0, 0)
287  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
288  .addGap(0, 0, 0))
289  );
290  jPanel1Layout.setVerticalGroup(
291  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292  .addGroup(jPanel1Layout.createSequentialGroup()
293  .addGap(0, 0, 0)
294  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
295  .addGap(0, 0, 0))
296  );
297 
298  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
299  this.setLayout(layout);
300  layout.setHorizontalGroup(
301  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
302  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
303  );
304  layout.setVerticalGroup(
305  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
306  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
307  );
308  }// </editor-fold>//GEN-END:initComponents
309 
310  @Messages({"TagOptionsPanel.TagNameDialog.tagNameAlreadyExists.message=Tag name must be unique. A tag with this name already exists.",
311  "TagOptionsPanel.TagNameDialog.tagNameAlreadyExists.title=Duplicate Tag Name"})
312 
313  private void newTagNameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newTagNameButtonActionPerformed
314  TagNameDialog dialog = new TagNameDialog();
315  TagNameDialog.BUTTON_PRESSED result = dialog.getResult();
316  if (result == TagNameDialog.BUTTON_PRESSED.OK) {
317  TskData.FileKnown status = dialog.isTagNotable() ? TskData.FileKnown.BAD : TskData.FileKnown.UNKNOWN;
318  TagNameDefinition newTagType = new TagNameDefinition(dialog.getTagName(), dialog.getTagDesciption(), DEFAULT_COLOR, status);
319  /*
320  * If tag name already exists, don't add the tag name.
321  */
322  if (!tagTypes.contains(newTagType)) {
323  tagTypes.add(newTagType);
324  updateTagNamesListModel();
325  tagNamesList.setSelectedValue(newTagType, true);
326  updatePanel();
327  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
328  } else {
329  JOptionPane.showMessageDialog(this,
330  NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.TagNameDialog.tagNameAlreadyExists.message"),
331  NbBundle.getMessage(TagOptionsPanel.class, "TagOptionsPanel.TagNameDialog.tagNameAlreadyExists.title"),
332  JOptionPane.INFORMATION_MESSAGE);
333  }
334  }
335  }//GEN-LAST:event_newTagNameButtonActionPerformed
336 
337  private void deleteTagNameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteTagNameButtonActionPerformed
338  TagNameDefinition tagName = tagNamesList.getSelectedValue();
339  tagTypes.remove(tagName);
340  updateTagNamesListModel();
341  updatePanel();
342  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
343 
344  }//GEN-LAST:event_deleteTagNameButtonActionPerformed
345 
346  private void editTagNameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editTagNameButtonActionPerformed
347  TagNameDefinition originalTagName = tagNamesList.getSelectedValue();
348  TagNameDialog dialog = new TagNameDialog(originalTagName);
349  TagNameDialog.BUTTON_PRESSED result = dialog.getResult();
350  if (result == TagNameDialog.BUTTON_PRESSED.OK) {
351  TskData.FileKnown status = dialog.isTagNotable() ? TskData.FileKnown.BAD : TskData.FileKnown.UNKNOWN;
352  TagNameDefinition newTagType = new TagNameDefinition(dialog.getTagName(), dialog.getTagDesciption(), DEFAULT_COLOR, status);
353  /*
354  * If tag name already exists, don't add the tag name.
355  */
356  tagTypes.remove(originalTagName);
357  tagTypes.add(newTagType);
358  updateTagNamesListModel();
359  tagNamesList.setSelectedValue(newTagType, true);
360  updatePanel();
361  firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
362  if (originalTagName.getKnownStatus() != newTagType.getKnownStatus() && Case.isCaseOpen()) {
363  updatedStatusTags.add(newTagType.getDisplayName());
364  }
365  }
366  }//GEN-LAST:event_editTagNameButtonActionPerformed
367 
368  // Variables declaration - do not modify//GEN-BEGIN:variables
369  private javax.swing.JScrollPane TagNameScrollPane;
370  private javax.swing.JButton deleteTagNameButton;
371  private javax.swing.JLabel descriptionLabel;
372  private javax.swing.JScrollPane descriptionScrollPane;
373  private javax.swing.JTextArea descriptionTextArea;
374  private javax.swing.JButton editTagNameButton;
375  private javax.swing.JLabel ingestRunningWarningLabel;
376  private javax.swing.JLabel isNotableLabel;
377  private javax.swing.JPanel jPanel1;
378  private javax.swing.JScrollPane jScrollPane2;
379  private javax.swing.JSplitPane jSplitPane1;
380  private javax.swing.JPanel modifyTagTypesListPanel;
381  private javax.swing.JButton newTagNameButton;
382  private javax.swing.JLabel notableYesOrNoLabel;
383  private javax.swing.JScrollPane panelDescriptionScrollPane;
384  private javax.swing.JTextArea panelDescriptionTextArea;
385  private javax.swing.JList<org.sleuthkit.autopsy.casemodule.services.TagNameDefinition> tagNamesList;
386  private javax.swing.JPanel tagTypesAdditionalPanel;
387  private javax.swing.JLabel tagTypesListLabel;
388  // End of variables declaration//GEN-END:variables
389 
393  private void updateTagNamesListModel() {
394  tagTypesListModel.clear();
395  for (TagNameDefinition tagName : tagTypes) {
396  tagTypesListModel.addElement(tagName);
397  }
398  }
399 
403  @Override
404  public void load() {
405  tagTypes = new TreeSet<>(TagNameDefinition.getTagNameDefinitions());
406  updateTagNamesListModel();
407  updatePanel();
408  }
409 
413  @Override
414  public void store() {
415  TagNameDefinition.setTagNameDefinitions(tagTypes);
416  sendStatusChangedEvents();
417  }
418 
419  void cancelChanges() {
420  updatedStatusTags.clear();
421  }
422 
423  private void sendStatusChangedEvents() {
424  for (String modifiedTagDisplayName : updatedStatusTags) {
425  //if user closes their case after options have been changed but before application of them is complete don't notify
426  try {
427  Case.getCurrentCaseThrows().notifyTagDefinitionChanged(modifiedTagDisplayName);
428  } catch (NoCurrentCaseException ex) {
429  Logger.getLogger(TagOptionsPanel.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
430  }
431  }
432  updatedStatusTags.clear();
433  }
434 
439  private void updatePanel() {
440  boolean ingestIsRunning = IngestManager.getInstance().isIngestRunning();
441  /*
442  * Only enable the delete button when there is a tag type selected in
443  * the tag types JList.
444  */
445  ingestRunningWarningLabel.setVisible(ingestIsRunning);
446  boolean isSelected = tagNamesList.getSelectedIndex() != -1;
447  boolean enableEdit = !ingestIsRunning && isSelected;
448  editTagNameButton.setEnabled(enableEdit);
449  deleteTagNameButton.setEnabled(enableEdit);
450  if (isSelected) {
451  descriptionTextArea.setText(tagNamesList.getSelectedValue().getDescription());
452  if (tagNamesList.getSelectedValue().getKnownStatus() == TskData.FileKnown.BAD) {
453  notableYesOrNoLabel.setText("Yes");
454  } else {
455  notableYesOrNoLabel.setText("No");
456  }
457  } else {
458  descriptionTextArea.setText("");
459  notableYesOrNoLabel.setText("");
460  }
461  }
462 
466  @Override
467  @SuppressWarnings("FinalizeDeclaration")
468  protected void finalize() throws Throwable {
469  IngestManager.getInstance().removeIngestJobEventListener(ingestJobEventsListener);
470  super.finalize();
471  }
472 
476  private class IngestJobEventPropertyChangeListener implements PropertyChangeListener {
477 
478  @Override
479  public void propertyChange(PropertyChangeEvent evt) {
480  EventQueue.invokeLater(new Runnable() {
481  @Override
482  public void run() {
483  updatePanel();
484  }
485  });
486  }
487  }
488 }

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