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