19 package org.sleuthkit.autopsy.centralrepository.optionspanel;
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;
46 private final DefaultListModel<EamOrganization>
rulesListModel =
new DefaultListModel<>();
49 @Messages({
"ManageOrganizationsDialog.title.text=Manage Organizations"})
54 super((JFrame) WindowManager.getDefault().getMainWindow(),
55 Bundle.ManageOrganizationsDialog_title_text(),
61 private static final long serialVersionUID = 1L;
63 @SuppressWarnings(
"rawtypes")
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);
77 Exceptions.printStackTrace(ex);
83 this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
88 rulesListModel.clear();
90 if (orgs.size() > 0) {
92 rulesListModel.addElement(
org);
93 if (selected != null &&
org.getOrgID() == selected.getOrgID()) {
97 if (orgs.contains(selected)) {
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")
158 setMinimumSize(
new java.awt.Dimension(545, 415));
165 organizationList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
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) {
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) {
201 closeButton.addActionListener(
new java.awt.event.ActionListener() {
202 public void actionPerformed(java.awt.event.ActionEvent evt) {
209 jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
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) {
241 manageOrganizationsPanelLayout.setHorizontalGroup(
242 manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
243 .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
245 .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246 .addComponent(
orgDescriptionScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
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)
263 .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
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)
277 .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
278 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
280 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
282 manageOrganizationsPanelLayout.setVerticalGroup(
283 manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
284 .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
286 .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
287 .addGroup(manageOrganizationsPanelLayout.createSequentialGroup()
289 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
290 .addGroup(manageOrganizationsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
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)
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)
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)
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)
312 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
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))))
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()
332 layout.setVerticalGroup(
333 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
334 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
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)) {
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);
379 if (orgToEdit != null) {
417 return newOrg != null;
425 boolean isSelected = (selectedOrg != null);
426 boolean isDefaultOrg =
false;
427 if(selectedOrg != null){
431 editButton.setEnabled(isSelected && (! isDefaultOrg));
432 deleteButton.setEnabled(isSelected && (! isDefaultOrg));
442 if (e.getValueIsAdjusting()) {
447 if (selected != null) {
static final long serialVersionUID
void editButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField pocPhoneTextField
void closeButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JTextField orgNameTextField
void valueChanged(ListSelectionEvent e)
javax.swing.JList< EamOrganization > organizationList
javax.swing.JButton deleteButton
final DefaultListModel< EamOrganization > rulesListModel
void deleteButtonActionPerformed(java.awt.event.ActionEvent evt)
static boolean isDefaultOrg(EamOrganization org)
static final Logger logger
javax.swing.JScrollPane orgDescriptionScrollPane
javax.swing.JPanel manageOrganizationsPanel
javax.swing.JScrollPane manageOrganizationsScrollPane
javax.swing.JLabel pocPhoneLabel
javax.swing.JLabel pocEmailLabel
ManageOrganizationsDialog()
javax.swing.JLabel pocNameLabel
javax.swing.JLabel orgDetailsLabel
javax.swing.JLabel orgListLabel
javax.swing.JSeparator jSeparator1
List< EamOrganization > getOrganizations()
void newButtonActionPerformed(java.awt.event.ActionEvent evt)
static EamDb getInstance()
javax.swing.JTextArea orgDescriptionTextArea
javax.swing.JScrollPane orgListScrollPane
javax.swing.JTextField pocNameTextField
void populateListAndSelect(EamOrganization selected)
javax.swing.JButton editButton
synchronized static Logger getLogger(String name)
javax.swing.JLabel orgNameLabel
void deleteOrganization(EamOrganization organizationToDelete)
void setButtonsEnabled(EamOrganization selectedOrg)
javax.swing.JButton closeButton
javax.swing.JButton newButton
EamOrganization getNewOrg()
javax.swing.JTextField pocEmailTextField
EamOrganization getNewOrg()