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.apache.commons.lang.StringUtils;
25 import org.openide.util.NbBundle.Messages;
26 import org.openide.windows.WindowManager;
32 @SuppressWarnings(
"PMD.SingularField")
35 private static final long serialVersionUID = 1L;
44 @Messages({
"PersonaAliasDialog.title.text=Add Alias",})
46 super(SwingUtilities.windowForComponent(pdp),
47 Bundle.PersonaAliasDialog_title_text(),
48 ModalityType.APPLICATION_MODAL);
56 super(SwingUtilities.windowForComponent(pdp),
57 Bundle.PersonaAliasDialog_title_text(),
58 ModalityType.APPLICATION_MODAL);
63 confidenceComboBox.setSelectedItem(pa.confidence);
64 justificationTextField.setText(pa.justification);
65 aliasTextField.setText(pa.alias);
67 aliasTextField.setEnabled(
false);
77 @SuppressWarnings(
"unchecked")
79 private
void initComponents() {
81 settingsPanel =
new javax.swing.JPanel();
82 aliasLbl =
new javax.swing.JLabel();
83 aliasTextField =
new javax.swing.JTextField();
84 confidenceLbl =
new javax.swing.JLabel();
85 confidenceComboBox =
new javax.swing.JComboBox<>();
86 justificationLbl =
new javax.swing.JLabel();
87 justificationTextField =
new javax.swing.JTextField();
88 cancelBtn =
new javax.swing.JButton();
89 okBtn =
new javax.swing.JButton();
91 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
94 settingsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
96 org.openide.awt.Mnemonics.setLocalizedText(aliasLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.aliasLbl.text"));
98 aliasTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.aliasTextField.text"));
100 org.openide.awt.Mnemonics.setLocalizedText(confidenceLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.confidenceLbl.text"));
104 org.openide.awt.Mnemonics.setLocalizedText(justificationLbl,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.justificationLbl.text"));
106 justificationTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.justificationTextField.text"));
108 javax.swing.GroupLayout settingsPanelLayout =
new javax.swing.GroupLayout(settingsPanel);
109 settingsPanel.setLayout(settingsPanelLayout);
110 settingsPanelLayout.setHorizontalGroup(
111 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
112 .addGroup(settingsPanelLayout.createSequentialGroup()
114 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115 .addGroup(settingsPanelLayout.createSequentialGroup()
116 .addComponent(aliasLbl)
117 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
118 .addComponent(aliasTextField))
119 .addGroup(settingsPanelLayout.createSequentialGroup()
120 .addComponent(justificationLbl)
121 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
122 .addComponent(justificationTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
123 .addGroup(settingsPanelLayout.createSequentialGroup()
124 .addComponent(confidenceLbl)
125 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
126 .addComponent(confidenceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
129 settingsPanelLayout.setVerticalGroup(
130 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131 .addGroup(settingsPanelLayout.createSequentialGroup()
133 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
134 .addComponent(aliasLbl)
135 .addComponent(aliasTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
136 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
137 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
138 .addComponent(confidenceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
139 .addComponent(confidenceLbl))
140 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
141 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
142 .addComponent(justificationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
143 .addComponent(justificationLbl))
144 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
147 org.openide.awt.Mnemonics.setLocalizedText(cancelBtn,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.cancelBtn.text_1"));
148 cancelBtn.setMaximumSize(
new java.awt.Dimension(79, 23));
149 cancelBtn.setMinimumSize(
new java.awt.Dimension(79, 23));
150 cancelBtn.setPreferredSize(
new java.awt.Dimension(79, 23));
151 cancelBtn.addActionListener(
new java.awt.event.ActionListener() {
152 public void actionPerformed(java.awt.event.ActionEvent evt) {
153 cancelBtnActionPerformed(evt);
157 org.openide.awt.Mnemonics.setLocalizedText(okBtn,
org.openide.util.NbBundle.getMessage(
PersonaAliasDialog.class,
"PersonaAliasDialog.okBtn.text_1"));
158 okBtn.addActionListener(
new java.awt.event.ActionListener() {
159 public void actionPerformed(java.awt.event.ActionEvent evt) {
160 okBtnActionPerformed(evt);
164 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
165 getContentPane().setLayout(layout);
166 layout.setHorizontalGroup(
167 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
168 .addGroup(layout.createSequentialGroup()
169 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
171 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
172 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
174 .addComponent(settingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
177 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelBtn, okBtn});
179 layout.setVerticalGroup(
180 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181 .addGroup(layout.createSequentialGroup()
182 .addComponent(settingsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
183 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
186 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
187 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
194 this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
199 "PersonaAliasDialog_empty_Title=Empty alias",
200 "PersonaAliasDialog_empty_msg=An alias cannot be empty.",
201 "PersonaAliasDialog_dup_Title=Alias add failure",
202 "PersonaAliasDialog_dup_msg=This alias has already been added to this persona.",})
204 if (StringUtils.isBlank(aliasTextField.getText())) {
205 JOptionPane.showMessageDialog(
this,
206 Bundle.PersonaAliasDialog_empty_msg(),
207 Bundle.PersonaAliasDialog_empty_Title(),
208 JOptionPane.ERROR_MESSAGE);
211 if (StringUtils.isBlank(justificationTextField.getText())) {
212 JOptionPane.showMessageDialog(
this,
213 Bundle.PersonaDetailsPanel_empty_justification_msg(),
214 Bundle.PersonaDetailsPanel_empty_justification_Title(),
215 JOptionPane.ERROR_MESSAGE);
220 String justification = justificationTextField.getText();
222 if (currentAlias != null) {
223 currentAlias.confidence = confidence;
224 currentAlias.justification = justification;
227 if (pdp.addAlias(aliasTextField.getText(), justification, confidence)) {
230 JOptionPane.showMessageDialog(
this,
231 Bundle.PersonaAliasDialog_dup_msg(),
232 Bundle.PersonaAliasDialog_dup_Title(),
233 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