Autopsy  4.7.0
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-2018 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.util.List;
23 import java.util.logging.Level;
24 import javax.swing.DefaultListCellRenderer;
25 import javax.swing.DefaultListModel;
26 import javax.swing.JDialog;
27 import javax.swing.JFrame;
28 import javax.swing.JOptionPane;
29 import javax.swing.event.ListSelectionEvent;
30 import javax.swing.event.ListSelectionListener;
31 import org.openide.util.Exceptions;
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 
48  private EamDb dbManager;
50  private final DefaultListModel<EamOrganization> rulesListModel = new DefaultListModel<>();
51  private final static Logger logger = Logger.getLogger(ManageOrganizationsDialog.class.getName());
52 
53  @Messages({"ManageOrganizationsDialog.title.text=Manage Organizations"})
58  super((JFrame) WindowManager.getDefault().getMainWindow(),
59  Bundle.ManageOrganizationsDialog_title_text(),
60  true); // NON-NLS
61  initComponents();
62  try {
63  this.dbManager = EamDb.getInstance();
64  organizationList.setCellRenderer(new DefaultListCellRenderer() {
65  private static final long serialVersionUID = 1L;
66 
67  @SuppressWarnings("rawtypes")
68  @Override
69  public Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
70  Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
71  setText(((EamOrganization) value).getName());
72  return c;
73  }
74  });
75  organizationList.setModel(rulesListModel);
76  organizationList.addListSelectionListener(new OrganizationListSelectionListener());
77  populateList();
78  setButtonsEnabled(organizationList.getSelectedValue());
79  newOrg = null;
80  } catch (EamDbException ex) {
81  Exceptions.printStackTrace(ex);
82  }
83  display();
84  }
85 
86  private void display() {
87  this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
88  setVisible(true);
89  }
90 
91  private void populateListAndSelect(EamOrganization selected) throws EamDbException {
92  rulesListModel.clear();
93  List<EamOrganization> orgs = dbManager.getOrganizations();
94  if (orgs.size() > 0) {
95  for (EamOrganization org : orgs) {
96  rulesListModel.addElement(org);
97  if (selected != null && org.getOrgID() == selected.getOrgID()) {
98  selected = org;
99  }
100  }
101  if (orgs.contains(selected)) {
102  organizationList.setSelectedValue(selected, true);
103  } else {
104  organizationList.setSelectedIndex(0);
105  }
106  organizationList.validate();
107  organizationList.repaint();
108  }
109  }
110 
111  private void populateList() throws EamDbException {
112  EamOrganization selected = organizationList.getSelectedValue();
113  populateListAndSelect(selected);
114  }
115 
116  @Messages({"ManageOrganizationsDialog.pocNameLabel.text=Point of Contact Name:",
117  "ManageOrganizationsDialog.deleteButton.text=Delete",
118  "ManageOrganizationsDialog.newButton.text=New",
119  "ManageOrganizationsDialog.closeButton.text=Close",
120  "ManageOrganizationsDialog.orgNameLabel.text=Organization Name:",
121  "ManageOrganizationsDialog.pocEmailLabel.text=Point of Contact Email:",
122  "ManageOrganizationsDialog.editButton.text=Edit",
123  "ManageOrganizationsDialog.pocPhoneLabel.text=Point of Contact Phone:",
124  "ManageOrganizationsDialog.orgDescriptionTextArea.text=Organizations are used to provide additional contact information for the content they are associated with.",
125  "ManageOrganizationsDialog.orgListLabel.text=Organizations",
126  "ManageOrganizationsDialog.orgDetailsLabel.text=Organization Details",
127  "ManageOrganizationsDialog.confirmDeletion.title=Confirm Deletion",
128  "ManageOrganizationsDialog.confirmDeletion.message=Are you sure you want to delete the selected organization from the central repo?",
129  "ManageOrganizationsDialog.unableToDeleteOrg.title=Unable to Delete",
130  "ManageOrganizationsDialog.unableToDeleteOrg.message=Unable to delete selected organizaiton."})
136  @SuppressWarnings("unchecked")
137  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
138  private void initComponents() {
139 
140  manageOrganizationsScrollPane = new javax.swing.JScrollPane();
141  manageOrganizationsPanel = new javax.swing.JPanel();
142  orgListScrollPane = new javax.swing.JScrollPane();
143  organizationList = new javax.swing.JList<>();
144  orgDescriptionScrollPane = new javax.swing.JScrollPane();
145  orgDescriptionTextArea = new javax.swing.JTextArea();
146  newButton = new javax.swing.JButton();
147  deleteButton = new javax.swing.JButton();
148  closeButton = new javax.swing.JButton();
149  orgListLabel = new javax.swing.JLabel();
150  jSeparator1 = new javax.swing.JSeparator();
151  pocNameLabel = new javax.swing.JLabel();
152  pocPhoneLabel = new javax.swing.JLabel();
153  pocEmailLabel = new javax.swing.JLabel();
154  orgNameLabel = new javax.swing.JLabel();
155  orgNameTextField = new javax.swing.JTextField();
156  pocNameTextField = new javax.swing.JTextField();
157  pocPhoneTextField = new javax.swing.JTextField();
158  pocEmailTextField = new javax.swing.JTextField();
159  editButton = new javax.swing.JButton();
160  orgDetailsLabel = new javax.swing.JLabel();
161 
162  setMinimumSize(new java.awt.Dimension(545, 415));
163 
164  manageOrganizationsScrollPane.setMinimumSize(null);
165  manageOrganizationsScrollPane.setPreferredSize(new java.awt.Dimension(535, 415));
166 
167  manageOrganizationsPanel.setPreferredSize(new java.awt.Dimension(527, 407));
168 
169  organizationList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
170  orgListScrollPane.setViewportView(organizationList);
171 
172  orgDescriptionTextArea.setEditable(false);
173  orgDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
174  orgDescriptionTextArea.setColumns(20);
175  orgDescriptionTextArea.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N
176  orgDescriptionTextArea.setLineWrap(true);
177  orgDescriptionTextArea.setRows(3);
178  orgDescriptionTextArea.setText(org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgDescriptionTextArea.text")); // NOI18N
179  orgDescriptionTextArea.setWrapStyleWord(true);
180  orgDescriptionScrollPane.setViewportView(orgDescriptionTextArea);
181 
182  org.openide.awt.Mnemonics.setLocalizedText(newButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.newButton.text")); // NOI18N
183  newButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
184  newButton.setMaximumSize(new java.awt.Dimension(70, 23));
185  newButton.setMinimumSize(new java.awt.Dimension(70, 23));
186  newButton.setPreferredSize(new java.awt.Dimension(70, 23));
187  newButton.addActionListener(new java.awt.event.ActionListener() {
188  public void actionPerformed(java.awt.event.ActionEvent evt) {
189  newButtonActionPerformed(evt);
190  }
191  });
192 
193  org.openide.awt.Mnemonics.setLocalizedText(deleteButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.deleteButton.text")); // NOI18N
194  deleteButton.setMargin(new java.awt.Insets(2, 6, 2, 6));
195  deleteButton.setMaximumSize(new java.awt.Dimension(70, 23));
196  deleteButton.setMinimumSize(new java.awt.Dimension(70, 23));
197  deleteButton.setPreferredSize(new java.awt.Dimension(70, 23));
198  deleteButton.addActionListener(new java.awt.event.ActionListener() {
199  public void actionPerformed(java.awt.event.ActionEvent evt) {
200  deleteButtonActionPerformed(evt);
201  }
202  });
203 
204  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.closeButton.text")); // NOI18N
205  closeButton.addActionListener(new java.awt.event.ActionListener() {
206  public void actionPerformed(java.awt.event.ActionEvent evt) {
207  closeButtonActionPerformed(evt);
208  }
209  });
210 
211  org.openide.awt.Mnemonics.setLocalizedText(orgListLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgListLabel.text")); // NOI18N
212 
213  jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
214 
215  org.openide.awt.Mnemonics.setLocalizedText(pocNameLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocNameLabel.text")); // NOI18N
216 
217  org.openide.awt.Mnemonics.setLocalizedText(pocPhoneLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocPhoneLabel.text")); // NOI18N
218 
219  org.openide.awt.Mnemonics.setLocalizedText(pocEmailLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.pocEmailLabel.text")); // NOI18N
220 
221  org.openide.awt.Mnemonics.setLocalizedText(orgNameLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgNameLabel.text")); // NOI18N
222 
223  orgNameTextField.setEditable(false);
224 
225  pocNameTextField.setEditable(false);
226 
227  pocPhoneTextField.setEditable(false);
228 
229  pocEmailTextField.setEditable(false);
230 
231  org.openide.awt.Mnemonics.setLocalizedText(editButton, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.editButton.text")); // NOI18N
232  editButton.setMaximumSize(new java.awt.Dimension(70, 23));
233  editButton.setMinimumSize(new java.awt.Dimension(70, 23));
234  editButton.setPreferredSize(new java.awt.Dimension(70, 23));
235  editButton.addActionListener(new java.awt.event.ActionListener() {
236  public void actionPerformed(java.awt.event.ActionEvent evt) {
237  editButtonActionPerformed(evt);
238  }
239  });
240 
241  org.openide.awt.Mnemonics.setLocalizedText(orgDetailsLabel, org.openide.util.NbBundle.getMessage(ManageOrganizationsDialog.class, "ManageOrganizationsDialog.orgDetailsLabel.text")); // NOI18N
242 
243  javax.swing.GroupLayout manageOrganizationsPanelLayout = new javax.swing.GroupLayout(manageOrganizationsPanel);
244  manageOrganizationsPanel.setLayout(manageOrganizationsPanelLayout);
245  manageOrganizationsPanelLayout.setHorizontalGroup(
246  manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
248  .addContainerGap()
249  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
250  .addComponent(orgDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
251  .addComponent(orgListLabel)
252  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
253  .addComponent(newButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
254  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255  .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
256  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
257  .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
258  .addComponent(orgListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE))
259  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
260  .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
261  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
262  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
263  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
264  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
265  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
266  .addComponent(closeButton))
267  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
268  .addGap(29, 29, 29)
269  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
270  .addComponent(pocNameLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
271  .addComponent(orgNameLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
272  .addComponent(pocPhoneLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
273  .addComponent(pocEmailLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
274  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
275  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
276  .addComponent(pocNameTextField)
277  .addComponent(pocPhoneTextField)
278  .addComponent(pocEmailTextField, javax.swing.GroupLayout.Alignment.TRAILING)
279  .addComponent(orgNameTextField))))
280  .addContainerGap())
281  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
282  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
283  .addComponent(orgDetailsLabel)
284  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
285  );
286  manageOrganizationsPanelLayout.setVerticalGroup(
287  manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
288  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
289  .addContainerGap()
290  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
291  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
292  .addComponent(orgDetailsLabel)
293  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
294  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
295  .addComponent(orgNameLabel)
296  .addComponent(orgNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
297  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
298  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
299  .addComponent(pocNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
300  .addComponent(pocNameLabel))
301  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
302  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
303  .addComponent(pocPhoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
304  .addComponent(pocPhoneLabel))
305  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
306  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
307  .addComponent(pocEmailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
308  .addComponent(pocEmailLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
309  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
310  .addComponent(closeButton))
311  .addComponent(jSeparator1)
312  .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
313  .addComponent(orgDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
314  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
315  .addComponent(orgListLabel)
316  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
317  .addComponent(orgListScrollPane)
318  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
319  .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
320  .addComponent(newButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
321  .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
322  .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
323  .addContainerGap())
324  );
325 
326  manageOrganizationsScrollPane.setViewportView(manageOrganizationsPanel);
327 
328  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
329  getContentPane().setLayout(layout);
330  layout.setHorizontalGroup(
331  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
332  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
333  .addGap(0, 0, 0)
334  .addComponent(manageOrganizationsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
335  );
336  layout.setVerticalGroup(
337  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
338  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
339  .addGap(0, 0, 0)
340  .addComponent(manageOrganizationsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
341  );
342 
343  pack();
344  }// </editor-fold>//GEN-END:initComponents
345 
346  private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
347  EamOrganization orgToDelete = organizationList.getSelectedValue();
348  if (orgToDelete != null) {
349  if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
350  Bundle.ManageOrganizationsDialog_confirmDeletion_message(),
351  Bundle.ManageOrganizationsDialog_confirmDeletion_title(),
352  JOptionPane.YES_NO_OPTION)) {
353  try {
354  EamDb.getInstance().deleteOrganization(orgToDelete);
355  populateList();
356  } catch (EamDbException ex) {
357  JOptionPane.showMessageDialog(this,
358  ex.getMessage(), Bundle.ManageOrganizationsDialog_unableToDeleteOrg_title(), JOptionPane.WARNING_MESSAGE);
359  logger.log(Level.INFO, "Was unable to delete organization from central repository", ex);
360  }
361  }
362  }
363  }//GEN-LAST:event_deleteButtonActionPerformed
364 
365  private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
366  dispose();
367  }//GEN-LAST:event_closeButtonActionPerformed
368 
369  private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
370  AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog();
371  if (dialogO.isChanged()) {
372  try {
373  newOrg = dialogO.getNewOrg();
374  populateListAndSelect(dialogO.getNewOrg());
375  } catch (EamDbException ex) {
376 
377  }
378  }
379  }//GEN-LAST:event_newButtonActionPerformed
380 
381  private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
382  EamOrganization orgToEdit = organizationList.getSelectedValue();
383  if (orgToEdit != null) {
384  AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog(orgToEdit);
385  if (dialogO.isChanged()) {
386  try {
387  newOrg = dialogO.getNewOrg();
388  populateListAndSelect(dialogO.getNewOrg());
389  } catch (EamDbException ex) {
390 
391  }
392  }
393  }
394  }//GEN-LAST:event_editButtonActionPerformed
395 
396 
397  // Variables declaration - do not modify//GEN-BEGIN:variables
398  private javax.swing.JButton closeButton;
399  private javax.swing.JButton deleteButton;
400  private javax.swing.JButton editButton;
401  private javax.swing.JSeparator jSeparator1;
402  private javax.swing.JPanel manageOrganizationsPanel;
403  private javax.swing.JScrollPane manageOrganizationsScrollPane;
404  private javax.swing.JButton newButton;
405  private javax.swing.JScrollPane orgDescriptionScrollPane;
406  private javax.swing.JTextArea orgDescriptionTextArea;
407  private javax.swing.JLabel orgDetailsLabel;
408  private javax.swing.JLabel orgListLabel;
409  private javax.swing.JScrollPane orgListScrollPane;
410  private javax.swing.JLabel orgNameLabel;
411  private javax.swing.JTextField orgNameTextField;
412  private javax.swing.JList<EamOrganization> organizationList;
413  private javax.swing.JLabel pocEmailLabel;
414  private javax.swing.JTextField pocEmailTextField;
415  private javax.swing.JLabel pocNameLabel;
416  private javax.swing.JTextField pocNameTextField;
417  private javax.swing.JLabel pocPhoneLabel;
418  private javax.swing.JTextField pocPhoneTextField;
419  // End of variables declaration//GEN-END:variables
420  public boolean isChanged() {
421  return newOrg != null;
422  }
423 
425  return newOrg;
426  }
427 
428  private void setButtonsEnabled(EamOrganization selectedOrg) {
429  boolean isSelected = (selectedOrg != null);
430  boolean isDefaultOrg = false;
431  if(selectedOrg != null){
432  isDefaultOrg = EamDbUtil.isDefaultOrg(selectedOrg);
433  }
434 
435  editButton.setEnabled(isSelected && (! isDefaultOrg));
436  deleteButton.setEnabled(isSelected && (! isDefaultOrg));
437  }
438 
442  private final class OrganizationListSelectionListener implements ListSelectionListener {
443 
444  @Override
445  public void valueChanged(ListSelectionEvent e) {
446  if (e.getValueIsAdjusting()) {
447  return;
448  }
449  EamOrganization selected = organizationList.getSelectedValue();
450  setButtonsEnabled(selected);
451  if (selected != null) {
452  orgNameTextField.setText(selected.getName());
453  pocNameTextField.setText(selected.getPocName());
454  pocPhoneTextField.setText(selected.getPocPhone());
455  pocEmailTextField.setText(selected.getPocEmail());
456  } else {
457  orgNameTextField.setText("");
458  pocNameTextField.setText("");
459  pocPhoneTextField.setText("");
460  pocEmailTextField.setText("");
461  }
462  }
463  }
464 
465 }
static boolean isDefaultOrg(EamOrganization org)
Definition: EamDbUtil.java:260
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
void deleteOrganization(EamOrganization organizationToDelete)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.