Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OptionalCasePropertiesPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.casemodule;
20 
21 import java.awt.Cursor;
22 import java.awt.Dialog;
23 import java.util.logging.Level;
24 import javax.swing.JComboBox;
25 import javax.swing.SwingUtilities;
26 import org.openide.util.NbBundle.Messages;
35 
40 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
41 final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
42 
43  private final static Logger logger = Logger.getLogger(OptionalCasePropertiesPanel.class.getName());
44  private static final long serialVersionUID = 1L;
45  private CentralRepoOrganization selectedOrg = null;
46  private java.util.List<CentralRepoOrganization> orgs = null;
47 
51  OptionalCasePropertiesPanel() {
52  initComponents();
53  caseDisplayNameLabel.setVisible(false);
54  caseDisplayNameTextField.setVisible(false);
55  lbPointOfContactNameLabel.setVisible(false);
56  lbPointOfContactNameText.setVisible(false);
57  lbPointOfContactPhoneLabel.setVisible(false);
58  lbPointOfContactPhoneText.setVisible(false);
59  lbPointOfContactEmailLabel.setVisible(false);
60  lbPointOfContactEmailText.setVisible(false);
61  }
62 
63  OptionalCasePropertiesPanel(boolean editCurrentCase) {
64  initComponents();
65  if (editCurrentCase) {
66  Case openCase;
67  try {
68  openCase = Case.getCurrentCaseThrows();
69  } catch (NoCurrentCaseException ex) {
70  logger.log(Level.SEVERE, "Exception while getting open case.", ex);
71  return;
72  }
73  caseDisplayNameTextField.setText(openCase.getDisplayName());
74  caseNumberTextField.setText(openCase.getNumber());
75  examinerTextField.setText(openCase.getExaminer());
76  tfExaminerEmailText.setText(openCase.getExaminerEmail());
77  tfExaminerPhoneText.setText(openCase.getExaminerPhone());
78  taNotesText.setText(openCase.getCaseNotes());
79  setUpCaseDetailsFields();
80  setUpOrganizationData();
81  } else {
82  caseDisplayNameLabel.setVisible(false);
83  caseDisplayNameTextField.setVisible(false);
84  lbPointOfContactNameLabel.setVisible(false);
85  lbPointOfContactNameText.setVisible(false);
86  lbPointOfContactPhoneLabel.setVisible(false);
87  lbPointOfContactPhoneText.setVisible(false);
88  lbPointOfContactEmailLabel.setVisible(false);
89  lbPointOfContactEmailText.setVisible(false);
90  setUpCaseDetailsFields();
91  }
92 
93  }
94 
95  private void setUpOrganizationData() {
96  if (CentralRepository.isEnabled()) {
97  try {
98  Case currentCase = Case.getCurrentCaseThrows();
99  if (currentCase != null) {
100  CentralRepository dbManager = CentralRepository.getInstance();
101  selectedOrg = dbManager.getCase(currentCase).getOrg();
102  }
103  } catch (CentralRepoException ex) {
104  logger.log(Level.SEVERE, "Unable to get Organization associated with the case from Central Repo", ex);
105  } catch (NoCurrentCaseException ex) {
106  logger.log(Level.SEVERE, "Exception while getting open case.", ex);
107  }
108 
109  if (selectedOrg != null) {
110  setCurrentlySelectedOrganization(selectedOrg.getName());
111  }
112  else {
113  setCurrentlySelectedOrganization(CentralRepoDbUtil.getDefaultOrgName());
114  }
115  }
116  }
117 
118  void setUpCaseDetailsFields() {
119  boolean cREnabled = CentralRepository.isEnabled();
120  comboBoxOrgName.setEnabled(cREnabled);
121  bnNewOrganization.setEnabled(cREnabled);
122  lbPointOfContactNameText.setEnabled(cREnabled);
123  lbPointOfContactEmailText.setEnabled(cREnabled);
124  lbPointOfContactPhoneText.setEnabled(cREnabled);
125  lbOrganizationNameLabel.setEnabled(cREnabled);
126  lbPointOfContactNameLabel.setEnabled(cREnabled);
127  lbPointOfContactEmailLabel.setEnabled(cREnabled);
128  lbPointOfContactPhoneLabel.setEnabled(cREnabled);
129  orgainizationPanel.setEnabled(cREnabled);
130  if (!cREnabled) {
131  clearOrganization();
132  } else {
133  loadOrganizationData();
134  }
135 
136  }
137 
138  private void loadOrganizationData() {
139  Object selectedBeforeLoad = comboBoxOrgName.getSelectedItem();
140  comboBoxOrgName.removeAllItems();
141  try {
142  CentralRepository dbManager = CentralRepository.getInstance();
143  orgs = dbManager.getOrganizations();
144  orgs.forEach((org) -> {
145  comboBoxOrgName.addItem(org.getName());
146  });
147  comboBoxOrgName.setSelectedItem(selectedBeforeLoad);
148  } catch (CentralRepoException ex) {
149  logger.log(Level.WARNING, "Unable to populate list of Organizations from Central Repo", ex);
150  }
151  }
152 
153  private void clearOrganization() {
154  selectedOrg = null;
155  lbPointOfContactNameText.setText("");
156  lbPointOfContactEmailText.setText("");
157  lbPointOfContactPhoneText.setText("");
158  }
159 
160  String getCaseNumber() {
161  return caseNumberTextField.getText();
162  }
163 
164  String getExaminerName() {
165  return examinerTextField.getText();
166  }
167 
168  String getExaminerPhone() {
169  return tfExaminerPhoneText.getText();
170  }
171 
172  String getExaminerEmail() {
173  return tfExaminerEmailText.getText();
174  }
175 
176  String getCaseNotes() {
177  return taNotesText.getText();
178  }
179 
180  String getOrganization() {
181  if (selectedOrg != null) {
182  return selectedOrg.getName();
183  } else {
184  return CentralRepoDbUtil.getDefaultOrgName();
185  }
186  }
187 
188  void setCaseNumberField(String caseNumber) {
189  caseNumberTextField.setText(caseNumber == null ? "" : caseNumber);
190  }
191 
192  void setExaminerNameField(String examinerName) {
193  examinerTextField.setText(examinerName == null ? "" : examinerName);
194  }
195 
196  void setExaminerPhoneField(String examinerPhone) {
197  tfExaminerPhoneText.setText(examinerPhone == null ? "" : examinerPhone);
198  }
199 
200  void setExaminerEmailField(String examinerEmail) {
201  tfExaminerEmailText.setText(examinerEmail == null ? "" : examinerEmail);
202  }
203 
204  void setCaseNotesField(String caseNotes) {
205  taNotesText.setText(caseNotes == null ? "" : caseNotes);
206  }
207 
208  @Messages({"OptionalCasePropertiesPanel.caseDisplayNameLabel.text=Name:",
209  "OptionalCasePropertiesPanel.lbPointOfContactEmailLabel.text=Email:",
210  "OptionalCasePropertiesPanel.lbOrganizationNameLabel.text=Organization analysis is being done for:",
211  "OptionalCasePropertiesPanel.bnNewOrganization.text=Manage Organizations",
212  "OptionalCasePropertiesPanel.lbPointOfContactNameLabel.text=Point of Contact:",
213  "OptionalCasePropertiesPanel.lbPointOfContactPhoneLabel.text=Phone:",
214  "OptionalCasePropertiesPanel.orgainizationPanel.border.title=Organization",
215  "OptionalCasePropertiesPanel.lbNotesLabel.text=Notes:",
216  "OptionalCasePropertiesPanel.examinerLabel.text=Name:",
217  "OptionalCasePropertiesPanel.lbExaminerEmailLabel.text=Email:",
218  "OptionalCasePropertiesPanel.lbExaminerPhoneLabel.text=Phone:",
219  "OptionalCasePropertiesPanel.examinerPanel.border.title=Examiner",
220  "OptionalCasePropertiesPanel.caseNumberLabel.text=Number:",
221  "OptionalCasePropertiesPanel.casePanel.border.title=Case"
222  })
228  @SuppressWarnings("unchecked")
229  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
230  private void initComponents() {
231  java.awt.GridBagConstraints gridBagConstraints;
232 
233  casePanel = new javax.swing.JPanel();
234  caseNumberLabel = new javax.swing.JLabel();
235  caseNumberTextField = new javax.swing.JTextField();
236  caseDisplayNameLabel = new javax.swing.JLabel();
237  caseDisplayNameTextField = new javax.swing.JTextField();
238  examinerPanel = new javax.swing.JPanel();
239  tfExaminerPhoneText = new javax.swing.JTextField();
240  lbExaminerPhoneLabel = new javax.swing.JLabel();
241  caseNotesScrollPane = new javax.swing.JScrollPane();
242  taNotesText = new javax.swing.JTextArea();
243  tfExaminerEmailText = new javax.swing.JTextField();
244  examinerTextField = new javax.swing.JTextField();
245  lbExaminerEmailLabel = new javax.swing.JLabel();
246  examinerLabel = new javax.swing.JLabel();
247  lbNotesLabel = new javax.swing.JLabel();
248  orgainizationPanel = new javax.swing.JPanel();
249  lbPointOfContactPhoneLabel = new javax.swing.JLabel();
250  comboBoxOrgName = new javax.swing.JComboBox<>();
251  lbPointOfContactNameLabel = new javax.swing.JLabel();
252  bnNewOrganization = new javax.swing.JButton();
253  lbPointOfContactEmailText = new javax.swing.JLabel();
254  lbPointOfContactNameText = new javax.swing.JLabel();
255  lbOrganizationNameLabel = new javax.swing.JLabel();
256  lbPointOfContactEmailLabel = new javax.swing.JLabel();
257  lbPointOfContactPhoneText = new javax.swing.JLabel();
258 
259  casePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.casePanel.border.title"))); // NOI18N
260 
261  org.openide.awt.Mnemonics.setLocalizedText(caseNumberLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.caseNumberLabel.text")); // NOI18N
262  caseNumberLabel.setMaximumSize(new java.awt.Dimension(41, 14));
263  caseNumberLabel.setMinimumSize(new java.awt.Dimension(41, 14));
264  caseNumberLabel.setPreferredSize(new java.awt.Dimension(41, 14));
265 
266  org.openide.awt.Mnemonics.setLocalizedText(caseDisplayNameLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.caseDisplayNameLabel.text")); // NOI18N
267  caseDisplayNameLabel.setMaximumSize(new java.awt.Dimension(41, 14));
268  caseDisplayNameLabel.setMinimumSize(new java.awt.Dimension(41, 14));
269  caseDisplayNameLabel.setPreferredSize(new java.awt.Dimension(41, 14));
270  caseDisplayNameLabel.setVerifyInputWhenFocusTarget(false);
271 
272  javax.swing.GroupLayout casePanelLayout = new javax.swing.GroupLayout(casePanel);
273  casePanel.setLayout(casePanelLayout);
274  casePanelLayout.setHorizontalGroup(
275  casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
276  .addGroup(casePanelLayout.createSequentialGroup()
277  .addContainerGap()
278  .addGroup(casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
279  .addComponent(caseNumberLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
280  .addComponent(caseDisplayNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
281  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
282  .addGroup(casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
283  .addComponent(caseNumberTextField)
284  .addComponent(caseDisplayNameTextField))
285  .addContainerGap())
286  );
287  casePanelLayout.setVerticalGroup(
288  casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289  .addGroup(casePanelLayout.createSequentialGroup()
290  .addContainerGap()
291  .addGroup(casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
292  .addComponent(caseDisplayNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
293  .addComponent(caseDisplayNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
294  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
295  .addGroup(casePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
296  .addComponent(caseNumberLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
297  .addComponent(caseNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
298  .addGap(6, 6, 6))
299  );
300 
301  examinerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.examinerPanel.border.title"))); // NOI18N
302 
303  org.openide.awt.Mnemonics.setLocalizedText(lbExaminerPhoneLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbExaminerPhoneLabel.text")); // NOI18N
304  lbExaminerPhoneLabel.setMaximumSize(new java.awt.Dimension(41, 14));
305  lbExaminerPhoneLabel.setMinimumSize(new java.awt.Dimension(41, 14));
306  lbExaminerPhoneLabel.setPreferredSize(new java.awt.Dimension(41, 14));
307 
308  caseNotesScrollPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
309 
310  taNotesText.setColumns(20);
311  taNotesText.setLineWrap(true);
312  taNotesText.setRows(2);
313  taNotesText.setWrapStyleWord(true);
314  taNotesText.setBorder(null);
315  caseNotesScrollPane.setViewportView(taNotesText);
316 
317  org.openide.awt.Mnemonics.setLocalizedText(lbExaminerEmailLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbExaminerEmailLabel.text")); // NOI18N
318  lbExaminerEmailLabel.setMaximumSize(new java.awt.Dimension(41, 14));
319  lbExaminerEmailLabel.setMinimumSize(new java.awt.Dimension(41, 14));
320  lbExaminerEmailLabel.setPreferredSize(new java.awt.Dimension(41, 14));
321 
322  org.openide.awt.Mnemonics.setLocalizedText(examinerLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.examinerLabel.text")); // NOI18N
323  examinerLabel.setMaximumSize(new java.awt.Dimension(41, 14));
324  examinerLabel.setMinimumSize(new java.awt.Dimension(41, 14));
325  examinerLabel.setPreferredSize(new java.awt.Dimension(41, 14));
326 
327  org.openide.awt.Mnemonics.setLocalizedText(lbNotesLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbNotesLabel.text")); // NOI18N
328  lbNotesLabel.setMaximumSize(new java.awt.Dimension(41, 14));
329  lbNotesLabel.setMinimumSize(new java.awt.Dimension(41, 14));
330  lbNotesLabel.setPreferredSize(new java.awt.Dimension(41, 14));
331 
332  javax.swing.GroupLayout examinerPanelLayout = new javax.swing.GroupLayout(examinerPanel);
333  examinerPanel.setLayout(examinerPanelLayout);
334  examinerPanelLayout.setHorizontalGroup(
335  examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
336  .addGroup(examinerPanelLayout.createSequentialGroup()
337  .addContainerGap()
338  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
339  .addGroup(examinerPanelLayout.createSequentialGroup()
340  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
341  .addComponent(lbNotesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
342  .addComponent(lbExaminerPhoneLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
343  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
344  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
345  .addComponent(caseNotesScrollPane)
346  .addComponent(tfExaminerPhoneText)))
347  .addGroup(examinerPanelLayout.createSequentialGroup()
348  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
349  .addComponent(lbExaminerEmailLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
350  .addComponent(examinerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
351  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
352  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
353  .addComponent(examinerTextField)
354  .addComponent(tfExaminerEmailText))))
355  .addGap(11, 11, 11))
356  );
357 
358  examinerPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {examinerLabel, lbExaminerEmailLabel, lbExaminerPhoneLabel, lbNotesLabel});
359 
360  examinerPanelLayout.setVerticalGroup(
361  examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
362  .addGroup(examinerPanelLayout.createSequentialGroup()
363  .addContainerGap()
364  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
365  .addComponent(examinerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
366  .addComponent(examinerTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
367  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
368  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
369  .addComponent(tfExaminerPhoneText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
370  .addComponent(lbExaminerPhoneLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
371  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
372  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
373  .addComponent(tfExaminerEmailText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
374  .addComponent(lbExaminerEmailLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
375  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
376  .addGroup(examinerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
377  .addComponent(lbNotesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
378  .addComponent(caseNotesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
379  .addGap(6, 6, 6))
380  );
381 
382  orgainizationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.orgainizationPanel.border.title"))); // NOI18N
383  orgainizationPanel.setLayout(new java.awt.GridBagLayout());
384 
385  org.openide.awt.Mnemonics.setLocalizedText(lbPointOfContactPhoneLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbPointOfContactPhoneLabel.text")); // NOI18N
386  lbPointOfContactPhoneLabel.setMaximumSize(new java.awt.Dimension(182, 14));
387  lbPointOfContactPhoneLabel.setMinimumSize(new java.awt.Dimension(82, 14));
388  lbPointOfContactPhoneLabel.setPreferredSize(new java.awt.Dimension(120, 14));
389  gridBagConstraints = new java.awt.GridBagConstraints();
390  gridBagConstraints.gridx = 0;
391  gridBagConstraints.gridy = 2;
392  gridBagConstraints.gridwidth = 2;
393  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
394  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
395  gridBagConstraints.insets = new java.awt.Insets(7, 12, 0, 0);
396  orgainizationPanel.add(lbPointOfContactPhoneLabel, gridBagConstraints);
397 
398  comboBoxOrgName.addActionListener(new java.awt.event.ActionListener() {
399  public void actionPerformed(java.awt.event.ActionEvent evt) {
400  comboBoxOrgNameActionPerformed(evt);
401  }
402  });
403  gridBagConstraints = new java.awt.GridBagConstraints();
404  gridBagConstraints.gridx = 2;
405  gridBagConstraints.gridy = 0;
406  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
407  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
408  gridBagConstraints.insets = new java.awt.Insets(8, 18, 0, 0);
409  orgainizationPanel.add(comboBoxOrgName, gridBagConstraints);
410 
411  org.openide.awt.Mnemonics.setLocalizedText(lbPointOfContactNameLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbPointOfContactNameLabel.text")); // NOI18N
412  lbPointOfContactNameLabel.setMaximumSize(new java.awt.Dimension(182, 14));
413  lbPointOfContactNameLabel.setMinimumSize(new java.awt.Dimension(82, 14));
414  lbPointOfContactNameLabel.setPreferredSize(new java.awt.Dimension(120, 14));
415  gridBagConstraints = new java.awt.GridBagConstraints();
416  gridBagConstraints.gridx = 0;
417  gridBagConstraints.gridy = 1;
418  gridBagConstraints.gridwidth = 2;
419  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
420  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
421  gridBagConstraints.insets = new java.awt.Insets(13, 12, 0, 5);
422  orgainizationPanel.add(lbPointOfContactNameLabel, gridBagConstraints);
423 
424  org.openide.awt.Mnemonics.setLocalizedText(bnNewOrganization, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.bnNewOrganization.text")); // NOI18N
425  bnNewOrganization.setMargin(new java.awt.Insets(2, 6, 2, 6));
426  bnNewOrganization.setMaximumSize(new java.awt.Dimension(160, 23));
427  bnNewOrganization.setMinimumSize(new java.awt.Dimension(123, 23));
428  bnNewOrganization.setPreferredSize(new java.awt.Dimension(140, 23));
429  bnNewOrganization.addActionListener(new java.awt.event.ActionListener() {
430  public void actionPerformed(java.awt.event.ActionEvent evt) {
431  bnNewOrganizationActionPerformed(evt);
432  }
433  });
434  gridBagConstraints = new java.awt.GridBagConstraints();
435  gridBagConstraints.gridx = 3;
436  gridBagConstraints.gridy = 0;
437  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
438  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
439  gridBagConstraints.insets = new java.awt.Insets(8, 12, 0, 18);
440  orgainizationPanel.add(bnNewOrganization, gridBagConstraints);
441  gridBagConstraints = new java.awt.GridBagConstraints();
442  gridBagConstraints.gridx = 2;
443  gridBagConstraints.gridy = 3;
444  gridBagConstraints.gridwidth = 2;
445  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
446  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
447  gridBagConstraints.insets = new java.awt.Insets(7, 4, 13, 18);
448  orgainizationPanel.add(lbPointOfContactEmailText, gridBagConstraints);
449  gridBagConstraints = new java.awt.GridBagConstraints();
450  gridBagConstraints.gridx = 2;
451  gridBagConstraints.gridy = 1;
452  gridBagConstraints.gridwidth = 2;
453  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
454  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
455  gridBagConstraints.insets = new java.awt.Insets(13, 4, 0, 18);
456  orgainizationPanel.add(lbPointOfContactNameText, gridBagConstraints);
457 
458  org.openide.awt.Mnemonics.setLocalizedText(lbOrganizationNameLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbOrganizationNameLabel.text")); // NOI18N
459  lbOrganizationNameLabel.setMaximumSize(new java.awt.Dimension(300, 14));
460  lbOrganizationNameLabel.setMinimumSize(new java.awt.Dimension(189, 14));
461  lbOrganizationNameLabel.setPreferredSize(new java.awt.Dimension(220, 14));
462  gridBagConstraints = new java.awt.GridBagConstraints();
463  gridBagConstraints.gridx = 0;
464  gridBagConstraints.gridy = 0;
465  gridBagConstraints.gridwidth = 2;
466  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
467  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
468  gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
469  orgainizationPanel.add(lbOrganizationNameLabel, gridBagConstraints);
470 
471  org.openide.awt.Mnemonics.setLocalizedText(lbPointOfContactEmailLabel, org.openide.util.NbBundle.getMessage(OptionalCasePropertiesPanel.class, "OptionalCasePropertiesPanel.lbPointOfContactEmailLabel.text")); // NOI18N
472  lbPointOfContactEmailLabel.setMaximumSize(new java.awt.Dimension(182, 14));
473  lbPointOfContactEmailLabel.setMinimumSize(new java.awt.Dimension(82, 14));
474  lbPointOfContactEmailLabel.setPreferredSize(new java.awt.Dimension(120, 14));
475  gridBagConstraints = new java.awt.GridBagConstraints();
476  gridBagConstraints.gridx = 0;
477  gridBagConstraints.gridy = 3;
478  gridBagConstraints.gridwidth = 2;
479  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
480  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
481  gridBagConstraints.insets = new java.awt.Insets(7, 12, 13, 0);
482  orgainizationPanel.add(lbPointOfContactEmailLabel, gridBagConstraints);
483  gridBagConstraints = new java.awt.GridBagConstraints();
484  gridBagConstraints.gridx = 2;
485  gridBagConstraints.gridy = 2;
486  gridBagConstraints.gridwidth = 2;
487  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
488  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
489  gridBagConstraints.insets = new java.awt.Insets(7, 4, 0, 18);
490  orgainizationPanel.add(lbPointOfContactPhoneText, gridBagConstraints);
491 
492  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
493  this.setLayout(layout);
494  layout.setHorizontalGroup(
495  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
496  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
497  .addGap(6, 6, 6)
498  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
499  .addComponent(casePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
500  .addComponent(examinerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
501  .addComponent(orgainizationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
502  .addGap(6, 6, 6))
503  );
504  layout.setVerticalGroup(
505  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
506  .addGroup(layout.createSequentialGroup()
507  .addContainerGap()
508  .addComponent(casePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
509  .addGap(0, 0, 0)
510  .addComponent(examinerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
511  .addGap(0, 0, 0)
512  .addComponent(orgainizationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
513  .addGap(0, 0, 0))
514  );
515  }// </editor-fold>//GEN-END:initComponents
516 
517  private void comboBoxOrgNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboBoxOrgNameActionPerformed
518  @SuppressWarnings("unchecked")
519  JComboBox<String> cb = (JComboBox<String>) evt.getSource();
520  String orgName = (String) cb.getSelectedItem();
521  if (null == orgName) {
522  return;
523  }
524  if ("".equals(orgName)) {
525  clearOrganization();
526  return;
527  }
528  for (CentralRepoOrganization org : orgs) {
529  if (org.getName().equals(orgName)) {
530  selectedOrg = org;
531  lbPointOfContactNameText.setText(selectedOrg.getPocName());
532  lbPointOfContactEmailText.setText(selectedOrg.getPocEmail());
533  lbPointOfContactPhoneText.setText(selectedOrg.getPocPhone());
534  return;
535  }
536  }
537  }//GEN-LAST:event_comboBoxOrgNameActionPerformed
538 
539  private void bnNewOrganizationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnNewOrganizationActionPerformed
540  ManageOrganizationsDialog dialog = new ManageOrganizationsDialog((Dialog) SwingUtilities.getWindowAncestor(this));
541  // update the combobox options and org data fields
542  loadOrganizationData();
543  if (dialog.isChanged()) {
544  selectedOrg = dialog.getNewOrg();
545  setCurrentlySelectedOrganization(dialog.getNewOrg().getName());
546  }
547  validate();
548  repaint();
549  }//GEN-LAST:event_bnNewOrganizationActionPerformed
550 
551  void setCurrentlySelectedOrganization(String orgName) {
552  comboBoxOrgName.setSelectedItem(orgName == null ? CentralRepoDbUtil.getDefaultOrgName() : orgName);
553  }
554 
555  @Messages({
556  "OptionalCasePropertiesPanel.errorDialog.emptyCaseNameMessage=No case name entered.",
557  "OptionalCasePropertiesPanel.errorDialog.invalidCaseNameMessage=Case names cannot include the following symbols: \\, /, :, *, ?, \", <, >, |",
558  "OptionalCasePropertiesPanel.errorDialog.noOpenCase.errMsg=Exception while getting open case."
559  })
560  void saveUpdatedCaseDetails() {
561  if (caseDisplayNameTextField.getText().trim().isEmpty()) {
562  MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_emptyCaseNameMessage());
563  return;
564  }
565  if (!Case.isValidName(caseDisplayNameTextField.getText())) {
566  MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_invalidCaseNameMessage());
567  return;
568  }
569  try {
570  updateCaseDetails();
571  } catch (NoCurrentCaseException ex) {
572  MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_noOpenCase_errMsg());
573  return;
574  }
575  updateCorrelationCase();
576  }
577 
578  private void updateCaseDetails() throws NoCurrentCaseException {
579  if (caseDisplayNameTextField.isVisible()) {
580  try {
581  Case.getCurrentCaseThrows().updateCaseDetails(new CaseDetails(
582  caseDisplayNameTextField.getText(), caseNumberTextField.getText(),
583  examinerTextField.getText(), tfExaminerPhoneText.getText(),
584  tfExaminerEmailText.getText(), taNotesText.getText()));
585  } catch (CaseActionException ex) {
586  logger.log(Level.WARNING, "Error updating case details", ex);
587  }
588  }
589  }
590 
595  private void updateCorrelationCase() {
596  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
597  if (CentralRepository.isEnabled()) {
598  try {
599  CentralRepository dbManager = CentralRepository.getInstance();
600  CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCaseThrows());
601  if (caseDisplayNameTextField.isVisible()) {
602  correlationCase.setDisplayName(caseDisplayNameTextField.getText());
603  }
604  correlationCase.setOrg(selectedOrg);
605  correlationCase.setCaseNumber(caseNumberTextField.getText());
606  correlationCase.setExaminerName(examinerTextField.getText());
607  correlationCase.setExaminerEmail(tfExaminerEmailText.getText());
608  correlationCase.setExaminerPhone(tfExaminerPhoneText.getText());
609  correlationCase.setNotes(taNotesText.getText());
610  dbManager.updateCase(correlationCase);
611  } catch (CentralRepoException ex) {
612  logger.log(Level.SEVERE, "Error connecting to central repository database", ex); // NON-NLS
613  } catch (NoCurrentCaseException ex) {
614  logger.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
615  } finally {
616  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
617  }
618  }
619  }
620  // Variables declaration - do not modify//GEN-BEGIN:variables
621  private javax.swing.JButton bnNewOrganization;
622  private javax.swing.JLabel caseDisplayNameLabel;
623  private javax.swing.JTextField caseDisplayNameTextField;
624  private javax.swing.JScrollPane caseNotesScrollPane;
625  private javax.swing.JLabel caseNumberLabel;
626  private javax.swing.JTextField caseNumberTextField;
627  private javax.swing.JPanel casePanel;
628  private javax.swing.JComboBox<String> comboBoxOrgName;
629  private javax.swing.JLabel examinerLabel;
630  private javax.swing.JPanel examinerPanel;
631  private javax.swing.JTextField examinerTextField;
632  private javax.swing.JLabel lbExaminerEmailLabel;
633  private javax.swing.JLabel lbExaminerPhoneLabel;
634  private javax.swing.JLabel lbNotesLabel;
635  private javax.swing.JLabel lbOrganizationNameLabel;
636  private javax.swing.JLabel lbPointOfContactEmailLabel;
637  private javax.swing.JLabel lbPointOfContactEmailText;
638  private javax.swing.JLabel lbPointOfContactNameLabel;
639  private javax.swing.JLabel lbPointOfContactNameText;
640  private javax.swing.JLabel lbPointOfContactPhoneLabel;
641  private javax.swing.JLabel lbPointOfContactPhoneText;
642  private javax.swing.JPanel orgainizationPanel;
643  private javax.swing.JTextArea taNotesText;
644  private javax.swing.JTextField tfExaminerEmailText;
645  private javax.swing.JTextField tfExaminerPhoneText;
646  // End of variables declaration//GEN-END:variables
647 }

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