1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.common.ReportResult; 4 import com.calipso.reportgenerator.common.IReportManager; 5 import com.calipso.reportgenerator.common.InfoException; 6 import com.calipso.reportgenerator.common.ShowExceptionMessageDialog; 7 8 import javax.swing.*; 9 import java.awt.*; 10 import java.awt.event.WindowAdapter ; 11 12 15 public class StaticReportFrame extends ReportFrame { 16 private JFrame frame; 17 private JPanel staticReportPanel; 18 19 24 public StaticReportFrame(ReportResult reportResult, IReportManager reportManager) throws InfoException { 25 if ((reportResult == null)) { 26 throw new InfoException(com.calipso.reportgenerator.common.LanguageTraslator.traslate("108")); 27 } 28 super.reportResult = reportResult; 29 super.reportManager = reportManager; 30 initComponents(); 31 } 32 33 public void show() { 34 getFrame().setVisible(true); 35 } 36 37 41 public JFrame getFrame() { 42 if (frame == null) { 43 frame = new JFrame(); 44 frame.setTitle(reportResult.getReportSpec().getTitle()); 45 frame.setName("Cube"); 46 } 47 return frame; 48 } 49 50 private void initComponents() { 51 staticReportPanel = new JPanel(); 54 staticReportPanel.setLayout(new BorderLayout()); 55 getFrame().getContentPane().setLayout(new BorderLayout()); 56 getFrame().getContentPane().add(staticReportPanel, BorderLayout.CENTER); 59 createResizePanel(); 60 frame.addWindowListener(new WindowAdapter () { 61 public void windowClosing() { 62 System.exit(0); 63 } 64 }); 65 66 String str = getText(); 67 JTextArea text = new JTextArea(str); 68 text.setWrapStyleWord(true); 69 staticReportPanel.add(text); 70 71 frame.pack(); 72 frame.setSize(400, 300); 73 } 74 75 private String getText() { 76 try { 77 return reportManager.getXML(reportResult.getReportSpec().getDefinitionId(),reportResult.getReportQuery().getParamValues()); 78 } 79 catch (Exception e) { 80 ShowExceptionMessageDialog.initExceptionDialogMessage(com.calipso.reportgenerator.common.LanguageTraslator.traslate("194"),e); 81 return e.getMessage(); 82 } 83 } 84 85 private Component createResizePanel() { 86 JPanel resizePanel = new JPanel(new BorderLayout()); 87 return resizePanel; 91 } 92 93 94 } 95 | Popular Tags |