Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CaseInformationPanel.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.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.logging.Level;
24 import javax.swing.JDialog;
26 import org.openide.util.NbBundle.Messages;
27 import org.openide.windows.WindowManager;
28 
32 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
33 class CaseInformationPanel extends javax.swing.JPanel {
34 
35  private static final long serialVersionUID = 1L;
36  private CaseDetailsPanel caseDetailsPanel;
37 
42  CaseInformationPanel() {
43  initComponents();
44  customizeComponents();
45  }
46 
47  @Messages({
48  "CaseInformationPanel.caseDetails.header=Details",
49  "CaseInformationPanel.editDetailsButton.text=Edit Details",
50  "CaseInformationPanel.editDetailsDialog.title=Edit Case Details"
51  })
52  private void customizeComponents() {
53  try {
54  caseDetailsPanel = new CaseDetailsPanel(Case.getCurrentCaseThrows());
55  } catch (NoCurrentCaseException ex) {
56  Logger.getLogger(CaseInformationPanel.class.getName()).log(Level.INFO, "Exception while getting open case.", ex);
57  }
58  caseDetailsPanel.setSize(caseDetailsPanel.getPreferredSize());
59  this.detailsPanel.add(caseDetailsPanel);
60  this.detailsPanel.setPreferredSize(caseDetailsPanel.getPreferredSize());
61  }
62 
68  void addCloseButtonAction(ActionListener action) {
69  this.closeButton.addActionListener(action);
70  }
71 
77  @SuppressWarnings("unchecked")
78  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
79  private void initComponents() {
80 
81  outerDetailsPanel = new javax.swing.JPanel();
82  closeButton = new javax.swing.JButton();
83  editDetailsButton = new javax.swing.JButton();
84  detailsPanel = new javax.swing.JPanel();
85 
86  org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(CaseInformationPanel.class, "CaseInformationPanel.closeButton.text")); // NOI18N
87 
88  org.openide.awt.Mnemonics.setLocalizedText(editDetailsButton, org.openide.util.NbBundle.getMessage(CaseInformationPanel.class, "CaseInformationPanel.editDetailsButton.text")); // NOI18N
89  editDetailsButton.addActionListener(new java.awt.event.ActionListener() {
90  public void actionPerformed(java.awt.event.ActionEvent evt) {
91  editDetailsButtonActionPerformed(evt);
92  }
93  });
94 
95  javax.swing.GroupLayout detailsPanelLayout = new javax.swing.GroupLayout(detailsPanel);
96  detailsPanel.setLayout(detailsPanelLayout);
97  detailsPanelLayout.setHorizontalGroup(
98  detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99  .addGap(0, 709, Short.MAX_VALUE)
100  );
101  detailsPanelLayout.setVerticalGroup(
102  detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
103  .addGap(0, 219, Short.MAX_VALUE)
104  );
105 
106  javax.swing.GroupLayout outerDetailsPanelLayout = new javax.swing.GroupLayout(outerDetailsPanel);
107  outerDetailsPanel.setLayout(outerDetailsPanelLayout);
108  outerDetailsPanelLayout.setHorizontalGroup(
109  outerDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110  .addGroup(outerDetailsPanelLayout.createSequentialGroup()
111  .addContainerGap()
112  .addComponent(editDetailsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
113  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 502, Short.MAX_VALUE)
114  .addComponent(closeButton)
115  .addContainerGap())
116  .addGroup(outerDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117  .addComponent(detailsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
118  );
119  outerDetailsPanelLayout.setVerticalGroup(
120  outerDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121  .addGroup(outerDetailsPanelLayout.createSequentialGroup()
122  .addContainerGap(228, Short.MAX_VALUE)
123  .addGroup(outerDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
124  .addComponent(closeButton)
125  .addComponent(editDetailsButton))
126  .addContainerGap())
127  .addGroup(outerDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
128  .addGroup(outerDetailsPanelLayout.createSequentialGroup()
129  .addComponent(detailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
130  .addGap(0, 43, Short.MAX_VALUE)))
131  );
132 
133  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
134  this.setLayout(layout);
135  layout.setHorizontalGroup(
136  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137  .addGroup(layout.createSequentialGroup()
138  .addGap(0, 0, 0)
139  .addComponent(outerDetailsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
140  .addGap(0, 0, 0))
141  );
142  layout.setVerticalGroup(
143  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144  .addComponent(outerDetailsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
145  );
146  }// </editor-fold>//GEN-END:initComponents
147 
148  private void editDetailsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editDetailsButtonActionPerformed
149  JDialog editCasePropertiesDialog = new JDialog(WindowManager.getDefault().getMainWindow(), Bundle.CaseInformationPanel_editDetailsDialog_title(), true);
150  EditOptionalCasePropertiesPanel editCasePropertiesPanel = new EditOptionalCasePropertiesPanel();
151  editCasePropertiesPanel.addCancelButtonAction((ActionEvent e) -> {
152  editCasePropertiesDialog.setVisible(false);
153  });
154  editCasePropertiesPanel.addSaveButtonAction((ActionEvent e) -> {
155  editCasePropertiesDialog.setVisible(false);
156  editCasePropertiesPanel.saveProperties();
157  caseDetailsPanel.updateCaseInfo();
158 
159  });
160 
161  editCasePropertiesDialog.add(editCasePropertiesPanel);
162  editCasePropertiesDialog.setResizable(true);
163  editCasePropertiesDialog.pack();
164  editCasePropertiesDialog.setLocationRelativeTo(this);
165  // Workaround to ensure dialog is not hidden on macOS
166  editCasePropertiesDialog.setAlwaysOnTop(true);
167  editCasePropertiesDialog.setVisible(true);
168  editCasePropertiesDialog.toFront();
169  caseDetailsPanel.updateCaseInfo();
170  }//GEN-LAST:event_editDetailsButtonActionPerformed
171 
172  // Variables declaration - do not modify//GEN-BEGIN:variables
173  private javax.swing.JButton closeButton;
174  private javax.swing.JPanel detailsPanel;
175  private javax.swing.JButton editDetailsButton;
176  private javax.swing.JPanel outerDetailsPanel;
177  // End of variables declaration//GEN-END:variables
178 }

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