19 package org.sleuthkit.autopsy.centralrepository.persona;
21 import java.awt.Component;
22 import java.awt.event.ActionEvent;
23 import java.text.SimpleDateFormat;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashMap;
27 import java.util.Date;
28 import java.util.List;
30 import java.util.logging.Level;
31 import javax.swing.JButton;
32 import javax.swing.JOptionPane;
33 import javax.swing.JTable;
34 import javax.swing.ListSelectionModel;
35 import javax.swing.event.ListSelectionEvent;
36 import javax.swing.table.DefaultTableModel;
37 import org.apache.commons.lang.StringUtils;
38 import org.openide.windows.TopComponent;
39 import org.openide.util.NbBundle.Messages;
40 import org.openide.windows.RetainLocation;
55 @TopComponent.Description(preferredID =
"PersonaDetailsTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
56 @TopComponent.Registration(mode =
"personadetails", openAtStartup =
false)
57 @RetainLocation(
"personadetails")
58 @SuppressWarnings(
"PMD.SingularField")
61 private static final long serialVersionUID = 1L;
67 private final List<PAccount> accountsToAdd =
new ArrayList<>();
68 private final List<PMetadata> metadataToAdd =
new ArrayList<>();
69 private final List<PAlias> aliasesToAdd =
new ArrayList<>();
71 private final List<PersonaAccount> accountsToRemove =
new ArrayList<>();
72 private final List<PersonaMetadata> metadataToRemove =
new ArrayList<>();
73 private final List<PersonaAlias> aliasesToRemove =
new ArrayList<>();
75 private final Map<PersonaAccount, PAccount> accountsToEdit =
new HashMap<>();
76 private final Map<PersonaMetadata, PMetadata> metadataToEdit =
new HashMap<>();
77 private final Map<PersonaAlias, PAlias> aliasesToEdit =
new HashMap<>();
80 private List<PersonaAccount> currentAccounts =
new ArrayList<>();
81 private List<PersonaMetadata> currentMetadata =
new ArrayList<>();
82 private List<PersonaAlias> currentAliases =
new ArrayList<>();
83 private List<CorrelationCase> currentCases =
new ArrayList<>();
91 "PersonaDetailsPanel_empty_justification_Title=Empty justification",
92 "PersonaDetailsPanel_empty_justification_msg=The justification field cannot be empty",})
98 addAccountBtn.addActionListener((ActionEvent e) -> {
101 editAccountBtn.addActionListener((ActionEvent e) -> {
102 int selectedRow = accountsTable.getSelectedRow();
103 if (selectedRow != -1) {
104 if (selectedRow >= currentAccounts.size()) {
105 PAccount acc = accountsToAdd.get(selectedRow - currentAccounts.size());
114 deleteAccountBtn.addActionListener((ActionEvent e) -> {
115 int selectedRow = accountsTable.getSelectedRow();
116 if (selectedRow != -1) {
118 if (selectedRow >= currentAccounts.size()) {
119 accountsToAdd.remove(selectedRow - currentAccounts.size());
122 accountsToEdit.remove(toRemove);
123 accountsToRemove.add(toRemove);
124 currentAccounts.remove(toRemove);
126 updateAccountsTable();
129 accountsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
130 accountsTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
131 handleSelectionChange(e, editAccountBtn, deleteAccountBtn, accountsTable);
135 addMetadataBtn.addActionListener((ActionEvent e) -> {
138 editMetadataBtn.addActionListener((ActionEvent e) -> {
139 int selectedRow = metadataTable.getSelectedRow();
140 if (selectedRow != -1) {
141 if (selectedRow >= currentMetadata.size()) {
142 PMetadata md = metadataToAdd.get(selectedRow - currentMetadata.size());
151 deleteMetadataBtn.addActionListener((ActionEvent e) -> {
152 int selectedRow = metadataTable.getSelectedRow();
153 if (selectedRow != -1) {
155 if (selectedRow >= currentMetadata.size()) {
156 metadataToAdd.remove(selectedRow - currentMetadata.size());
159 metadataToEdit.remove(toRemove);
160 metadataToRemove.add(toRemove);
161 currentMetadata.remove(toRemove);
163 updateMetadataTable();
166 metadataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
167 metadataTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
168 handleSelectionChange(e, editMetadataBtn, deleteMetadataBtn, metadataTable);
172 addAliasBtn.addActionListener((ActionEvent e) -> {
175 editAliasBtn.addActionListener((ActionEvent e) -> {
176 int selectedRow = aliasesTable.getSelectedRow();
177 if (selectedRow != -1) {
178 if (selectedRow >= currentAliases.size()) {
179 PAlias pa = aliasesToAdd.get(selectedRow - currentAliases.size());
182 PersonaAlias personaAlias = currentAliases.get(selectedRow);
188 deleteAliasBtn.addActionListener((ActionEvent e) -> {
189 int selectedRow = aliasesTable.getSelectedRow();
190 if (selectedRow != -1) {
192 if (selectedRow >= currentAliases.size()) {
193 aliasesToAdd.remove(selectedRow - currentAliases.size());
195 PersonaAlias toRemove = currentAliases.get(selectedRow);
196 aliasesToEdit.remove(toRemove);
197 aliasesToRemove.add(toRemove);
198 currentAliases.remove(toRemove);
200 updateAliasesTable();
203 aliasesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
204 aliasesTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
205 handleSelectionChange(e, editAliasBtn, deleteAliasBtn, aliasesTable);
210 if (e.getValueIsAdjusting()) {
218 accountsToEdit.put(account,
new PAccount(account.
getAccount(), justification, confidence));
221 void addEditExistingMetadata(PersonaMetadata metadata, String justification, Persona.Confidence confidence) {
222 metadataToEdit.put(metadata,
new PMetadata(metadata.getName(), metadata.getValue(), justification, confidence));
225 void addEditExistingAlias(PersonaAlias alias, String justification, Persona.Confidence confidence) {
226 aliasesToEdit.put(alias,
new PAlias(alias.getAlias(), justification, confidence));
229 PersonaDetailsMode getMode() {
238 CentralRepoAccount account;
239 String justification;
240 Persona.Confidence confidence;
242 PAccount(CentralRepoAccount account, String justification, Persona.Confidence confidence) {
243 this.account = account;
244 this.justification = justification;
245 this.confidence = confidence;
249 boolean accountExists(CentralRepoAccount account) {
250 for (PersonaAccount acc : currentAccounts) {
251 if (acc.getAccount().getId() == account.getId()) {
255 for (PAccount acc : accountsToAdd) {
256 if (acc.account.getId() == account.getId()) {
264 if (!accountExists(account)) {
265 accountsToAdd.add(
new PAccount(account, justification, confidence));
266 updateAccountsTable();
279 String justification;
282 PMetadata(String name, String value, String justification,
Persona.
Confidence confidence) {
285 this.justification = justification;
286 this.confidence = confidence;
290 boolean metadataExists(String name) {
291 for (PersonaMetadata pm : currentMetadata) {
292 if (pm.getName().equals(name)) {
296 for (PMetadata pm : metadataToAdd) {
297 if (pm.name.equals(name)) {
304 boolean addMetadata(String name, String value, String justification, Persona.Confidence confidence) {
305 if (!metadataExists(name)) {
306 metadataToAdd.add(
new PMetadata(name, value, justification, confidence));
307 updateMetadataTable();
319 String justification;
320 Persona.Confidence confidence;
322 PAlias(String alias, String justification, Persona.Confidence confidence) {
324 this.justification = justification;
325 this.confidence = confidence;
329 boolean aliasExists(String alias) {
330 for (PersonaAlias pa : currentAliases) {
331 if (pa.getAlias().equals(alias)) {
335 for (PAlias pa : aliasesToAdd) {
336 if (pa.alias.equals(alias)) {
343 boolean addAlias(String alias, String justification, Persona.Confidence confidence) {
344 if (!aliasExists(alias)) {
345 aliasesToAdd.add(
new PAlias(alias, justification, confidence));
346 updateAliasesTable();
360 detailsPanel =
new javax.swing.JPanel();
361 examinerLbl =
new javax.swing.JLabel();
362 examinerField =
new javax.swing.JTextField();
363 creationDateLbl =
new javax.swing.JLabel();
364 creationDateField =
new javax.swing.JTextField();
365 commentLbl =
new javax.swing.JLabel();
366 commentField =
new javax.swing.JTextField();
367 nameLbl =
new javax.swing.JLabel();
368 nameField =
new javax.swing.JTextField();
369 accountsLbl =
new javax.swing.JLabel();
370 accountsTablePane =
new javax.swing.JScrollPane();
371 accountsTable =
new javax.swing.JTable();
372 addAccountBtn =
new javax.swing.JButton();
373 editAccountBtn =
new javax.swing.JButton();
374 deleteAccountBtn =
new javax.swing.JButton();
375 metadataLabel =
new javax.swing.JLabel();
376 metadataTablePane =
new javax.swing.JScrollPane();
377 metadataTable =
new javax.swing.JTable();
378 addMetadataBtn =
new javax.swing.JButton();
379 editMetadataBtn =
new javax.swing.JButton();
380 deleteMetadataBtn =
new javax.swing.JButton();
381 aliasesLabel =
new javax.swing.JLabel();
382 aliasesTablePane =
new javax.swing.JScrollPane();
383 aliasesTable =
new javax.swing.JTable();
384 addAliasBtn =
new javax.swing.JButton();
385 editAliasBtn =
new javax.swing.JButton();
386 deleteAliasBtn =
new javax.swing.JButton();
387 casesLbl =
new javax.swing.JLabel();
388 casesTablePane =
new javax.swing.JScrollPane();
389 casesTable =
new javax.swing.JTable();
391 addComponentListener(
new java.awt.event.ComponentAdapter() {
392 public void componentShown(java.awt.event.ComponentEvent evt) {
393 formComponentShown(evt);
397 org.openide.awt.Mnemonics.setLocalizedText(examinerLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.examinerLbl.text"));
399 examinerField.setEditable(
false);
400 examinerField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.examinerField.text"));
402 org.openide.awt.Mnemonics.setLocalizedText(creationDateLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.creationDateLbl.text"));
404 creationDateField.setEditable(
false);
405 creationDateField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.creationDateField.text"));
407 org.openide.awt.Mnemonics.setLocalizedText(commentLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.commentLbl.text"));
409 commentField.setEditable(
false);
410 commentField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.commentField.text"));
412 nameLbl.setFont(nameLbl.getFont().deriveFont(nameLbl.getFont().getStyle() | java.awt.Font.BOLD));
413 org.openide.awt.Mnemonics.setLocalizedText(nameLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.nameLbl.text"));
415 nameField.setEditable(
false);
416 nameField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.nameField.text"));
418 accountsLbl.setFont(accountsLbl.getFont().deriveFont(accountsLbl.getFont().getStyle() | java.awt.Font.BOLD));
419 org.openide.awt.Mnemonics.setLocalizedText(accountsLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.accountsLbl.text"));
421 accountsTable.setModel(
new javax.swing.table.DefaultTableModel(
432 accountsTablePane.setViewportView(accountsTable);
434 org.openide.awt.Mnemonics.setLocalizedText(addAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addAccountBtn.text"));
435 addAccountBtn.setEnabled(
false);
437 org.openide.awt.Mnemonics.setLocalizedText(editAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editAccountBtn.text"));
438 editAccountBtn.setEnabled(
false);
440 org.openide.awt.Mnemonics.setLocalizedText(deleteAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteAccountBtn.text"));
441 deleteAccountBtn.setEnabled(
false);
443 metadataLabel.setFont(metadataLabel.getFont().deriveFont(metadataLabel.getFont().getStyle() | java.awt.Font.BOLD));
444 org.openide.awt.Mnemonics.setLocalizedText(metadataLabel,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.metadataLabel.text"));
446 metadataTable.setModel(
new javax.swing.table.DefaultTableModel(
457 metadataTablePane.setViewportView(metadataTable);
459 org.openide.awt.Mnemonics.setLocalizedText(addMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addMetadataBtn.text"));
460 addMetadataBtn.setEnabled(
false);
462 org.openide.awt.Mnemonics.setLocalizedText(editMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editMetadataBtn.text"));
463 editMetadataBtn.setEnabled(
false);
465 org.openide.awt.Mnemonics.setLocalizedText(deleteMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteMetadataBtn.text"));
466 deleteMetadataBtn.setEnabled(
false);
468 aliasesLabel.setFont(aliasesLabel.getFont().deriveFont(aliasesLabel.getFont().getStyle() | java.awt.Font.BOLD));
469 org.openide.awt.Mnemonics.setLocalizedText(aliasesLabel,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.aliasesLabel.text"));
471 aliasesTable.setModel(
new javax.swing.table.DefaultTableModel(
482 aliasesTablePane.setViewportView(aliasesTable);
484 org.openide.awt.Mnemonics.setLocalizedText(addAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addAliasBtn.text"));
485 addAliasBtn.setEnabled(
false);
487 org.openide.awt.Mnemonics.setLocalizedText(editAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editAliasBtn.text"));
488 editAliasBtn.setEnabled(
false);
490 org.openide.awt.Mnemonics.setLocalizedText(deleteAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteAliasBtn.text"));
491 deleteAliasBtn.setEnabled(
false);
493 casesLbl.setFont(casesLbl.getFont().deriveFont(casesLbl.getFont().getStyle() | java.awt.Font.BOLD));
494 org.openide.awt.Mnemonics.setLocalizedText(casesLbl,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.casesLbl.text"));
496 casesTable.setModel(
new javax.swing.table.DefaultTableModel(
507 casesTablePane.setViewportView(casesTable);
509 javax.swing.GroupLayout detailsPanelLayout =
new javax.swing.GroupLayout(detailsPanel);
510 detailsPanel.setLayout(detailsPanelLayout);
511 detailsPanelLayout.setHorizontalGroup(
512 detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
513 .addGroup(detailsPanelLayout.createSequentialGroup()
515 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
516 .addComponent(accountsLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
517 .addComponent(metadataLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
518 .addComponent(aliasesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
519 .addComponent(casesLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
520 .addGroup(detailsPanelLayout.createSequentialGroup()
521 .addComponent(nameLbl)
522 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
523 .addComponent(nameField))
524 .addGroup(detailsPanelLayout.createSequentialGroup()
525 .addComponent(examinerLbl)
526 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
527 .addComponent(examinerField, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
529 .addComponent(creationDateLbl)
530 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
531 .addComponent(creationDateField))
532 .addGroup(detailsPanelLayout.createSequentialGroup()
533 .addComponent(commentLbl)
534 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
535 .addComponent(commentField))
536 .addGroup(detailsPanelLayout.createSequentialGroup()
538 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
539 .addComponent(aliasesTablePane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
540 .addComponent(metadataTablePane, javax.swing.GroupLayout.Alignment.TRAILING)
541 .addComponent(accountsTablePane, javax.swing.GroupLayout.Alignment.TRAILING)
542 .addGroup(detailsPanelLayout.createSequentialGroup()
543 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
544 .addGroup(detailsPanelLayout.createSequentialGroup()
545 .addComponent(addAliasBtn)
546 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
547 .addComponent(editAliasBtn)
548 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
549 .addComponent(deleteAliasBtn))
550 .addGroup(detailsPanelLayout.createSequentialGroup()
551 .addComponent(addMetadataBtn)
552 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
553 .addComponent(editMetadataBtn)
554 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
555 .addComponent(deleteMetadataBtn))
556 .addGroup(detailsPanelLayout.createSequentialGroup()
557 .addComponent(addAccountBtn)
558 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
559 .addComponent(editAccountBtn)
560 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
561 .addComponent(deleteAccountBtn)))
562 .addGap(0, 0, Short.MAX_VALUE))
563 .addComponent(casesTablePane))))
566 detailsPanelLayout.setVerticalGroup(
567 detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
568 .addGroup(detailsPanelLayout.createSequentialGroup()
570 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
571 .addComponent(nameLbl)
572 .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
574 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
575 .addComponent(examinerLbl)
576 .addComponent(examinerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
577 .addComponent(creationDateLbl)
578 .addComponent(creationDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
579 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
580 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
581 .addComponent(commentField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
582 .addComponent(commentLbl))
584 .addComponent(accountsLbl)
585 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
586 .addComponent(accountsTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
587 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
588 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
589 .addComponent(addAccountBtn)
590 .addComponent(deleteAccountBtn)
591 .addComponent(editAccountBtn))
592 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
593 .addComponent(metadataLabel)
594 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
595 .addComponent(metadataTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
596 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
597 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
598 .addComponent(addMetadataBtn)
599 .addComponent(deleteMetadataBtn)
600 .addComponent(editMetadataBtn))
601 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
602 .addComponent(aliasesLabel)
603 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
604 .addComponent(aliasesTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
605 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
606 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
607 .addComponent(addAliasBtn)
608 .addComponent(deleteAliasBtn)
609 .addComponent(editAliasBtn))
610 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
611 .addComponent(casesLbl)
612 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
613 .addComponent(casesTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
617 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
618 this.setLayout(layout);
619 layout.setHorizontalGroup(
620 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
621 .addComponent(detailsPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
622 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
623 .addGap(0, 617, Short.MAX_VALUE))
625 layout.setVerticalGroup(
626 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
627 .addGap(0, 583, Short.MAX_VALUE)
628 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
629 .addGroup(layout.createSequentialGroup()
630 .addComponent(detailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
631 .addGap(0, 0, Short.MAX_VALUE)))
673 "PersonaDetailsPanel_load_exception_Title=Initialization failure",
674 "PersonaDetailsPanel_load_exception_msg=Failed to load persona.",})
680 Collection<PersonaAccount> accounts;
681 Collection<PersonaMetadata> metadata;
682 Collection<PersonaAlias> aliases;
683 Collection<CorrelationCase> cases;
687 SimpleDateFormat dateFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
689 creationDate = dateFormat.format(cDate);
698 logger.log(Level.SEVERE,
"Failed to load persona", ex);
699 JOptionPane.showMessageDialog(parent,
700 Bundle.PersonaDetailsPanel_load_exception_Title(),
701 Bundle.PersonaDetailsPanel_load_exception_msg(),
702 JOptionPane.ERROR_MESSAGE);
705 this.currentPersona = persona;
706 this.examinerField.setText(examiner);
707 this.creationDateField.setText(creationDate);
708 this.commentField.setText(comment);
709 this.nameField.setText(name);
710 this.currentAccounts.addAll(accounts);
711 this.currentMetadata.addAll(metadata);
712 this.currentAliases.addAll(aliases);
713 this.currentCases.addAll(cases);
717 currentPersona = null;
718 examinerField.setText(
"");
719 creationDateField.setText(
"");
720 commentField.setText(
"");
722 currentAccounts =
new ArrayList<>();
723 currentMetadata =
new ArrayList<>();
724 currentAliases =
new ArrayList<>();
725 currentCases =
new ArrayList<>();
726 accountsToAdd.clear();
727 metadataToAdd.clear();
728 aliasesToAdd.clear();
729 nameField.setEditable(
false);
730 commentField.setEditable(
false);
734 addAccountBtn.setEnabled(
false);
735 addMetadataBtn.setEnabled(
false);
736 addAliasBtn.setEnabled(
false);
737 deleteAccountBtn.setEnabled(
false);
738 deleteMetadataBtn.setEnabled(
false);
739 deleteAliasBtn.setEnabled(
false);
740 editAccountBtn.setEnabled(
false);
741 editMetadataBtn.setEnabled(
false);
742 editAliasBtn.setEnabled(
false);
748 final class PersonaDetailsTableModel
extends DefaultTableModel {
750 private static final long serialVersionUID = 1L;
752 PersonaDetailsTableModel(Object[][] rows, String[] colNames) {
753 super(rows, colNames);
757 public boolean isCellEditable(
int row,
int column) {
763 Object[][] rows =
new Object[currentAccounts.size() + accountsToAdd.size()][2];
766 rows[i] =
new Object[]{
767 acc.getAccount().getAccountType().getAcctType().getDisplayName(),
768 acc.getAccount().getIdentifier()
772 for (PAccount acc : accountsToAdd) {
773 rows[i] =
new Object[]{
774 acc.account.getAccountType().getAcctType().getDisplayName(),
775 acc.account.getIdentifier()
779 accountsModel =
new PersonaDetailsTableModel(
781 new String[]{
"Type",
"Identifier"}
783 accountsTable.setModel(accountsModel);
786 accountsTable.getColumnModel().getColumn(0).setMaxWidth(100);
787 accountsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
791 Object[][] rows =
new Object[currentMetadata.size() + metadataToAdd.size()][2];
794 rows[i] =
new Object[]{md.getName(), md.getValue()};
797 for (PMetadata md : metadataToAdd) {
798 rows[i] =
new Object[]{md.name, md.value};
801 metadataModel =
new PersonaDetailsTableModel(
803 new String[]{
"Name",
"Value"}
805 metadataTable.setModel(metadataModel);
809 Object[][] rows =
new Object[currentAliases.size() + aliasesToAdd.size()][1];
812 rows[i] =
new Object[]{alias.getAlias()};
815 for (PAlias alias : aliasesToAdd) {
816 rows[i] =
new Object[]{alias.alias};
819 aliasesModel =
new PersonaDetailsTableModel(
821 new String[]{
"Alias"}
823 aliasesTable.setModel(aliasesModel);
827 Object[][] rows =
new Object[currentCases.size()][1];
830 rows[i] =
new Object[]{c.getDisplayName()};
833 casesModel =
new PersonaDetailsTableModel(
837 casesTable.setModel(casesModel);
840 void configureEditComponents(
boolean enabled) {
841 commentField.setEditable(enabled);
842 nameField.setEditable(enabled);
843 addAccountBtn.setEnabled(enabled);
844 addMetadataBtn.setEnabled(enabled);
845 addAliasBtn.setEnabled(enabled);
847 addAccountBtn.setVisible(enabled);
848 editAccountBtn.setVisible(enabled);
849 deleteAccountBtn.setVisible(enabled);
850 addMetadataBtn.setVisible(enabled);
851 editMetadataBtn.setVisible(enabled);
852 deleteMetadataBtn.setVisible(enabled);
853 addAliasBtn.setVisible(enabled);
854 editAliasBtn.setVisible(enabled);
855 deleteAliasBtn.setVisible(enabled);
858 void initializeFields() {
859 if (mode == PersonaDetailsMode.
CREATE) {
862 examinerField.setText(examiner.getLoginName());
863 }
catch (CentralRepoException e) {
864 logger.log(Level.SEVERE,
"Failed to access central repository", e);
865 JOptionPane.showMessageDialog(
this,
866 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
867 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
868 JOptionPane.ERROR_MESSAGE);
871 updateAccountsTable();
872 updateMetadataTable();
873 updateAliasesTable();
877 void setMode(Component parent, PersonaDetailsMode mode, Persona persona) {
882 configureEditComponents(
true);
885 loadPersona(parent, persona);
886 configureEditComponents(
true);
889 loadPersona(parent, persona);
890 configureEditComponents(
false);
893 logger.log(Level.WARNING,
"Unsupported mode: {0}", mode);
900 "PersonaDetailsPanel_NotEnoughAccounts_msg=A persona needs at least one account.",
901 "PersonaDetailsPanel_NotEnoughAccounts_Title=Missing account",
902 "PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository.",
903 "PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure",
904 "PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty.",
905 "PersonaDetailsPanel_EmptyName_Title=Empty persona name",
906 "PersonaDetailsPanel_EmptyComment_msg=Persona comment cannot be empty.",
907 "PersonaDetailsPanel_EmptyComment_Title=Empty persona comment",})
908 Persona okHandler() {
909 if (accountsToAdd.size() + currentAccounts.size() < 1) {
910 JOptionPane.showMessageDialog(
this,
911 Bundle.PersonaDetailsPanel_NotEnoughAccounts_msg(),
912 Bundle.PersonaDetailsPanel_NotEnoughAccounts_Title(),
913 JOptionPane.ERROR_MESSAGE);
917 if (StringUtils.isBlank(commentField.getText())) {
918 JOptionPane.showMessageDialog(
this,
919 Bundle.PersonaDetailsPanel_EmptyComment_msg(),
920 Bundle.PersonaDetailsPanel_EmptyComment_Title(),
921 JOptionPane.ERROR_MESSAGE);
924 if (StringUtils.isBlank(nameField.getText())) {
925 JOptionPane.showMessageDialog(
this,
926 Bundle.PersonaDetailsPanel_EmptyName_msg(),
927 Bundle.PersonaDetailsPanel_EmptyName_Title(),
928 JOptionPane.ERROR_MESSAGE);
936 PAccount firstAccount = accountsToAdd.get(0);
937 ret = Persona.createPersonaForAccount(nameField.getText(),
938 commentField.getText(), Persona.PersonaStatus.ACTIVE, firstAccount.account,
939 firstAccount.justification, firstAccount.confidence);
940 for (
int i = 1; i < accountsToAdd.size(); i++) {
941 ret.addAccount(accountsToAdd.get(i).account,
942 accountsToAdd.get(i).justification,
943 accountsToAdd.get(i).confidence);
945 for (PMetadata md : metadataToAdd) {
946 ret.addMetadata(md.name, md.value, md.justification, md.confidence);
948 for (PAlias pa : aliasesToAdd) {
949 ret.addAlias(pa.alias, pa.justification, pa.confidence);
951 }
catch (CentralRepoException e) {
952 logger.log(Level.SEVERE,
"Failed to access central repository", e);
953 JOptionPane.showMessageDialog(
this,
954 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
955 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
956 JOptionPane.ERROR_MESSAGE);
962 ret = currentPersona;
963 currentPersona.
setComment(commentField.getText());
964 currentPersona.
setName(nameField.getText());
965 for (PAccount acc : accountsToAdd) {
966 ret.addAccount(acc.account, acc.justification, acc.confidence);
968 for (PersonaAccount acc : accountsToRemove) {
969 ret.removeAccount(acc);
971 for (HashMap.Entry<PersonaAccount, PAccount> entry : accountsToEdit.entrySet()) {
972 ret.modifyAccount(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
974 for (PMetadata md : metadataToAdd) {
975 ret.addMetadata(md.name, md.value, md.justification, md.confidence);
977 for (PersonaMetadata md : metadataToRemove) {
978 ret.removeMetadata(md);
980 for (HashMap.Entry<PersonaMetadata, PMetadata> entry : metadataToEdit.entrySet()) {
981 ret.modifyMetadata(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
983 for (PAlias pa : aliasesToAdd) {
984 ret.addAlias(pa.alias, pa.justification, pa.confidence);
986 for (PersonaAlias pa : aliasesToRemove) {
989 for (HashMap.Entry<PersonaAlias, PAlias> entry : aliasesToEdit.entrySet()) {
990 ret.modifyAlias(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
992 }
catch (CentralRepoException e) {
993 logger.log(Level.SEVERE,
"Failed to access central repository", e);
994 JOptionPane.showMessageDialog(
this,
995 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
996 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
997 JOptionPane.ERROR_MESSAGE);
1002 ret = currentPersona;
1005 logger.log(Level.SEVERE,
"Unsupported mode: {0}", mode);
1016 nameField.setText(name);
boolean addAccount(CentralRepoAccount account, String justification, Persona.Confidence confidence)
javax.swing.JPanel detailsPanel
javax.swing.JButton addAliasBtn
void updateAccountsTable()
javax.swing.JButton editMetadataBtn
void updateAliasesTable()
Collection< PersonaAccount > getPersonaAccounts()
javax.swing.JTable casesTable
javax.swing.JButton addMetadataBtn
javax.swing.JTextField nameField
Persona.Confidence getConfidence()
void formComponentShown(java.awt.event.ComponentEvent evt)
void setName(String name)
javax.swing.JLabel creationDateLbl
Persona.Confidence getConfidence()
void loadPersona(Component parent, Persona persona)
javax.swing.JScrollPane accountsTablePane
CentralRepoExaminer getOrInsertExaminer(String examinerLoginName)
PersonaDetailsTableModel metadataModel
javax.swing.JButton deleteAliasBtn
CentralRepoExaminer getExaminer()
String getJustification()
javax.swing.JButton addAccountBtn
Collection< PersonaAlias > getAliases()
javax.swing.JLabel casesLbl
Collection< CorrelationCase > getCases()
PersonaDetailsTableModel aliasesModel
javax.swing.JLabel commentLbl
void handleSelectionChange(ListSelectionEvent e, JButton editBtn, JButton deleteBtn, JTable table)
javax.swing.JLabel aliasesLabel
void setComment(String comment)
javax.swing.JButton deleteMetadataBtn
javax.swing.JTable aliasesTable
javax.swing.JLabel accountsLbl
javax.swing.JScrollPane casesTablePane
javax.swing.JLabel examinerLbl
void updateMetadataTable()
PersonaDetailsTableModel accountsModel
String getJustification()
javax.swing.JTextField creationDateField
javax.swing.JScrollPane aliasesTablePane
javax.swing.JButton editAliasBtn
javax.swing.JButton editAccountBtn
javax.swing.JTable accountsTable
void setPersonaName(String name)
PersonaDetailsTableModel casesModel
synchronized static Logger getLogger(String name)
javax.swing.JLabel metadataLabel
CentralRepoAccount getAccount()
javax.swing.JButton deleteAccountBtn
javax.swing.JScrollPane metadataTablePane
javax.swing.JTextField examinerField
javax.swing.JTextField commentField
javax.swing.JLabel nameLbl
static CentralRepository getInstance()
Collection< PersonaMetadata > getMetadata()
static String getDefaultName()
javax.swing.JTable metadataTable