19 package org.sleuthkit.autopsy.report;
22 import java.awt.event.ActionListener;
23 import javax.swing.Box;
24 import javax.swing.JOptionPane;
26 import org.openide.util.NbBundle;
29 class ReportGenerationPanel
extends javax.swing.JPanel {
30 private GridBagConstraints c;
31 ReportProgressPanel progressPanel;
32 private Component glue;
33 private ActionListener actionListener;
38 public ReportGenerationPanel() {
43 private void customInit() {
44 reportPanel.setLayout(
new GridBagLayout());
45 c =
new GridBagConstraints();
46 c.fill = GridBagConstraints.BOTH;
50 glue = Box.createVerticalGlue();
60 public ReportProgressPanel addReport(String reportName, String reportPath) {
62 reportPanel.remove(glue);
64 progressPanel =
new ReportProgressPanel(reportName, reportPath);
66 c.anchor = GridBagConstraints.NORTH;
67 reportPanel.add(progressPanel, c);
72 c.anchor = GridBagConstraints.PAGE_END;
73 reportPanel.add(glue, c);
76 reportPanel.setPreferredSize(
new Dimension(600, 1 * 80));
77 reportPanel.repaint();
85 boolean closeable =
true;
86 if (progressPanel.getStatus() != ReportStatus.CANCELED && progressPanel.getStatus() != ReportStatus.COMPLETE && progressPanel.getStatus() != ReportStatus.ERROR) {
90 actionListener.actionPerformed(null);
92 int result = JOptionPane.showConfirmDialog(null,
93 NbBundle.getMessage(
this.getClass(),
94 "ReportGenerationPanel.confDlg.sureToClose.msg"),
95 NbBundle.getMessage(
this.getClass(),
96 "ReportGenerationPanel.confDlg.title.closing"),
97 JOptionPane.YES_NO_OPTION);
99 progressPanel.cancel();
100 actionListener.actionPerformed(null);
111 @SuppressWarnings(
"unchecked")
113 private
void initComponents() {
115 closeButton =
new javax.swing.JButton();
116 cancelButton =
new javax.swing.JButton();
117 reportScrollPane =
new javax.swing.JScrollPane();
118 reportPanel =
new javax.swing.JPanel();
119 titleLabel =
new javax.swing.JLabel();
120 titleSeparator =
new javax.swing.JSeparator();
121 optionSeparator =
new javax.swing.JSeparator();
123 setPreferredSize(
new java.awt.Dimension(700, 400));
125 org.openide.awt.Mnemonics.setLocalizedText(closeButton,
org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class,
"ReportGenerationPanel.closeButton.text"));
126 closeButton.addActionListener(
new java.awt.event.ActionListener() {
127 public void actionPerformed(java.awt.event.ActionEvent evt) {
128 closeButtonActionPerformed(evt);
132 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class,
"ReportGenerationPanel.cancelButton.text"));
133 cancelButton.setActionCommand(
org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class,
"ReportGenerationPanel.cancelButton.actionCommand"));
134 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
135 public void actionPerformed(java.awt.event.ActionEvent evt) {
136 cancelButtonActionPerformed(evt);
140 reportScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.SystemColor.activeCaptionBorder));
141 reportScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
143 reportPanel.setPreferredSize(
new java.awt.Dimension(600, 400));
145 javax.swing.GroupLayout reportPanelLayout =
new javax.swing.GroupLayout(reportPanel);
146 reportPanel.setLayout(reportPanelLayout);
147 reportPanelLayout.setHorizontalGroup(
148 reportPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
149 .addGap(0, 661, Short.MAX_VALUE)
151 reportPanelLayout.setVerticalGroup(
152 reportPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
153 .addGap(0, 400, Short.MAX_VALUE)
156 reportScrollPane.setViewportView(reportPanel);
158 titleLabel.setFont(
new java.awt.Font(
"Tahoma", 1, 11));
159 org.openide.awt.Mnemonics.setLocalizedText(titleLabel,
org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class,
"ReportGenerationPanel.titleLabel.text"));
161 titleSeparator.setForeground(
new java.awt.Color(0, 0, 0));
163 optionSeparator.setForeground(
new java.awt.Color(0, 0, 0));
165 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
166 this.setLayout(layout);
167 layout.setHorizontalGroup(
168 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
169 .addComponent(optionSeparator)
170 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
172 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
173 .addComponent(reportScrollPane)
174 .addComponent(titleSeparator, javax.swing.GroupLayout.Alignment.LEADING)
175 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
176 .addComponent(titleLabel)
177 .addGap(0, 522, Short.MAX_VALUE))
178 .addGroup(layout.createSequentialGroup()
179 .addGap(0, 546, Short.MAX_VALUE)
180 .addComponent(cancelButton)
181 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
182 .addComponent(closeButton)))
185 layout.setVerticalGroup(
186 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 .addGroup(layout.createSequentialGroup()
189 .addComponent(titleLabel)
191 .addComponent(titleSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
193 .addComponent(reportScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)
195 .addComponent(optionSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
196 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
197 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
198 .addComponent(closeButton)
199 .addComponent(cancelButton))
204 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
208 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
209 if(progressPanel.getStatus() == ReportStatus.QUEUING || progressPanel.getStatus() == ReportStatus.RUNNING) {
210 int result = JOptionPane.showConfirmDialog(null, NbBundle.getMessage(
this.getClass(),
211 "ReportGenerationPanel.confDlg.cancelReport.msg"),
212 NbBundle.getMessage(
this.getClass(),
213 "ReportGenerationPanel.cancelButton.text"),
214 JOptionPane.YES_NO_OPTION);
216 progressPanel.cancel();
221 void addCloseAction(ActionListener l) {
222 this.actionListener = l;
226 private javax.swing.JButton cancelButton;
227 private javax.swing.JButton closeButton;
228 private javax.swing.JSeparator optionSeparator;
229 private javax.swing.JPanel reportPanel;
230 private javax.swing.JScrollPane reportScrollPane;
231 private javax.swing.JLabel titleLabel;
232 private javax.swing.JSeparator titleSeparator;