001: /*
002: * Created on 08/02/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.windows.config;
023:
024: import java.awt.Component;
025: import java.io.IOException;
026: import java.util.Locale;
027:
028: import javax.swing.JOptionPane;
029:
030: import br.com.gfp.dao.GFPController;
031: import br.com.gfp.data.ConfigLocalizacao;
032: import br.com.gfp.internationalization.ConfigLocalizacaoBeanInfoMessages;
033: import br.com.gfp.util.SimpleLog;
034: import br.com.gfpshare.config.ConfigPanel;
035: import br.com.gfpshare.config.GrupoDePropriedades;
036:
037: /**
038: * @author Igor Regis da Silva Simoes
039: */
040: public class PainelConfiguracaoLocalizacao extends ConfigPanel {
041: /**
042: *
043: */
044: public PainelConfiguracaoLocalizacao() {
045: super (ConfigLocalizacao.class);
046: }
047:
048: /**
049: * @see br.com.gfpshare.config.ConfigPanel#loadDefaultProperties()
050: */
051: @Override
052: public GrupoDePropriedades loadDefaultProperties() {
053: ((ConfigLocalizacao) grupoDePropriedades).setIdioma(Locale
054: .getDefault().getLanguage());
055: ((ConfigLocalizacao) grupoDePropriedades).setPais(Locale
056: .getDefault().getCountry());
057:
058: return grupoDePropriedades;
059: }
060:
061: @Override
062: public boolean isDadosValidos() {
063: //TODO Implementação de validação de dados
064: //ConfigPrevisaoDeRedimento config = (ConfigPrevisaoDeRedimento)grupoDePropriedades;
065: return true;
066: }
067:
068: /**
069: * Salva os dados e também configura o GFP para usar a localização
070: * solicitada na proxima vez que for aberto.
071: * @see br.com.gfpshare.config.ConfigPanel#saveData()
072: */
073: @Override
074: public void saveData() {
075: try {
076: LocaleConf localeConf = new LocaleConf();
077: localeConf
078: .setLanguage(((ConfigLocalizacao) grupoDePropriedades)
079: .getIdioma());
080: localeConf
081: .setCountry(((ConfigLocalizacao) grupoDePropriedades)
082: .getPais());
083: localeConf.saveData();
084: JOptionPane.showMessageDialog((Component) GFPController
085: .getGFPController().getContexto().get(
086: GFPController.FRAME_PRINCIPAL),
087: ConfigLocalizacaoBeanInfoMessages.getMessages()
088: .getString("aviso"));
089: } catch (IOException e) {
090: ((SimpleLog) GFPController.getGFPController().getContexto()
091: .get(GFPController.LOG))
092: .log("Erro ao salvar dados de configuracao de idioma e pais!");
093: ((SimpleLog) GFPController.getGFPController().getContexto()
094: .get(GFPController.LOG)).log(e
095: .getLocalizedMessage());
096: ((SimpleLog) GFPController.getGFPController().getContexto()
097: .get(GFPController.LOG)).log(e);
098: }
099: }
100: }
|