001: /*
002: * Created on 04/08/2005
003: *
004: * Swing Components - visit http://sf.net/projects/gfd
005: *
006: * Copyright (C) 2004 Igor Regis da Silva Simões
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022: package br.com.gfp.actions;
023:
024: import java.awt.event.ActionEvent;
025: import java.awt.event.ActionListener;
026:
027: import br.com.gfp.dao.GFPController;
028: import br.com.gfp.internationalization.ReportsMessages;
029: import br.com.gfp.reports.ReportFactory;
030: import br.com.gfp.util.SimpleLog;
031: import br.com.gfpshare.beans.MessageView;
032:
033: /**
034: * @author Igor Regis da Silva Simoes
035: */
036: public class ShowReportAction implements ActionListener {
037: private static ShowReportAction action = null;
038:
039: /**
040: *
041: */
042: private ShowReportAction() {
043: super ();
044: }
045:
046: /**
047: * @return Retorna uma instancia desta action
048: */
049: public static ShowReportAction getAction() {
050: return action;
051: }
052:
053: /**
054: *
055: */
056: public static void initializeAction() {
057: if (action == null)
058: action = new ShowReportAction();
059: }
060:
061: /**
062: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
063: */
064: public void actionPerformed(final ActionEvent e) {
065: new Thread() {
066: {
067: setPriority(Thread.MIN_PRIORITY);
068: setDaemon(true);
069: }
070:
071: @Override
072: public void run() {
073: MessageView messages = (MessageView) GFPController
074: .getGFPController().getContexto().get(
075: GFPController.RODAPE_MESSAGER);
076: messages = messages.showMessage(ReportsMessages
077: .getMessages().getString("Relatorio"),
078: ReportsMessages.getMessages().getString(
079: "GerandoRelatorio"), true);
080: messages.getMessagePanel().getProgressBar()
081: .setIndeterminate(true);
082:
083: try {
084: ReportFactory
085: .makeReport(e.getActionCommand(), null);
086:
087: messages.getMessagePanel().setMessage(
088: ReportsMessages.getMessages().getString(
089: "RelatorioGerado"), false);
090: messages.getMessagePanel().getProgressBar()
091: .setIndeterminate(false);
092: messages.finishUse(10);
093: } catch (Exception e1) {
094: messages.getMessagePanel().setMessage(
095: ReportsMessages.getMessages().getString(
096: "ProblemasGeracao"), false);
097: messages.getMessagePanel().getProgressBar()
098: .setIndeterminate(false);
099: messages.finishUse();
100:
101: ((SimpleLog) GFPController.getGFPController()
102: .getContexto().get(GFPController.LOG))
103: .log("Erro ao gerar relatorio: "
104: + e.getActionCommand());
105: ((SimpleLog) GFPController.getGFPController()
106: .getContexto().get(GFPController.LOG))
107: .log(e1.getLocalizedMessage());
108: ((SimpleLog) GFPController.getGFPController()
109: .getContexto().get(GFPController.LOG))
110: .log(e1);
111: }
112: }
113: }.start();
114: }
115: }
|