19 package org.sleuthkit.autopsy.centralrepository.persona;
21 import javax.swing.JDialog;
22 import javax.swing.JOptionPane;
23 import javax.swing.SwingUtilities;
24 import org.openide.util.NbBundle.Messages;
25 import org.openide.windows.WindowManager;
31 @SuppressWarnings(
"PMD.SingularField")
34 private static final long serialVersionUID = 1L;
43 @Messages({
"PersonaAliasDialog.title.text=Add Alias",})
45 super(SwingUtilities.windowForComponent(pdp),
46 Bundle.PersonaAliasDialog_title_text(),
47 ModalityType.APPLICATION_MODAL);
55 super(SwingUtilities.windowForComponent(pdp),
56 Bundle.PersonaAliasDialog_title_text(),
57 ModalityType.APPLICATION_MODAL);
62 confidenceComboBox.setSelectedItem(pa.confidence);
63 justificationTextField.setText(pa.justification);
64 aliasTextField.setText(pa.alias);
66 aliasTextField.setEnabled(
false);
76 @SuppressWarnings(
"unchecked")
78 private
void initComponents() {
80 settingsPanel =
new javax.swing.JPanel();
81 aliasLbl =
new javax.swing.JLabel();
82 aliasTextField =
new javax.swing.JTextField();
83 confidenceLbl =
new javax.swing.JLabel();
84 confidenceComboBox =
new javax.swing.JComboBox<>();
85 justificationLbl =
new javax.swing.JLabel();
86 justificationTextField =
new javax.swing.JTextField();
87 cancelBtn =
new javax.swing.JButton();
88 okBtn =
new javax.swing.JButton();
90 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
93 settingsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
95 org.openide.awt.Mnemonics.setLocalizedText(aliasLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.aliasLbl.text"));
97 aliasTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.aliasTextField.text"));
99 org.openide.awt.Mnemonics.setLocalizedText(confidenceLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.confidenceLbl.text"));
103 org.openide.awt.Mnemonics.setLocalizedText(justificationLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.justificationLbl.text"));
105 justificationTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.justificationTextField.text"));
107 javax.swing.GroupLayout settingsPanelLayout =
new javax.swing.GroupLayout(settingsPanel);
108 settingsPanel.setLayout(settingsPanelLayout);
109 settingsPanelLayout.setHorizontalGroup(
110 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
111 .addGroup(settingsPanelLayout.createSequentialGroup()
113 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
114 .addGroup(settingsPanelLayout.createSequentialGroup()
115 .addComponent(aliasLbl)
116 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
117 .addComponent(aliasTextField))
118 .addGroup(settingsPanelLayout.createSequentialGroup()
119 .addComponent(justificationLbl)
120 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121 .addComponent(justificationTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
122 .addGroup(settingsPanelLayout.createSequentialGroup()
123 .addComponent(confidenceLbl)
124 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
125 .addComponent(confidenceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
128 settingsPanelLayout.setVerticalGroup(
129 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
130 .addGroup(settingsPanelLayout.createSequentialGroup()
132 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
133 .addComponent(aliasLbl)
134 .addComponent(aliasTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
135 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
136 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
137 .addComponent(confidenceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
138 .addComponent(confidenceLbl))
139 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
140 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
141 .addComponent(justificationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
142 .addComponent(justificationLbl))
143 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
146 org.openide.awt.Mnemonics.setLocalizedText(cancelBtn,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.cancelBtn.text_1"));
147 cancelBtn.setMaximumSize(
new java.awt.Dimension(79, 23));
148 cancelBtn.setMinimumSize(
new java.awt.Dimension(79, 23));
149 cancelBtn.setPreferredSize(
new java.awt.Dimension(79, 23));
150 cancelBtn.addActionListener(
new java.awt.event.ActionListener() {
151 public void actionPerformed(java.awt.event.ActionEvent evt) {
152 cancelBtnActionPerformed(evt);
156 org.openide.awt.Mnemonics.setLocalizedText(okBtn,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.okBtn.text_1"));
157 okBtn.addActionListener(
new java.awt.event.ActionListener() {
158 public void actionPerformed(java.awt.event.ActionEvent evt) {
159 okBtnActionPerformed(evt);
163 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
164 getContentPane().setLayout(layout);
165 layout.setHorizontalGroup(
166 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167 .addGroup(layout.createSequentialGroup()
168 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
170 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
171 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
173 .addComponent(settingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
176 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelBtn, okBtn});
178 layout.setVerticalGroup(
179 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180 .addGroup(layout.createSequentialGroup()
181 .addComponent(settingsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
182 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
183 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
185 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
186 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
193 this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
198 "PersonaAliasDialog_empty_Title=Empty alias",
199 "PersonaAliasDialog_empty_msg=An alias cannot be empty.",
200 "PersonaAliasDialog_dup_Title=Alias add failure",
201 "PersonaAliasDialog_dup_msg=This alias has already been added to this persona.",})
203 if (aliasTextField.getText().isEmpty()) {
204 JOptionPane.showMessageDialog(
this,
205 Bundle.PersonaAliasDialog_empty_msg(),
206 Bundle.PersonaAliasDialog_empty_Title(),
207 JOptionPane.ERROR_MESSAGE);
210 if (justificationTextField.getText().isEmpty()) {
211 JOptionPane.showMessageDialog(
this,
212 Bundle.PersonaDetailsPanel_empty_justification_msg(),
213 Bundle.PersonaDetailsPanel_empty_justification_Title(),
214 JOptionPane.ERROR_MESSAGE);
219 String justification = justificationTextField.getText();
221 if (currentAlias != null) {
222 currentAlias.confidence = confidence;
223 currentAlias.justification = justification;
226 if (pdp.addAlias(aliasTextField.getText(), justification, confidence)) {
229 JOptionPane.showMessageDialog(
this,
230 Bundle.PersonaAliasDialog_dup_msg(),
231 Bundle.PersonaAliasDialog_dup_Title(),
232 JOptionPane.ERROR_MESSAGE);
javax.swing.JComboBox< org.sleuthkit.autopsy.centralrepository.datamodel.Persona.Confidence > confidenceComboBox
javax.swing.JLabel aliasLbl
javax.swing.JButton okBtn
void okBtnActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JPanel settingsPanel
final PersonaDetailsPanel pdp
javax.swing.JLabel confidenceLbl
void cancelBtnActionPerformed(java.awt.event.ActionEvent evt)
PersonaAliasDialog(PersonaDetailsPanel pdp)
javax.swing.JButton cancelBtn
javax.swing.JTextField aliasTextField
javax.swing.JTextField justificationTextField
javax.swing.JLabel justificationLbl