001: package com.calipso.reportgenerator.userinterface;
002:
003: import com.calipso.reportgenerator.common.ReportResult;
004: import com.calipso.reportgenerator.common.IReportManager;
005: import com.calipso.reportgenerator.common.InfoException;
006: import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
007:
008: import javax.swing.*;
009: import java.awt.*;
010: import java.awt.event.WindowAdapter;
011:
012: /**
013: * Muestra los reportes estaticos
014: */
015: public class StaticReportFrame extends ReportFrame {
016: private JFrame frame;
017: private JPanel staticReportPanel;
018:
019: /**
020: * Inicializa
021: * @param reportResult
022: * @param reportManager
023: */
024: public StaticReportFrame(ReportResult reportResult,
025: IReportManager reportManager) throws InfoException {
026: if ((reportResult == null)) {
027: throw new InfoException(
028: com.calipso.reportgenerator.common.LanguageTraslator
029: .traslate("108"));
030: }
031: super .reportResult = reportResult;
032: super .reportManager = reportManager;
033: initComponents();
034: }
035:
036: public void show() {
037: getFrame().setVisible(true);
038: }
039:
040: /**
041: * Devuelve el Frame
042: * @return
043: */
044: public JFrame getFrame() {
045: if (frame == null) {
046: frame = new JFrame();
047: frame.setTitle(reportResult.getReportSpec().getTitle());
048: frame.setName("Cube");
049: }
050: return frame;
051: }
052:
053: private void initComponents() {
054: //bottomPanel = new JPanel();
055: //bottomPanel.setPreferredSize(new Dimension(100, 100));
056: staticReportPanel = new JPanel();
057: staticReportPanel.setLayout(new BorderLayout());
058: getFrame().getContentPane().setLayout(new BorderLayout());
059: //getFrame().getContentPane().add(createLeftPanel(), BorderLayout.WEST);
060: //getFrame().getContentPane().add(bottomPanel, BorderLayout.SOUTH);
061: getFrame().getContentPane().add(staticReportPanel,
062: BorderLayout.CENTER);
063: createResizePanel();
064: frame.addWindowListener(new WindowAdapter() {
065: public void windowClosing() {
066: System.exit(0);
067: }
068: });
069:
070: String str = getText();
071: JTextArea text = new JTextArea(str);
072: text.setWrapStyleWord(true);
073: staticReportPanel.add(text);
074:
075: frame.pack();
076: frame.setSize(400, 300);
077: }
078:
079: private String getText() {
080: try {
081: return reportManager.getXML(reportResult.getReportSpec()
082: .getDefinitionId(), reportResult.getReportQuery()
083: .getParamValues());
084: } catch (Exception e) {
085: ShowExceptionMessageDialog
086: .initExceptionDialogMessage(
087: com.calipso.reportgenerator.common.LanguageTraslator
088: .traslate("194"), e);
089: return e.getMessage();
090: }
091: }
092:
093: private Component createResizePanel() {
094: JPanel resizePanel = new JPanel(new BorderLayout());
095: // this.printButton = new JButton("Imprimir");
096: // this.printButton.setMnemonic('I');
097: // resizePanel.add(this.printButton, BorderLayout.NORTH);
098: return resizePanel;
099: }
100:
101: }
|