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({
"AddMetadataDialog.title.text=Add Metadata",})
45 super(SwingUtilities.windowForComponent(pdp),
46 Bundle.AddMetadataDialog_title_text(),
47 ModalityType.APPLICATION_MODAL);
55 super(SwingUtilities.windowForComponent(pdp),
56 Bundle.AddMetadataDialog_title_text(),
57 ModalityType.APPLICATION_MODAL);
62 confidenceComboBox.setSelectedItem(md.confidence);
63 justificationTextField.setText(md.justification);
64 nameTextField.setText(md.name);
65 valueTextField.setText(md.value);
67 nameTextField.setEnabled(
false);
68 valueTextField.setEnabled(
false);
78 @SuppressWarnings(
"unchecked")
80 private
void initComponents() {
82 settingsPanel =
new javax.swing.JPanel();
83 nameLbl =
new javax.swing.JLabel();
84 nameTextField =
new javax.swing.JTextField();
85 valueLbl =
new javax.swing.JLabel();
86 valueTextField =
new javax.swing.JTextField();
87 confidenceLbl =
new javax.swing.JLabel();
88 confidenceComboBox =
new javax.swing.JComboBox<>();
89 justificationLbl =
new javax.swing.JLabel();
90 justificationTextField =
new javax.swing.JTextField();
91 cancelBtn =
new javax.swing.JButton();
92 okBtn =
new javax.swing.JButton();
94 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
97 settingsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
99 org.openide.awt.Mnemonics.setLocalizedText(nameLbl,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.nameLbl.text"));
101 nameTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.nameTextField.text"));
103 org.openide.awt.Mnemonics.setLocalizedText(valueLbl,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.valueLbl.text"));
105 valueTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.valueTextField.text"));
107 org.openide.awt.Mnemonics.setLocalizedText(confidenceLbl,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.confidenceLbl.text"));
111 org.openide.awt.Mnemonics.setLocalizedText(justificationLbl,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.justificationLbl.text"));
113 justificationTextField.setText(
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.justificationTextField.text"));
115 javax.swing.GroupLayout settingsPanelLayout =
new javax.swing.GroupLayout(settingsPanel);
116 settingsPanel.setLayout(settingsPanelLayout);
117 settingsPanelLayout.setHorizontalGroup(
118 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119 .addGroup(settingsPanelLayout.createSequentialGroup()
121 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
122 .addGroup(settingsPanelLayout.createSequentialGroup()
123 .addComponent(nameLbl)
124 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
125 .addComponent(nameTextField))
126 .addGroup(settingsPanelLayout.createSequentialGroup()
127 .addComponent(valueLbl)
128 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
129 .addComponent(valueTextField))
130 .addGroup(settingsPanelLayout.createSequentialGroup()
131 .addComponent(justificationLbl)
132 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
133 .addComponent(justificationTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE))
134 .addGroup(settingsPanelLayout.createSequentialGroup()
135 .addComponent(confidenceLbl)
136 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
137 .addComponent(confidenceComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
140 settingsPanelLayout.setVerticalGroup(
141 settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142 .addGroup(settingsPanelLayout.createSequentialGroup()
144 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
145 .addComponent(nameLbl)
146 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
147 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
148 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
149 .addComponent(valueLbl)
150 .addComponent(valueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
151 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
152 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
153 .addComponent(confidenceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
154 .addComponent(confidenceLbl))
155 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
156 .addGroup(settingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
157 .addComponent(justificationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
158 .addComponent(justificationLbl))
159 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
162 org.openide.awt.Mnemonics.setLocalizedText(cancelBtn,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.cancelBtn.text"));
163 cancelBtn.setMaximumSize(
new java.awt.Dimension(79, 23));
164 cancelBtn.setMinimumSize(
new java.awt.Dimension(79, 23));
165 cancelBtn.setPreferredSize(
new java.awt.Dimension(79, 23));
166 cancelBtn.addActionListener(
new java.awt.event.ActionListener() {
167 public void actionPerformed(java.awt.event.ActionEvent evt) {
168 cancelBtnActionPerformed(evt);
172 org.openide.awt.Mnemonics.setLocalizedText(okBtn,
org.openide.util.NbBundle.getMessage(
PersonaMetadataDialog.class,
"PersonaMetadataDialog.okBtn.text"));
173 okBtn.addActionListener(
new java.awt.event.ActionListener() {
174 public void actionPerformed(java.awt.event.ActionEvent evt) {
175 okBtnActionPerformed(evt);
179 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
180 getContentPane().setLayout(layout);
181 layout.setHorizontalGroup(
182 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
183 .addGroup(layout.createSequentialGroup()
184 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
186 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
187 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
189 .addComponent(settingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
192 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelBtn, okBtn});
194 layout.setVerticalGroup(
195 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
196 .addGroup(layout.createSequentialGroup()
197 .addComponent(settingsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
198 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
201 .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
202 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
209 this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
214 "AddMetadataDialog_dup_Title=Metadata add failure",
215 "AddMetadataDialog_dup_msg=A metadata entry with this name has already been added to this persona.",
216 "AddMetadataDialog_empty_name_Title=Missing field(s)",
217 "AddMetadataDialog_empty_name_msg=A metadata entry cannot have an empty name or value.",})
219 if (nameTextField.getText().isEmpty() || valueTextField.getText().isEmpty()) {
220 JOptionPane.showMessageDialog(
this,
221 Bundle.AddMetadataDialog_empty_name_msg(),
222 Bundle.AddMetadataDialog_empty_name_Title(),
223 JOptionPane.ERROR_MESSAGE);
226 if (justificationTextField.getText().isEmpty()) {
227 JOptionPane.showMessageDialog(
this,
228 Bundle.PersonaDetailsPanel_empty_justification_msg(),
229 Bundle.PersonaDetailsPanel_empty_justification_Title(),
230 JOptionPane.ERROR_MESSAGE);
235 String justification = justificationTextField.getText();
237 if (currentMetadata != null) {
238 currentMetadata.confidence = confidence;
239 currentMetadata.justification = justification;
242 if (pdp.addMetadata(nameTextField.getText(), valueTextField.getText(), justification, confidence)) {
245 JOptionPane.showMessageDialog(
this,
246 Bundle.AddMetadataDialog_dup_msg(),
247 Bundle.AddMetadataDialog_dup_Title(),
248 JOptionPane.ERROR_MESSAGE);