X-Git-Url: https://harishankar.org/repos/?p=habeas.git;a=blobdiff_plain;f=src%2Fhabeas%2FNoticesReportViewDialog.java;h=4563f6445ba81ed804fa4f4e7263e977a870f2e1;hp=8852409f511531cdc2cbfcbd7a90b46d40d49a84;hb=1e2e20a0dbc54a7395acba80a96bf5b41105af8e;hpb=703ad2090595c7cf19f92a58b95ce197c60bf5ea diff --git a/src/habeas/NoticesReportViewDialog.java b/src/habeas/NoticesReportViewDialog.java index 8852409..4563f64 100644 --- a/src/habeas/NoticesReportViewDialog.java +++ b/src/habeas/NoticesReportViewDialog.java @@ -48,6 +48,7 @@ public class NoticesReportViewDialog extends javax.swing.JDialog { popMenu = new javax.swing.JPopupMenu(); menuExportCSV = new javax.swing.JMenuItem(); + menuExportHTML = new javax.swing.JMenuItem(); labelReportTitle = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); tableReport = new javax.swing.JTable(); @@ -66,6 +67,15 @@ public class NoticesReportViewDialog extends javax.swing.JDialog { }); popMenu.add(menuExportCSV); + menuExportHTML.setMnemonic('H'); + menuExportHTML.setText("Export as HTML..."); + menuExportHTML.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuExportHTMLActionPerformed(evt); + } + }); + popMenu.add(menuExportHTML); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("View Report"); setLocationByPlatform(true); @@ -166,6 +176,25 @@ public class NoticesReportViewDialog extends javax.swing.JDialog { } }//GEN-LAST:event_buttonApplyActionPerformed + + private void menuExportHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuExportHTMLActionPerformed + // TODO add your handling code here: + JFileChooser chooser = new JFileChooser (); + FileNameExtensionFilter flt = new FileNameExtensionFilter("Hypertext Markup File (.html)", "html"); + chooser.setFileFilter(flt); + int rt = chooser.showSaveDialog(this); + if (rt == JFileChooser.APPROVE_OPTION) { + String filepath = chooser.getSelectedFile().getAbsolutePath(); + if (! (filepath.endsWith(".html") || filepath.endsWith(".htm")) ) + filepath = filepath.concat(".html"); + boolean ret= Utility.saveReportHTML (filepath, reportTitle, reportCols, reportData); + if (ret == false) + JOptionPane.showMessageDialog (this, ERROR_SAVING_REPORT); + else + JOptionPane.showMessageDialog(this, REPORT_SAVED_SUCCESSFULLY); + + } + }//GEN-LAST:event_menuExportHTMLActionPerformed private static final String REPORT_SAVED_SUCCESSFULLY = "Report saved successfully"; private static final String ERROR_SAVING_REPORT = "Error saving report"; @@ -218,6 +247,7 @@ public class NoticesReportViewDialog extends javax.swing.JDialog { private javax.swing.JScrollPane jScrollPane2; private javax.swing.JLabel labelReportTitle; private javax.swing.JMenuItem menuExportCSV; + private javax.swing.JMenuItem menuExportHTML; private javax.swing.JPopupMenu popMenu; private javax.swing.JTable tableReport; // End of variables declaration//GEN-END:variables