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

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.