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));
234 CentralRepoAccount account;
235 String justification;
236 Persona.Confidence confidence;
238 PAccount(CentralRepoAccount account, String justification, Persona.Confidence confidence) {
239 this.account = account;
240 this.justification = justification;
241 this.confidence = confidence;
245 boolean accountExists(CentralRepoAccount account) {
246 for (PersonaAccount acc : currentAccounts) {
247 if (acc.getAccount().getId() == account.getId()) {
251 for (PAccount acc : accountsToAdd) {
252 if (acc.account.getId() == account.getId()) {
260 if (!accountExists(account)) {
261 accountsToAdd.add(
new PAccount(account, justification, confidence));
262 updateAccountsTable();
275 String justification;
278 PMetadata(String name, String value, String justification,
Persona.
Confidence confidence) {
281 this.justification = justification;
282 this.confidence = confidence;
286 boolean metadataExists(String name) {
287 for (PersonaMetadata pm : currentMetadata) {
288 if (pm.getName().equals(name)) {
292 for (PMetadata pm : metadataToAdd) {
293 if (pm.name.equals(name)) {
300 boolean addMetadata(String name, String value, String justification, Persona.Confidence confidence) {
301 if (!metadataExists(name)) {
302 metadataToAdd.add(
new PMetadata(name, value, justification, confidence));
303 updateMetadataTable();
315 String justification;
316 Persona.Confidence confidence;
318 PAlias(String alias, String justification, Persona.Confidence confidence) {
320 this.justification = justification;
321 this.confidence = confidence;
325 boolean aliasExists(String alias) {
326 for (PersonaAlias pa : currentAliases) {
327 if (pa.getAlias().equals(alias)) {
331 for (PAlias pa : aliasesToAdd) {
332 if (pa.alias.equals(alias)) {
339 boolean addAlias(String alias, String justification, Persona.Confidence confidence) {
340 if (!aliasExists(alias)) {
341 aliasesToAdd.add(
new PAlias(alias, justification, confidence));
342 updateAliasesTable();
356 detailsPanel =
new javax.swing.JPanel();
357 examinerLbl =
new javax.swing.JLabel();
358 examinerField =
new javax.swing.JTextField();
359 creationDateLbl =
new javax.swing.JLabel();
360 creationDateField =
new javax.swing.JTextField();
361 commentLbl =
new javax.swing.JLabel();
362 commentField =
new javax.swing.JTextField();
363 nameLbl =
new javax.swing.JLabel();
364 nameField =
new javax.swing.JTextField();
365 accountsLbl =
new javax.swing.JLabel();
366 accountsTablePane =
new javax.swing.JScrollPane();
367 accountsTable =
new javax.swing.JTable();
368 addAccountBtn =
new javax.swing.JButton();
369 editAccountBtn =
new javax.swing.JButton();
370 deleteAccountBtn =
new javax.swing.JButton();
371 metadataLabel =
new javax.swing.JLabel();
372 metadataTablePane =
new javax.swing.JScrollPane();
373 metadataTable =
new javax.swing.JTable();
374 addMetadataBtn =
new javax.swing.JButton();
375 editMetadataBtn =
new javax.swing.JButton();
376 deleteMetadataBtn =
new javax.swing.JButton();
377 aliasesLabel =
new javax.swing.JLabel();
378 aliasesTablePane =
new javax.swing.JScrollPane();
379 aliasesTable =
new javax.swing.JTable();
380 addAliasBtn =
new javax.swing.JButton();
381 editAliasBtn =
new javax.swing.JButton();
382 deleteAliasBtn =
new javax.swing.JButton();
383 casesLbl =
new javax.swing.JLabel();
384 casesTablePane =
new javax.swing.JScrollPane();
385 casesTable =
new javax.swing.JTable();
387 org.openide.awt.Mnemonics.setLocalizedText(examinerLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.examinerLbl.text"));
389 examinerField.setEditable(
false);
390 examinerField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.examinerField.text"));
392 org.openide.awt.Mnemonics.setLocalizedText(creationDateLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.creationDateLbl.text"));
394 creationDateField.setEditable(
false);
395 creationDateField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.creationDateField.text"));
397 org.openide.awt.Mnemonics.setLocalizedText(commentLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.commentLbl.text"));
399 commentField.setEditable(
false);
400 commentField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.commentField.text"));
402 nameLbl.setFont(nameLbl.getFont().deriveFont(nameLbl.getFont().getStyle() | java.awt.Font.BOLD));
403 org.openide.awt.Mnemonics.setLocalizedText(nameLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.nameLbl.text"));
405 nameField.setEditable(
false);
406 nameField.setText(
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.nameField.text"));
408 accountsLbl.setFont(accountsLbl.getFont().deriveFont(accountsLbl.getFont().getStyle() | java.awt.Font.BOLD));
409 org.openide.awt.Mnemonics.setLocalizedText(accountsLbl,
org.openide.util.NbBundle.getMessage(
PersonaDetailsPanel.class,
"PersonaDetailsPanel.accountsLbl.text"));
411 accountsTable.setModel(
new javax.swing.table.DefaultTableModel(
422 accountsTablePane.setViewportView(accountsTable);
424 org.openide.awt.Mnemonics.setLocalizedText(addAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addAccountBtn.text"));
425 addAccountBtn.setEnabled(
false);
427 org.openide.awt.Mnemonics.setLocalizedText(editAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editAccountBtn.text"));
428 editAccountBtn.setEnabled(
false);
430 org.openide.awt.Mnemonics.setLocalizedText(deleteAccountBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteAccountBtn.text"));
431 deleteAccountBtn.setEnabled(
false);
433 metadataLabel.setFont(metadataLabel.getFont().deriveFont(metadataLabel.getFont().getStyle() | java.awt.Font.BOLD));
434 org.openide.awt.Mnemonics.setLocalizedText(metadataLabel,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.metadataLabel.text"));
436 metadataTable.setModel(
new javax.swing.table.DefaultTableModel(
447 metadataTablePane.setViewportView(metadataTable);
449 org.openide.awt.Mnemonics.setLocalizedText(addMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addMetadataBtn.text"));
450 addMetadataBtn.setEnabled(
false);
452 org.openide.awt.Mnemonics.setLocalizedText(editMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editMetadataBtn.text"));
453 editMetadataBtn.setEnabled(
false);
455 org.openide.awt.Mnemonics.setLocalizedText(deleteMetadataBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteMetadataBtn.text"));
456 deleteMetadataBtn.setEnabled(
false);
458 aliasesLabel.setFont(aliasesLabel.getFont().deriveFont(aliasesLabel.getFont().getStyle() | java.awt.Font.BOLD));
459 org.openide.awt.Mnemonics.setLocalizedText(aliasesLabel,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.aliasesLabel.text"));
461 aliasesTable.setModel(
new javax.swing.table.DefaultTableModel(
472 aliasesTablePane.setViewportView(aliasesTable);
474 org.openide.awt.Mnemonics.setLocalizedText(addAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.addAliasBtn.text"));
475 addAliasBtn.setEnabled(
false);
477 org.openide.awt.Mnemonics.setLocalizedText(editAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.editAliasBtn.text"));
478 editAliasBtn.setEnabled(
false);
480 org.openide.awt.Mnemonics.setLocalizedText(deleteAliasBtn,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.deleteAliasBtn.text"));
481 deleteAliasBtn.setEnabled(
false);
483 casesLbl.setFont(casesLbl.getFont().deriveFont(casesLbl.getFont().getStyle() | java.awt.Font.BOLD));
484 org.openide.awt.Mnemonics.setLocalizedText(casesLbl,
org.openide.util.NbBundle.getMessage(PersonaDetailsPanel.class,
"PersonaDetailsPanel.casesLbl.text"));
486 casesTable.setModel(
new javax.swing.table.DefaultTableModel(
497 casesTablePane.setViewportView(casesTable);
499 javax.swing.GroupLayout detailsPanelLayout =
new javax.swing.GroupLayout(detailsPanel);
500 detailsPanel.setLayout(detailsPanelLayout);
501 detailsPanelLayout.setHorizontalGroup(
502 detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
503 .addGroup(detailsPanelLayout.createSequentialGroup()
505 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
506 .addComponent(accountsLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
507 .addComponent(metadataLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
508 .addComponent(aliasesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
509 .addComponent(casesLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
510 .addGroup(detailsPanelLayout.createSequentialGroup()
511 .addComponent(nameLbl)
512 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
513 .addComponent(nameField))
514 .addGroup(detailsPanelLayout.createSequentialGroup()
515 .addComponent(examinerLbl)
516 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
517 .addComponent(examinerField, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
519 .addComponent(creationDateLbl)
520 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
521 .addComponent(creationDateField))
522 .addGroup(detailsPanelLayout.createSequentialGroup()
523 .addComponent(commentLbl)
524 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
525 .addComponent(commentField))
526 .addGroup(detailsPanelLayout.createSequentialGroup()
528 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
529 .addComponent(aliasesTablePane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
530 .addComponent(metadataTablePane, javax.swing.GroupLayout.Alignment.TRAILING)
531 .addComponent(accountsTablePane, javax.swing.GroupLayout.Alignment.TRAILING)
532 .addGroup(detailsPanelLayout.createSequentialGroup()
533 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
534 .addGroup(detailsPanelLayout.createSequentialGroup()
535 .addComponent(addAliasBtn)
536 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
537 .addComponent(editAliasBtn)
538 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
539 .addComponent(deleteAliasBtn))
540 .addGroup(detailsPanelLayout.createSequentialGroup()
541 .addComponent(addMetadataBtn)
542 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
543 .addComponent(editMetadataBtn)
544 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
545 .addComponent(deleteMetadataBtn))
546 .addGroup(detailsPanelLayout.createSequentialGroup()
547 .addComponent(addAccountBtn)
548 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
549 .addComponent(editAccountBtn)
550 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
551 .addComponent(deleteAccountBtn)))
552 .addGap(0, 0, Short.MAX_VALUE))
553 .addComponent(casesTablePane))))
556 detailsPanelLayout.setVerticalGroup(
557 detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
558 .addGroup(detailsPanelLayout.createSequentialGroup()
560 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
561 .addComponent(nameLbl)
562 .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
564 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
565 .addComponent(examinerLbl)
566 .addComponent(examinerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
567 .addComponent(creationDateLbl)
568 .addComponent(creationDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
569 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
570 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
571 .addComponent(commentField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
572 .addComponent(commentLbl))
574 .addComponent(accountsLbl)
575 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
576 .addComponent(accountsTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
577 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
578 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
579 .addComponent(addAccountBtn)
580 .addComponent(deleteAccountBtn)
581 .addComponent(editAccountBtn))
582 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
583 .addComponent(metadataLabel)
584 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
585 .addComponent(metadataTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
586 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
587 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
588 .addComponent(addMetadataBtn)
589 .addComponent(deleteMetadataBtn)
590 .addComponent(editMetadataBtn))
591 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
592 .addComponent(aliasesLabel)
593 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
594 .addComponent(aliasesTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
595 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
596 .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
597 .addComponent(addAliasBtn)
598 .addComponent(deleteAliasBtn)
599 .addComponent(editAliasBtn))
600 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
601 .addComponent(casesLbl)
602 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
603 .addComponent(casesTablePane, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
607 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
608 this.setLayout(layout);
609 layout.setHorizontalGroup(
610 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
611 .addComponent(detailsPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
612 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
613 .addGap(0, 617, Short.MAX_VALUE))
615 layout.setVerticalGroup(
616 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
617 .addGap(0, 583, Short.MAX_VALUE)
618 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
619 .addGroup(layout.createSequentialGroup()
620 .addComponent(detailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
621 .addGap(0, 0, Short.MAX_VALUE)))
659 "PersonaDetailsPanel_load_exception_Title=Initialization failure",
660 "PersonaDetailsPanel_load_exception_msg=Failed to load persona.",})
666 Collection<PersonaAccount> accounts;
667 Collection<PersonaMetadata> metadata;
668 Collection<PersonaAlias> aliases;
669 Collection<CorrelationCase> cases;
673 SimpleDateFormat dateFormat =
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
675 creationDate = dateFormat.format(cDate);
684 logger.log(Level.SEVERE,
"Failed to load persona", ex);
685 JOptionPane.showMessageDialog(parent,
686 Bundle.PersonaDetailsPanel_load_exception_Title(),
687 Bundle.PersonaDetailsPanel_load_exception_msg(),
688 JOptionPane.ERROR_MESSAGE);
691 this.currentPersona = persona;
692 this.examinerField.setText(examiner);
693 this.creationDateField.setText(creationDate);
694 this.commentField.setText(comment);
695 this.nameField.setText(name);
696 this.currentAccounts.addAll(accounts);
697 this.currentMetadata.addAll(metadata);
698 this.currentAliases.addAll(aliases);
699 this.currentCases.addAll(cases);
703 currentPersona = null;
704 examinerField.setText(
"");
705 creationDateField.setText(
"");
706 commentField.setText(
"");
708 currentAccounts =
new ArrayList<>();
709 currentMetadata =
new ArrayList<>();
710 currentAliases =
new ArrayList<>();
711 currentCases =
new ArrayList<>();
712 accountsToAdd.clear();
713 metadataToAdd.clear();
714 aliasesToAdd.clear();
715 nameField.setEditable(
false);
716 commentField.setEditable(
false);
720 addAccountBtn.setEnabled(
false);
721 addMetadataBtn.setEnabled(
false);
722 addAliasBtn.setEnabled(
false);
723 deleteAccountBtn.setEnabled(
false);
724 deleteMetadataBtn.setEnabled(
false);
725 deleteAliasBtn.setEnabled(
false);
726 editAccountBtn.setEnabled(
false);
727 editMetadataBtn.setEnabled(
false);
728 editAliasBtn.setEnabled(
false);
734 final class PersonaDetailsTableModel
extends DefaultTableModel {
736 private static final long serialVersionUID = 1L;
738 PersonaDetailsTableModel(Object[][] rows, String[] colNames) {
739 super(rows, colNames);
743 public boolean isCellEditable(
int row,
int column) {
749 Object[][] rows =
new Object[currentAccounts.size() + accountsToAdd.size()][2];
752 rows[i] =
new Object[]{
753 acc.getAccount().getAccountType().getAcctType().getDisplayName(),
754 acc.getAccount().getIdentifier()
758 for (PAccount acc : accountsToAdd) {
759 rows[i] =
new Object[]{
760 acc.account.getAccountType().getAcctType().getDisplayName(),
761 acc.account.getIdentifier()
765 accountsModel =
new PersonaDetailsTableModel(
767 new String[]{
"Type",
"Identifier"}
769 accountsTable.setModel(accountsModel);
772 accountsTable.getColumnModel().getColumn(0).setMaxWidth(100);
773 accountsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
777 Object[][] rows =
new Object[currentMetadata.size() + metadataToAdd.size()][2];
780 rows[i] =
new Object[]{md.getName(), md.getValue()};
783 for (PMetadata md : metadataToAdd) {
784 rows[i] =
new Object[]{md.name, md.value};
787 metadataModel =
new PersonaDetailsTableModel(
789 new String[]{
"Name",
"Value"}
791 metadataTable.setModel(metadataModel);
795 Object[][] rows =
new Object[currentAliases.size() + aliasesToAdd.size()][1];
798 rows[i] =
new Object[]{alias.getAlias()};
801 for (PAlias alias : aliasesToAdd) {
802 rows[i] =
new Object[]{alias.alias};
805 aliasesModel =
new PersonaDetailsTableModel(
807 new String[]{
"Alias"}
809 aliasesTable.setModel(aliasesModel);
813 Object[][] rows =
new Object[currentCases.size()][1];
816 rows[i] =
new Object[]{c.getDisplayName()};
819 casesModel =
new PersonaDetailsTableModel(
823 casesTable.setModel(casesModel);
826 void configureEditComponents(
boolean enabled) {
827 commentField.setEditable(enabled);
828 nameField.setEditable(enabled);
829 addAccountBtn.setEnabled(enabled);
830 addMetadataBtn.setEnabled(enabled);
831 addAliasBtn.setEnabled(enabled);
833 addAccountBtn.setVisible(enabled);
834 editAccountBtn.setVisible(enabled);
835 deleteAccountBtn.setVisible(enabled);
836 addMetadataBtn.setVisible(enabled);
837 editMetadataBtn.setVisible(enabled);
838 deleteMetadataBtn.setVisible(enabled);
839 addAliasBtn.setVisible(enabled);
840 editAliasBtn.setVisible(enabled);
841 deleteAliasBtn.setVisible(enabled);
844 void initializeFields() {
845 if (mode == PersonaDetailsMode.
CREATE) {
848 examinerField.setText(examiner.getLoginName());
849 }
catch (CentralRepoException e) {
850 logger.log(Level.SEVERE,
"Failed to access central repository", e);
851 JOptionPane.showMessageDialog(
this,
852 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
853 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
854 JOptionPane.ERROR_MESSAGE);
857 updateAccountsTable();
858 updateMetadataTable();
859 updateAliasesTable();
863 void setMode(Component parent, PersonaDetailsMode mode, Persona persona) {
868 configureEditComponents(
true);
871 loadPersona(parent, persona);
872 configureEditComponents(
true);
875 loadPersona(parent, persona);
876 configureEditComponents(
false);
879 logger.log(Level.WARNING,
"Unsupported mode: {0}", mode);
886 "PersonaDetailsPanel_NotEnoughAccounts_msg=A persona needs at least one account.",
887 "PersonaDetailsPanel_NotEnoughAccounts_Title=Missing account",
888 "PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository.",
889 "PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure",
890 "PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty.",
891 "PersonaDetailsPanel_EmptyName_Title=Empty persona name",
892 "PersonaDetailsPanel_EmptyComment_msg=Persona comment cannot be empty.",
893 "PersonaDetailsPanel_EmptyComment_Title=Empty persona comment",})
894 Persona okHandler() {
895 if (accountsToAdd.size() + currentAccounts.size() < 1) {
896 JOptionPane.showMessageDialog(
this,
897 Bundle.PersonaDetailsPanel_NotEnoughAccounts_msg(),
898 Bundle.PersonaDetailsPanel_NotEnoughAccounts_Title(),
899 JOptionPane.ERROR_MESSAGE);
903 if (StringUtils.isBlank(commentField.getText())) {
904 JOptionPane.showMessageDialog(
this,
905 Bundle.PersonaDetailsPanel_EmptyComment_msg(),
906 Bundle.PersonaDetailsPanel_EmptyComment_Title(),
907 JOptionPane.ERROR_MESSAGE);
910 if (StringUtils.isBlank(nameField.getText())) {
911 JOptionPane.showMessageDialog(
this,
912 Bundle.PersonaDetailsPanel_EmptyName_msg(),
913 Bundle.PersonaDetailsPanel_EmptyName_Title(),
914 JOptionPane.ERROR_MESSAGE);
922 PAccount firstAccount = accountsToAdd.get(0);
923 ret = Persona.createPersonaForAccount(nameField.getText(),
924 commentField.getText(), Persona.PersonaStatus.ACTIVE, firstAccount.account,
925 firstAccount.justification, firstAccount.confidence);
926 for (
int i = 1; i < accountsToAdd.size(); i++) {
927 ret.addAccount(accountsToAdd.get(i).account,
928 accountsToAdd.get(i).justification,
929 accountsToAdd.get(i).confidence);
931 for (PMetadata md : metadataToAdd) {
932 ret.addMetadata(md.name, md.value, md.justification, md.confidence);
934 for (PAlias pa : aliasesToAdd) {
935 ret.addAlias(pa.alias, pa.justification, pa.confidence);
937 }
catch (CentralRepoException e) {
938 logger.log(Level.SEVERE,
"Failed to access central repository", e);
939 JOptionPane.showMessageDialog(
this,
940 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
941 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
942 JOptionPane.ERROR_MESSAGE);
948 ret = currentPersona;
949 currentPersona.
setComment(commentField.getText());
950 currentPersona.
setName(nameField.getText());
951 for (PAccount acc : accountsToAdd) {
952 ret.addAccount(acc.account, acc.justification, acc.confidence);
954 for (PersonaAccount acc : accountsToRemove) {
955 ret.removeAccount(acc);
957 for (HashMap.Entry<PersonaAccount, PAccount> entry : accountsToEdit.entrySet()) {
958 ret.modifyAccount(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
960 for (PMetadata md : metadataToAdd) {
961 ret.addMetadata(md.name, md.value, md.justification, md.confidence);
963 for (PersonaMetadata md : metadataToRemove) {
964 ret.removeMetadata(md);
966 for (HashMap.Entry<PersonaMetadata, PMetadata> entry : metadataToEdit.entrySet()) {
967 ret.modifyMetadata(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
969 for (PAlias pa : aliasesToAdd) {
970 ret.addAlias(pa.alias, pa.justification, pa.confidence);
972 for (PersonaAlias pa : aliasesToRemove) {
975 for (HashMap.Entry<PersonaAlias, PAlias> entry : aliasesToEdit.entrySet()) {
976 ret.modifyAlias(entry.getKey(), entry.getValue().confidence, entry.getValue().justification);
978 }
catch (CentralRepoException e) {
979 logger.log(Level.SEVERE,
"Failed to access central repository", e);
980 JOptionPane.showMessageDialog(
this,
981 Bundle.PersonaDetailsPanel_CentralRepoErr_msg(),
982 Bundle.PersonaDetailsPanel_CentralRepoErr_Title(),
983 JOptionPane.ERROR_MESSAGE);
988 ret = currentPersona;
991 logger.log(Level.SEVERE,
"Unsupported mode: {0}", mode);
1002 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 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