Skip to content

Commit

Permalink
Merge pull request #1163 from sidheshenator/report_generation_panel_fix
Browse files Browse the repository at this point in the history
Cancel button disabled on report generation completion(with or without e...
  • Loading branch information
rcordovano committed Apr 16, 2015
2 parents 9493c3d + 772c677 commit 87cbca1
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 159 deletions.
8 changes: 3 additions & 5 deletions Core/src/org/sleuthkit/autopsy/report/Bundle.properties
Expand Up @@ -11,12 +11,9 @@ ReportVisualPanel2.advancedButton.text=Data Types
ArtifactSelectionDialog.deselectAllButton.text=Deselect All
ArtifactSelectionDialog.selectAllButton.text=Select All
ReportGenerationPanel.closeButton.text=Close
ReportGenerationPanel.cancelAllButton.text=Cancel All
ReportProgressPanel.reportLabel.text=reportLabel
ReportProgressPanel.pathLabel.text=pathLabel
ReportProgressPanel.separationLabel.text=-
ReportProgressPanel.cancelButton.toolTipText=Queuing
ReportProgressPanel.cancelButton.text=Cancel
ReportProgressPanel.processingLabel.text=processingLabel
ReportGenerationPanel.titleLabel.text=Report Generation Progress
ReportVisualPanel2.taggedResultsRadioButton.text=Tagged Results
Expand Down Expand Up @@ -65,7 +62,7 @@ ReportExcel.cellVal.examiner=Examiner\:
ReportExcel.cellVal.numImages=Number of Images\:
ReportGenerationPanel.confDlg.sureToClose.msg=Are you sure you'd like to close the dialog?\nAll reports will be canceled.
ReportGenerationPanel.confDlg.title.closing=Closing
ReportGenerationPanel.confDlg.cancelReports.msg=Are you sure you'd like to cancel all the reports?
ReportGenerationPanel.confDlg.cancelReport.msg=Are you sure you'd like to cancel the report?
ReportGenerator.displayProgress.title.text=Report Generation Progress...
ReportGenerator.progress.queryingDb.text=Querying database...
ReportGenerator.progress.processingFile.text=Now processing {0}
Expand Down Expand Up @@ -251,4 +248,5 @@ ReportGenerator.errList.failedQueryHashsetHits=Failed to query hashsets hits.
ReportGenerator.errList.coreExceptionWhileGenRptRow=Core exception while generating row data for artifact report.
ReportKML.latLongStartPoint={0};{1};;{2} (Start)\n
ReportKML.latLongEndPoint={0};{1};;{2} (End)\n

ReportGenerationPanel.cancelButton.actionCommand=Cancel
ReportGenerationPanel.cancelButton.text=Cancel
15 changes: 9 additions & 6 deletions Core/src/org/sleuthkit/autopsy/report/ReportGenerationPanel.form
Expand Up @@ -32,8 +32,8 @@
<EmptySpace min="0" pref="522" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
<Component id="cancelAllButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="546" max="32767" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="closeButton" min="-2" max="-2" attributes="0"/>
</Group>
Expand All @@ -56,7 +56,7 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="closeButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelAllButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -74,14 +74,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelAllButton">
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportGenerationPanel.cancelAllButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportGenerationPanel.cancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportGenerationPanel.cancelButton.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelAllButtonActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="reportScrollPane">
Expand Down
67 changes: 28 additions & 39 deletions Core/src/org/sleuthkit/autopsy/report/ReportGenerationPanel.java
Expand Up @@ -20,8 +20,6 @@

import java.awt.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Box;
import javax.swing.JOptionPane;

Expand All @@ -30,7 +28,7 @@

class ReportGenerationPanel extends javax.swing.JPanel {
private GridBagConstraints c;
private List<ReportProgressPanel> progressPanels;
ReportProgressPanel progressPanel;
private Component glue;
private ActionListener actionListener;

Expand All @@ -44,7 +42,6 @@ public ReportGenerationPanel() {

private void customInit() {
reportPanel.setLayout(new GridBagLayout());
progressPanels = new ArrayList<ReportProgressPanel>();
c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
Expand All @@ -64,33 +61,30 @@ public ReportProgressPanel addReport(String reportName, String reportPath) {
// Remove the glue
reportPanel.remove(glue);

// Add the new panel
ReportProgressPanel panel = new ReportProgressPanel(reportName, reportPath);
progressPanels.add(panel);
progressPanel = new ReportProgressPanel(reportName, reportPath);
c.weighty = 0.0;
c.anchor = GridBagConstraints.NORTH;
reportPanel.add(panel, c);
reportPanel.add(progressPanel, c);
c.gridy++;

// Add the glue back to the bottom
c.weighty = 1.0;
c.anchor = GridBagConstraints.PAGE_END;
reportPanel.add(glue, c);

reportPanel.setPreferredSize(new Dimension(600, progressPanels.size() * 80));
// 80 px per progressPanel.
reportPanel.setPreferredSize(new Dimension(600, 1 * 80));
reportPanel.repaint();
return panel;
return progressPanel;
}

/**
* Close this panel and it's dialog if all reports are done.
*/
void close() {
boolean closeable = true;
for (ReportProgressPanel panel : progressPanels) {
if (panel.getStatus() != ReportStatus.CANCELED && panel.getStatus() != ReportStatus.COMPLETE) {
closeable = false;
}
if (progressPanel.getStatus() != ReportStatus.CANCELED && progressPanel.getStatus() != ReportStatus.COMPLETE && progressPanel.getStatus() != ReportStatus.ERROR) {
closeable = false;
}
if (closeable) {
actionListener.actionPerformed(null);
Expand All @@ -102,20 +96,12 @@ void close() {
"ReportGenerationPanel.confDlg.title.closing"),
JOptionPane.YES_NO_OPTION);
if (result == 0) {
cancelAllReports();
progressPanel.cancel();
actionListener.actionPerformed(null);
}
}
}

/**
* Cancel all reports.
*/
private void cancelAllReports() {
for (ReportProgressPanel panel : progressPanels) {
panel.cancel();
}
}

/**
* This method is called from within the constructor to initialize the form.
Expand All @@ -127,7 +113,7 @@ private void cancelAllReports() {
private void initComponents() {

closeButton = new javax.swing.JButton();
cancelAllButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
reportScrollPane = new javax.swing.JScrollPane();
reportPanel = new javax.swing.JPanel();
titleLabel = new javax.swing.JLabel();
Expand All @@ -143,10 +129,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

org.openide.awt.Mnemonics.setLocalizedText(cancelAllButton, org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class, "ReportGenerationPanel.cancelAllButton.text")); // NOI18N
cancelAllButton.addActionListener(new java.awt.event.ActionListener() {
org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class, "ReportGenerationPanel.cancelButton.text")); // NOI18N
cancelButton.setActionCommand(org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class, "ReportGenerationPanel.cancelButton.actionCommand")); // NOI18N
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelAllButtonActionPerformed(evt);
cancelButtonActionPerformed(evt);
}
});

Expand All @@ -168,7 +155,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

reportScrollPane.setViewportView(reportPanel);

titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 11));
titleLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(ReportGenerationPanel.class, "ReportGenerationPanel.titleLabel.text")); // NOI18N

titleSeparator.setForeground(new java.awt.Color(0, 0, 0));
Expand All @@ -189,8 +176,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(titleLabel)
.addGap(0, 522, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(0, 380, Short.MAX_VALUE)
.addComponent(cancelAllButton)
.addGap(0, 546, Short.MAX_VALUE)
.addComponent(cancelButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(closeButton)))
.addContainerGap())
Expand All @@ -209,7 +196,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(closeButton)
.addComponent(cancelAllButton))
.addComponent(cancelButton))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
Expand All @@ -218,23 +205,25 @@ private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
close();
}//GEN-LAST:event_closeButtonActionPerformed

private void cancelAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelAllButtonActionPerformed
int result = JOptionPane.showConfirmDialog(null, NbBundle.getMessage(this.getClass(),
"ReportGenerationPanel.confDlg.cancelReports.msg"),
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
if(progressPanel.getStatus() == ReportStatus.QUEUING || progressPanel.getStatus() == ReportStatus.RUNNING) {
int result = JOptionPane.showConfirmDialog(null, NbBundle.getMessage(this.getClass(),
"ReportGenerationPanel.confDlg.cancelReport.msg"),
NbBundle.getMessage(this.getClass(),
"ReportGenerationPanel.cancelAllButton.text"),
JOptionPane.YES_NO_OPTION);
"ReportGenerationPanel.cancelButton.text"),
JOptionPane.YES_NO_OPTION);
if (result == 0) {
cancelAllReports();
progressPanel.cancel();
}
}//GEN-LAST:event_cancelAllButtonActionPerformed
}
}//GEN-LAST:event_cancelButtonActionPerformed

void addCloseAction(ActionListener l) {
this.actionListener = l;
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelAllButton;
private javax.swing.JButton cancelButton;
private javax.swing.JButton closeButton;
private javax.swing.JSeparator optionSeparator;
private javax.swing.JPanel reportPanel;
Expand Down
32 changes: 2 additions & 30 deletions Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.form
Expand Up @@ -27,8 +27,7 @@
<Component id="processingLabel" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="reportProgressBar" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="58" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="reportLabel" min="-2" max="-2" attributes="0"/>
Expand All @@ -46,10 +45,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cancelButton" max="32767" attributes="0"/>
<Component id="reportProgressBar" max="32767" attributes="0"/>
</Group>
<Component id="reportProgressBar" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="reportLabel" alignment="3" min="-2" max="-2" attributes="0"/>
Expand All @@ -66,30 +62,6 @@
<SubComponents>
<Component class="javax.swing.JProgressBar" name="reportProgressBar">
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/sleuthkit/autopsy/report/images/report_loading.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportProgressPanel.cancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportProgressPanel.cancelButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="borderPainted" type="boolean" value="false"/>
<Property name="contentAreaFilled" type="boolean" value="false"/>
<Property name="focusPainted" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cancelButtonMouseEntered"/>
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cancelButtonMouseExited"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="reportLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
Expand Down

0 comments on commit 87cbca1

Please sign in to comment.