001: /*
002: * Created on 17/01/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: */
023: package br.com.gfp.windows;
024:
025: import java.awt.GridBagConstraints;
026: import java.awt.Insets;
027: import java.awt.event.ActionEvent;
028: import java.awt.event.ActionListener;
029: import java.sql.SQLException;
030:
031: import javax.swing.JButton;
032: import javax.swing.JCheckBox;
033: import javax.swing.JFrame;
034:
035: import br.com.gfp.dao.GFPController;
036: import br.com.gfp.dao.PendingTransactionDAO;
037: import br.com.gfp.data.PendingTransaction;
038: import br.com.gfp.data.Transaction;
039: import br.com.gfp.internationalization.ConfirmImportedTransactionsMessages;
040: import br.com.gfp.util.SimpleLog;
041: import br.com.gfp.windows.componentes.GFPHeaderRenderer;
042: import br.com.gfpshare.beans.GeneralEventHandler;
043: import br.com.gfpshare.beans.aplicativos.PainelBotoes;
044: import br.com.gfpshare.beans.aplicativos.PainelTelaBasica;
045: import br.com.gfpshare.beans.table.DBTable;
046: import br.com.gfpshare.db.DAOEvent;
047: import br.com.gfpshare.db.DAOListener;
048:
049: /**
050: * @author f4353008
051: * @since 17/01/2005 11:15:05
052: *
053: * To change the template for this generated type comment go to
054: * Window - Preferences - Java - Code Generation - Code and Comments
055: */
056: public class ConfirmImportedTransactionsWindow extends
057: TransactionWindow {
058: protected JCheckBox jcbEfetivar = null;
059:
060: private PendingTransactionDAO controller = new PendingTransactionDAO();
061:
062: /**
063: *
064: */
065: public ConfirmImportedTransactionsWindow(JFrame owner) {
066: super (owner);
067: setClosable(true);
068: setIconifiable(true);
069: setMaximizable(true);
070: setResizable(true);
071: jpSaldoEm.setVisible(false);
072: jpSaldoAtual.setVisible(false);
073: jcbRepetirLancamentoCada.setVisible(false);
074: jcbTipoIntervalorRepeticao.setVisible(false);
075: jlVezesACada.setVisible(false);
076: jsVezes.setVisible(false);
077: jsIntervalorRepeticao.setVisible(false);
078: jcbOcultarPrevisoes.setVisible(false);
079: jcbFiltrarPorData.setSelected(false);
080:
081: controller
082: .addControllerListener(new DAOListener<PendingTransaction>() {
083:
084: public void adicionadoNovo(
085: DAOEvent<PendingTransaction> e) {/*Fazemos nada*/
086: }
087:
088: public void atualizado(
089: DAOEvent<PendingTransaction> e) {/*Fazemos nada*/
090: }
091:
092: public void filtrado(DAOEvent<PendingTransaction> e) {/*Fazemos nada*/
093: }
094:
095: public void selecionado(
096: DAOEvent<PendingTransaction> e) {/*Fazemos nada*/
097: }
098:
099: public void deletado(DAOEvent<PendingTransaction> e) {
100: atualizar(null);
101: }
102: });
103:
104: jcbEfetivar = new JCheckBox();
105: jcbEfetivar.setText(ConfirmImportedTransactionsMessages
106: .getMessages().getString("Efetivar"));
107: jcbEfetivar.setMnemonic(ConfirmImportedTransactionsMessages
108: .getMessages().getString("EfetivarMnemonic").charAt(0));
109: GridBagConstraints gridBagConstraints = new GridBagConstraints();
110: gridBagConstraints.gridx = 0;
111: gridBagConstraints.gridy = 2;
112: gridBagConstraints.gridwidth = 2;
113: gridBagConstraints.anchor = GridBagConstraints.WEST;
114: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
115: telaPrincipal.addComponent(jcbEfetivar, gridBagConstraints,
116: PainelTelaBasica.DATA_COMPONENTS_AREA);
117:
118: telaPrincipal.setPrintButtonVisible(false);
119:
120: JButton jbMarcarTodos = new JButton();
121: jbMarcarTodos.setText(ConfirmImportedTransactionsMessages
122: .getMessages().getString("MarcarTodos"));
123: jbMarcarTodos.setMnemonic(ConfirmImportedTransactionsMessages
124: .getMessages().getString("MarcarTodosMnemonic").charAt(
125: 0));
126: jbMarcarTodos
127: .setToolTipText(ConfirmImportedTransactionsMessages
128: .getMessages().getString("MarcarTodosToolTip"));
129: gridBagConstraints = new GridBagConstraints();
130: gridBagConstraints.gridx = 0;
131: gridBagConstraints.gridy = 0;
132: gridBagConstraints.anchor = GridBagConstraints.WEST;
133: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
134: telaPrincipal.addComponent(jbMarcarTodos, gridBagConstraints,
135: PainelTelaBasica.TABLE_HEADER_AREA);
136: jbMarcarTodos
137: .addActionListener((ActionListener) GeneralEventHandler
138: .makeProxy(this , "marcarLancamentos",
139: ActionListener.class, "actionPerformed"));
140:
141: JButton jbEfetivar = new JButton();
142: jbEfetivar.setText(ConfirmImportedTransactionsMessages
143: .getMessages().getString("EfetivarMarcados"));
144: jbEfetivar.setMnemonic(ConfirmImportedTransactionsMessages
145: .getMessages().getString("EfetivarMarcadosMnemonic")
146: .charAt(0));
147: jbEfetivar.setToolTipText(ConfirmImportedTransactionsMessages
148: .getMessages().getString("EfetivarMarcadosToolTip"));
149: gridBagConstraints = new GridBagConstraints();
150: gridBagConstraints.gridx = 1;
151: gridBagConstraints.gridy = 0;
152: gridBagConstraints.anchor = GridBagConstraints.WEST;
153: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
154: telaPrincipal.addComponent(jbEfetivar, gridBagConstraints,
155: PainelTelaBasica.TABLE_HEADER_AREA);
156: jbEfetivar
157: .addActionListener((ActionListener) GeneralEventHandler
158: .makeProxy(this , "efetivarLancamentos",
159: ActionListener.class, "actionPerformed"));
160:
161: telaPrincipal.getPainelBotoes().setEnableCommand(
162: PainelBotoes.NOVO_COMMAND, false);
163: }
164:
165: @Override
166: protected void lancamentoInit() {
167: transaction = new PendingTransaction();
168: }
169:
170: @Override
171: protected Transaction getFiltro() {
172: return new PendingTransaction();
173: }
174:
175: @Override
176: protected void createTable() {
177: jtLancamentos = new DBTable(new PendingTransaction(),
178: new GFPHeaderRenderer());
179: }
180:
181: public void efetivarLancamentos(ActionEvent ev) {
182: try {
183: controller.efetivarMarcados();
184: } catch (SQLException e) {
185: ((SimpleLog) GFPController.getGFPController().getContexto()
186: .get(GFPController.LOG))
187: .log("Erro efetivar lançamentos marcados!");
188: ((SimpleLog) GFPController.getGFPController().getContexto()
189: .get(GFPController.LOG)).log(e
190: .getLocalizedMessage());
191: ((SimpleLog) GFPController.getGFPController().getContexto()
192: .get(GFPController.LOG)).log(e);
193: }
194: atualizar(ev);
195: }
196:
197: public void marcarLancamentos(ActionEvent ev) {
198: try {
199: controller.marcarTodosParaEfetivacao();
200: } catch (SQLException e) {
201: ((SimpleLog) GFPController.getGFPController().getContexto()
202: .get(GFPController.LOG))
203: .log("Erro ao marcar lancamentos para efetivação!");
204: ((SimpleLog) GFPController.getGFPController().getContexto()
205: .get(GFPController.LOG)).log(e
206: .getLocalizedMessage());
207: ((SimpleLog) GFPController.getGFPController().getContexto()
208: .get(GFPController.LOG)).log(e);
209: }
210: atualizar(ev);
211: }
212:
213: @Override
214: protected void loadLancamento() {
215: super .loadLancamento();
216: ((PendingTransaction) transaction).setEfetivar(Boolean
217: .valueOf(jcbEfetivar.isSelected()));
218: }
219:
220: @Override
221: public void excluir(ActionEvent e) {
222: super.excluir(e);
223: }
224: }
|