19 package org.sleuthkit.autopsy.centralrepository.optionspanel;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import javax.swing.JFrame;
25 import javax.swing.JTextField;
26 import javax.swing.event.DocumentEvent;
27 import javax.swing.event.DocumentListener;
28 import org.netbeans.spi.options.OptionsPanelController;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.windows.WindowManager;
53 @Messages({
"AddNewOrganizationDialog.addNewOrg.msg=Add New Organization"})
55 super((JFrame) WindowManager.getDefault().getMainWindow(),
56 Bundle.AddNewOrganizationDialog_addNewOrg_msg(),
58 textBoxes =
new ArrayList<>();
64 organizationToEdit = null;
69 super((JFrame) WindowManager.getDefault().getMainWindow(),
70 Bundle.AddNewOrganizationDialog_addNewOrg_msg(),
72 organizationToEdit = orgToEdit;
73 textBoxes =
new ArrayList<>();
87 this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
114 textFields.forEach((textField) -> {
115 textField.getDocument().addDocumentListener(listener);
134 @Messages({
"AddNewOrganizationDialog.validation.incompleteFields=Organization Name is required."})
136 boolean result =
true;
143 lbWarningMsg.setText(Bundle.AddNewOrganizationDialog_validation_incompleteFields());
167 bnOK.setEnabled(enable);
179 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
185 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
191 firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
209 @SuppressWarnings(
"unchecked")
213 bnOK =
new javax.swing.JButton();
214 bnCancel =
new javax.swing.JButton();
220 tfPocName =
new javax.swing.JTextField();
226 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
229 bnOK.addActionListener(
new java.awt.event.ActionListener() {
230 public void actionPerformed(java.awt.event.ActionEvent evt) {
236 bnCancel.addActionListener(
new java.awt.event.ActionListener() {
237 public void actionPerformed(java.awt.event.ActionEvent evt) {
254 lbWarningMsg.setFont(
new java.awt.Font(
"Tahoma", 1, 12));
255 lbWarningMsg.setForeground(
new java.awt.Color(255, 0, 0));
257 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
258 getContentPane().setLayout(layout);
259 layout.setHorizontalGroup(
260 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
261 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
262 .addContainerGap(258, Short.MAX_VALUE)
267 .addGroup(layout.createSequentialGroup()
269 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
273 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
274 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
279 .addGroup(layout.createSequentialGroup()
281 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
282 .addGroup(layout.createSequentialGroup()
284 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
286 .addGroup(layout.createSequentialGroup()
288 .addGap(0, 0, Short.MAX_VALUE))
289 .addComponent(
lbWarningMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
292 layout.setVerticalGroup(
293 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
296 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
298 .addComponent(
tfOrganizationName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
299 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
301 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
302 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
304 .addComponent(
tfPocName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
305 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
306 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
308 .addComponent(
tfPocEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
309 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
310 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
312 .addComponent(
tfPocPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
313 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
314 .addComponent(
lbWarningMsg, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
315 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
316 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
329 @Messages({
"AddNewOrganizationDialog.bnOk.addFailed.text=Failed to add new organization."})
334 if (organizationToEdit != null) {
353 lbWarningMsg.setText(Bundle.AddNewOrganizationDialog_bnOk_addFailed_text());
354 LOGGER.log(Level.SEVERE,
"Failed adding new organization.", ex);
361 private javax.swing.JButton
bnOK;
final TextBoxChangedListener textBoxChangedListener
AddNewOrganizationDialog()
javax.swing.JLabel lbPocHeading
javax.swing.JLabel lbPocEmail
boolean requiredFieldsArePopulated()
void insertUpdate(DocumentEvent e)
long newOrganization(EamOrganization eamOrg)
static final long serialVersionUID
final Collection< JTextField > textBoxes
javax.swing.JLabel lbWarningMsg
javax.swing.JLabel lbPocName
javax.swing.JLabel lbPocPhone
boolean enableOkButton(Boolean enable)
void updateOrganization(EamOrganization updatedOrganization)
AddNewOrganizationDialog(EamOrganization orgToEdit)
void bnCancelActionPerformed(java.awt.event.ActionEvent evt)
void setTextBoxListeners()
javax.swing.JLabel lbOrganizationName
static EamDb getInstance()
void customizeComponents()
javax.swing.JTextField tfPocName
final EamOrganization organizationToEdit
static void addDocumentListeners(Collection< JTextField > textFields, TextBoxChangedListener listener)
javax.swing.JButton bnCancel
javax.swing.JTextField tfPocEmail
void removeUpdate(DocumentEvent e)
synchronized static Logger getLogger(String name)
void changedUpdate(DocumentEvent e)
javax.swing.JTextField tfPocPhone
static final Logger LOGGER
javax.swing.JTextField tfOrganizationName
EamOrganization getNewOrg()
void bnOKActionPerformed(java.awt.event.ActionEvent evt)