Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
ManageOrganizationsDialog.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2015-2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.centralrepository.optionspanel;
20 
21 import java.awt.Component;
22 import java.awt.Dialog;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.DefaultListCellRenderer;
26 import javax.swing.DefaultListModel;
27 import javax.swing.JDialog;
28 import javax.swing.JFrame;
29 import javax.swing.JOptionPane;
30 import javax.swing.event.ListSelectionEvent;
31 import javax.swing.event.ListSelectionListener;
32 import org.openide.util.NbBundle.Messages;
33 import org.openide.windows.WindowManager;
39 
43 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
44 public final class ManageOrganizationsDialog extends JDialog {
45 
46  private static final long serialVersionUID = 1L;
47 
50  private final DefaultListModel<CentralRepoOrganization> rulesListModel = new DefaultListModel<>();
51  private final static Logger logger = Logger.getLogger(ManageOrganizationsDialog.class.getName());
52 
53  @Messages({"ManageOrganizationsDialog.title.text=Manage Organizations"})
58  public ManageOrganizationsDialog(Dialog parent) {
59  super(parent,
60  Bundle.ManageOrganizationsDialog_title_text(),
61  true); // NON-NLS
62  init();
63  }
64 
65 
70  public ManageOrganizationsDialog(JFrame parent) {
71  super(parent,
72  Bundle.ManageOrganizationsDialog_title_text(),
73  true); // NON-NLS
74  init();
75  }
76 
77 
82  this((JFrame) WindowManager.getDefault().getMainWindow());
83  }
84 
85 
89  private void init() {
90  initComponents();
91  try {
92  this.dbManager = CentralRepository.getInstance();
93  organizationList.setCellRenderer(new DefaultListCellRenderer() {
94  private static final long serialVersionUID = 1L;
95 
96  @SuppressWarnings("rawtypes")
97  @Override
98  public Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
99  Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
100  setText(((CentralRepoOrganization) value).getName());
101  return c;
102  }
103  });
104  organizationList.setModel(rulesListModel);
105  organizationList.addListSelectionListener(new OrganizationListSelectionListener());
106  populateList();
107  setButtonsEnabled(organizationList.getSelectedValue());
108  newOrg = null;
109  } catch (CentralRepoException ex) {
110  logger.log(Level.WARNING, "Error getting Central Repo for Organizations dialog", ex);
111  }
112  display();
113  }
114 
115  private void display() {
116  this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
117  setVisible(true);
118  toFront();
119  }
120 
122  rulesListModel.clear();
123  List<CentralRepoOrganization> orgs = dbManager.getOrganizations();
124  if (orgs.size() > 0) {
125  for (CentralRepoOrganization org : orgs) {
126  rulesListModel.addElement(org);
127  if (selected != null && org.getOrgID() == selected.getOrgID()) {
128  selected = org;
129  }
130  }
131  if (orgs.contains(selected)) {
132  organizationList.setSelectedValue(selected, true);
133  } else {
134  organizationList.setSelectedIndex(0);
135  }
136  organizationList.validate();
137  organizationList.repaint();
138  }
139  }
140 
141  private void populateList() throws CentralRepoException {
142  CentralRepoOrganization selected = organizationList.getSelectedValue();
143  populateListAndSelect(selected);
144  }
145 
146  @Messages({"ManageOrganizationsDialog.pocNameLabel.text=Point of Contact Name:",
147  "ManageOrganizationsDialog.deleteButton.text=Delete",
148  "ManageOrganizationsDialog.newButton.text=New",
149  "ManageOrganizationsDialog.closeButton.text=Close",
150  "ManageOrganizationsDialog.orgNameLabel.text=Organization Name:",
151  "ManageOrganizationsDialog.pocEmailLabel.text=Point of Contact Email:",
152  "ManageOrganizationsDialog.editButton.text=Edit",
153  "ManageOrganizationsDialog.pocPhoneLabel.text=Point of Contact Phone:",
154  "ManageOrganizationsDialog.orgDescriptionTextArea.text=Organizations are used to provide additional contact information for the content they are associated with.",
155  "ManageOrganizationsDialog.orgListLabel.text=Organizations",
156  "ManageOrganizationsDialog.orgDetailsLabel.text=Organization Details",
157  "ManageOrganizationsDialog.confirmDeletion.title=Confirm Deletion",
158  "ManageOrganizationsDialog.confirmDeletion.message=Are you sure you want to delete the selected organization from the central repo?",
159  "ManageOrganizationsDialog.unableToDeleteOrg.title=Unable to Delete",
160  "ManageOrganizationsDialog.unableToDeleteOrg.message=Unable to delete selected organizaiton."})
166  @SuppressWarnings("unchecked")
167  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
168  private void initComponents() {
169 
170  manageOrganizationsScrollPane = new javax.swing.JScrollPane();
171  manageOrganizationsPanel = new javax.swing.JPanel();
172  orgListScrollPane = new javax.swing.JScrollPane();
173  organizationList = new javax.swing.JList<>();
174  orgDescriptionScrollPane = new javax.swing.JScrollPane();
175  orgDescriptionTextArea = new javax.swing.JTextArea();
176  newButton = new javax.swing.JButton();
177  deleteButton = new javax.swing.JButton();
178  closeButton = new javax.swing.JButton();
179  orgListLabel = new javax.swing.JLabel();
180  jSeparator1 = new javax.swing.JSeparator();
181  pocNameLabel = new javax.swing.JLabel();
182  pocPhoneLabel = new javax.swing.JLabel();
183  pocEmailLabel = new javax.swing.JLabel();
184  orgNameLabel = new javax.swing.JLabel();
185  orgNameTextField = new javax.swing.JTextField();
186  pocNameTextField = new javax.swing.JTextField();
187  pocPhoneTextField = new javax.swing.JTextField();
188  pocEmailTextField = new javax.swing.JTextField();
189  editButton = new javax.swing.JButton();
190  orgDetailsLabel = new javax.swing.JLabel();
191 
192  setMinimumSize(new java.awt.Dimension(600, 450));
193  setPreferredSize(new java.awt.Dimension(600, 450));
194 
195  manageOrganizationsScrollPane.setMinimumSize(null);
196  manageOrganizationsScrollPane.setPreferredSize(new java.awt.Dimension(535, 415));
197 
198  manageOrganizationsPanel.setPreferredSize(new java.awt.Dimension(527, 407));
199 
200  organizationList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
201  orgListScrollPane.setViewportView(organizationList);
202 
203  orgDescriptionTextArea.setEditable(false);
204  orgDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
205  orgDescriptionTextArea.setColumns(20);
206  orgDescriptionTextArea.setLineWrap(true);
207  orgDescriptionTextArea.setRows(3);
208  orgDescriptionTextArea.setText(org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgDescriptionTextArea.text")); // NOI18N
209  orgDescriptionTextArea.setWrapStyleWord(true);
210  orgDescriptionScrollPane.setViewportView(orgDescriptionTextArea);
211 
212  org.openide.awt.Mnemonics.setLocalizedText(newButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.newButton.text")); // NOI18N
213  newButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
214  newButton.setMaximumSize(new java.awt.Dimension(70, 23));
215  newButton.setMinimumSize(new java.awt.Dimension(70, 23));
216  newButton.setPreferredSize(new java.awt.Dimension(70, 23));
217  newButton.addActionListener(new java.awt.event.ActionListener() {
218  public void actionPerformed(java.awt.event.ActionEvent evt) {
219  newButtonActionPerformed(evt);
220  }
221  });
222 
223  org.openide.awt.Mnemonics.setLocalizedText(deleteButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.deleteButton.text")); // NOI18N
224  deleteButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
225  deleteButton.setMaximumSize(new java.awt.Dimension(70, 23));
226  deleteButton.setMinimumSize(new java.awt.Dimension(70, 23));
227  deleteButton.setPreferredSize(new java.awt.Dimension(70, 23));
228  deleteButton.addActionListener(new java.awt.event.ActionListener() {
229  public void actionPerformed(java.awt.event.ActionEvent evt) {
230  deleteButtonActionPerformed(evt);
231  }
232  });
233 
234  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.closeButton.text")); // NOI18N
235  closeButton.addActionListener(new java.awt.event.ActionListener() {
236  public void actionPerformed(java.awt.event.ActionEvent evt) {
237  closeButtonActionPerformed(evt);
238  }
239  });
240 
241  org.openide.awt.Mnemonics.setLocalizedText(orgListLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgListLabel.text")); // NOI18N
242 
243  jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
244 
245  org.openide.awt.Mnemonics.setLocalizedText(pocNameLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocNameLabel.text")); // NOI18N
246 
247  org.openide.awt.Mnemonics.setLocalizedText(pocPhoneLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocPhoneLabel.text")); // NOI18N
248 
249  org.openide.awt.Mnemonics.setLocalizedText(pocEmailLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocEmailLabel.text")); // NOI18N
250 
251  org.openide.awt.Mnemonics.setLocalizedText(orgNameLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgNameLabel.text")); // NOI18N
252 
253  orgNameTextField.setEditable(false);
254 
255  pocNameTextField.setEditable(false);
256 
257  pocPhoneTextField.setEditable(false);
258 
259  pocEmailTextField.setEditable(false);
260 
261  org.openide.awt.Mnemonics.setLocalizedText(editButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.editButton.text")); // NOI18N
262  editButton.setMaximumSize(new java.awt.Dimension(70, 23));
263  editButton.setMinimumSize(new java.awt.Dimension(70, 23));
264  editButton.setPreferredSize(new java.awt.Dimension(70, 23));
265  editButton.addActionListener(new java.awt.event.ActionListener() {
266  public void actionPerformed(java.awt.event.ActionEvent evt) {
267  editButtonActionPerformed(evt);
268  }
269  });
270 
271  org.openide.awt.Mnemonics.setLocalizedText(orgDetailsLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgDetailsLabel.text")); // NOI18N
272 
273  javax.swing.GroupLayout manageOrganizationsPanelLayout = new javax.swing.GroupLayout(manageOrganizationsPanel);
274  manageOrganizationsPanel.setLayout(manageOrganizationsPanelLayout);
275  manageOrganizationsPanelLayout.setHorizontalGroup(
276  manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
277  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
278  .addContainerGap()
279  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
280  .addComponent(orgDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
281  .addComponent(orgListLabel)
282  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
283  .addComponent(newButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
284  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
285  .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
286  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
287  .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
288  .addComponent(orgListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE))
289  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
290  .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
291  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
293  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
294  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
295  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
296  .addComponent(closeButton))
297  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
298  .addGap(29, 29, 29)
299  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
300  .addComponent(pocNameLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
301  .addComponent(orgNameLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
302  .addComponent(pocPhoneLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
303  .addComponent(pocEmailLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
304  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
305  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
306  .addComponent(pocNameTextField)
307  .addComponent(pocPhoneTextField)
308  .addComponent(pocEmailTextField, javax.swing.GroupLayout.Alignment.TRAILING)
309  .addComponent(orgNameTextField))))
310  .addContainerGap())
311  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
312  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
313  .addComponent(orgDetailsLabel)
314  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
315  );
316  manageOrganizationsPanelLayout.setVerticalGroup(
317  manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
318  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
319  .addContainerGap()
320  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
321  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
322  .addComponent(orgDetailsLabel)
323  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
324  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
325  .addComponent(orgNameLabel)
326  .addComponent(orgNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
327  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
328  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
329  .addComponent(pocNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
330  .addComponent(pocNameLabel))
331  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
332  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
333  .addComponent(pocPhoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
334  .addComponent(pocPhoneLabel))
335  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
336  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
337  .addComponent(pocEmailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
338  .addComponent(pocEmailLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
339  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
340  .addComponent(closeButton))
341  .addComponent(jSeparator1)
342  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
343  .addComponent(orgDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
344  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
345  .addComponent(orgListLabel)
346  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
347  .addComponent(orgListScrollPane)
348  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
349  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
350  .addComponent(newButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
351  .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
352  .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
353  .addContainerGap())
354  );
355 
356  manageOrganizationsScrollPane.setViewportView(manageOrganizationsPanel);
357 
358  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
359  getContentPane().setLayout(layout);
360  layout.setHorizontalGroup(
361  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
362  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
363  .addGap(0, 0, 0)
364  .addComponent(manageOrganizationsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 603, Short.MAX_VALUE))
365  );
366  layout.setVerticalGroup(
367  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
368  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
369  .addGap(0, 0, 0)
370  .addComponent(manageOrganizationsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE))
371  );
372 
373  pack();
374  }// </editor-fold>//GEN-END:initComponents
375 
376  private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
377  CentralRepoOrganization orgToDelete = organizationList.getSelectedValue();
378  if (orgToDelete != null) {
379  if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this,
380  Bundle.ManageOrganizationsDialog_confirmDeletion_message(),
381  Bundle.ManageOrganizationsDialog_confirmDeletion_title(),
382  JOptionPane.YES_NO_OPTION)) {
383  try {
385  populateList();
386  } catch (CentralRepoException ex) {
387  JOptionPane.showMessageDialog(this,
388  ex.getMessage(), Bundle.ManageOrganizationsDialog_unableToDeleteOrg_title(), JOptionPane.WARNING_MESSAGE);
389  logger.log(Level.INFO, "Was unable to delete organization from central repository", ex);
390  }
391  }
392  }
393  }//GEN-LAST:event_deleteButtonActionPerformed
394 
395  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
396  dispose();
397  }//GEN-LAST:event_closeButtonActionPerformed
398 
399  private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
400  AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog(this);
401  if (dialogO.isChanged()) {
402  try {
403  newOrg = dialogO.getNewOrg();
404  populateListAndSelect(dialogO.getNewOrg());
405  } catch (CentralRepoException ex) {
406 
407  }
408  }
409  }//GEN-LAST:event_newButtonActionPerformed
410 
411  private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
412  CentralRepoOrganization orgToEdit = organizationList.getSelectedValue();
413  if (orgToEdit != null) {
414  AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog(this, orgToEdit);
415  if (dialogO.isChanged()) {
416  try {
417  newOrg = dialogO.getNewOrg();
418  populateListAndSelect(dialogO.getNewOrg());
419  } catch (CentralRepoException ex) {
420 
421  }
422  }
423  }
424  }//GEN-LAST:event_editButtonActionPerformed
425 
426 
427  // Variables declaration - do not modify//GEN-BEGIN:variables
428  private javax.swing.JButton closeButton;
429  private javax.swing.JButton deleteButton;
430  private javax.swing.JButton editButton;
431  private javax.swing.JSeparator jSeparator1;
432  private javax.swing.JPanel manageOrganizationsPanel;
433  private javax.swing.JScrollPane manageOrganizationsScrollPane;
434  private javax.swing.JButton newButton;
435  private javax.swing.JScrollPane orgDescriptionScrollPane;
436  private javax.swing.JTextArea orgDescriptionTextArea;
437  private javax.swing.JLabel orgDetailsLabel;
438  private javax.swing.JLabel orgListLabel;
439  private javax.swing.JScrollPane orgListScrollPane;
440  private javax.swing.JLabel orgNameLabel;
441  private javax.swing.JTextField orgNameTextField;
443  private javax.swing.JLabel pocEmailLabel;
444  private javax.swing.JTextField pocEmailTextField;
445  private javax.swing.JLabel pocNameLabel;
446  private javax.swing.JTextField pocNameTextField;
447  private javax.swing.JLabel pocPhoneLabel;
448  private javax.swing.JTextField pocPhoneTextField;
449  // End of variables declaration//GEN-END:variables
450  public boolean isChanged() {
451  return newOrg != null;
452  }
453 
455  return newOrg;
456  }
457 
458  private void setButtonsEnabled(CentralRepoOrganization selectedOrg) {
459  boolean isSelected = (selectedOrg != null);
460  boolean isDefaultOrg = false;
461  if(selectedOrg != null){
462  isDefaultOrg = CentralRepoDbUtil.isDefaultOrg(selectedOrg);
463  }
464 
465  editButton.setEnabled(isSelected && (! isDefaultOrg));
466  deleteButton.setEnabled(isSelected && (! isDefaultOrg));
467  }
468 
472  private final class OrganizationListSelectionListener implements ListSelectionListener {
473 
474  @Override
475  public void valueChanged(ListSelectionEvent e) {
476  if (e.getValueIsAdjusting()) {
477  return;
478  }
479  CentralRepoOrganization selected = organizationList.getSelectedValue();
480  setButtonsEnabled(selected);
481  if (selected != null) {
482  orgNameTextField.setText(selected.getName());
483  pocNameTextField.setText(selected.getPocName());
484  pocPhoneTextField.setText(selected.getPocPhone());
485  pocEmailTextField.setText(selected.getPocEmail());
486  } else {
487  orgNameTextField.setText("");
488  pocNameTextField.setText("");
489  pocPhoneTextField.setText("");
490  pocEmailTextField.setText("");
491  }
492  }
493  }
494 
495 }
void deleteOrganization(CentralRepoOrganization organizationToDelete)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
javax.swing.JList< org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization > organizationList

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.