001: /*
002: * Created on 13/10/2004
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 javax.swing.JFrame;
028: import javax.swing.JOptionPane;
029:
030: import br.com.gfp.dao.GFPController;
031: import br.com.gfp.internationalization.ActionsMessages;
032: import br.com.gfp.util.ThreadUtil;
033: import br.com.gfpshare.controllers.ArquivoDeDadosAbertoContoller;
034:
035: /**
036: * @author Igor Regis da Silva Simoes
037: */
038: public class SairAction implements ActionListener {
039: private static SairAction action = null;
040:
041: /**
042: *
043: */
044: private SairAction() {
045: super ();
046: }
047:
048: /**
049: * @return Retorna uma instancia desta action
050: */
051: public static SairAction getAction() {
052: return action;
053: }
054:
055: /**
056: *
057: */
058: public static void initializeAction() {
059: if (action == null)
060: action = new SairAction();
061: }
062:
063: /**
064: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
065: */
066: public void actionPerformed(final ActionEvent e) {
067: (new Thread("SairGFP") {
068: @Override
069: public void run() {
070: if (JOptionPane.showOptionDialog((JFrame) GFPController
071: .getGFPController().getContexto().get(
072: GFPController.FRAME_PRINCIPAL),
073: ActionsMessages.getMessages().getString(
074: "querMesmoSair"), ActionsMessages
075: .getMessages().getString("atencao"),
076: JOptionPane.YES_NO_OPTION,
077: JOptionPane.INFORMATION_MESSAGE, null,
078: new String[] {
079: ActionsMessages.getMessages()
080: .getString("sim"),
081: ActionsMessages.getMessages()
082: .getString("nao") },
083: ActionsMessages.getMessages().getString("sim")) == JOptionPane.YES_OPTION) {
084: FecharDBAction.getAction().actionPerformed(e);
085:
086: ThreadUtil.waitFor("FecharDB");
087:
088: if (ArquivoDeDadosAbertoContoller.getInstance(null) == null
089: || !ArquivoDeDadosAbertoContoller
090: .getInstance(null)
091: .isArquivoAberto()) {
092: ClearTempFolderAction.getAction()
093: .actionPerformed(e);
094: System.exit(0);
095: }
096: }
097: }
098: }).start();
099: }
100: }
|