001: /*
002: * Created on 20/03/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;
023:
024: import java.awt.BorderLayout;
025: import java.io.IOException;
026: import java.net.URL;
027:
028: import javax.swing.JDialog;
029: import javax.swing.JEditorPane;
030: import javax.swing.JFrame;
031: import javax.swing.JScrollPane;
032: import javax.swing.event.HyperlinkEvent;
033: import javax.swing.event.HyperlinkListener;
034:
035: import br.com.gfp.dao.GFPController;
036: import br.com.gfp.util.SimpleLog;
037:
038: /**
039: * Esta é a tela que da informações gerais a respeito do GFP
040: * Os dados exibidos nesta tela estão na pasta resources
041: * @author Igor Regis da Silva Simoes
042: */
043: public class GFPAboutDialog extends JDialog {
044: /**
045: * Editor usado para abrir documentos HTML com suporte a hyperlink
046: */
047: private JEditorPane sobreHTML = new JEditorPane();
048:
049: /**
050: * Construtor default da tela
051: */
052: public GFPAboutDialog(URL page) {
053: super ((JFrame) GFPController.getGFPController().getContexto()
054: .get(GFPController.FRAME_PRINCIPAL), true);
055: setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
056: sobreHTML.setEditable(false);
057: try {
058: //sobreHTML.setEditorKit(new HTMLEditorKit());
059: sobreHTML.setPage(page);
060: sobreHTML.addHyperlinkListener(new LinkListener());
061: } catch (IOException e) {
062: ((SimpleLog) GFPController.getGFPController().getContexto()
063: .get(GFPController.LOG))
064: .log("Erro ao inicializar tela Sobre GFP - pagina: "
065: + page);
066: ((SimpleLog) GFPController.getGFPController().getContexto()
067: .get(GFPController.LOG)).log(e
068: .getLocalizedMessage());
069: ((SimpleLog) GFPController.getGFPController().getContexto()
070: .get(GFPController.LOG)).log(e);
071: }
072:
073: getContentPane().add(new JScrollPane(sobreHTML),
074: BorderLayout.CENTER);
075: setSize(450, 380);
076: setLocationRelativeTo(getOwner());
077: }
078:
079: /**
080: * Listener responsável por realizar a abertura de hyperlinks
081: *
082: * @author Igor Regis da Silva Simoes
083: * @since 10/08/2005 11:31:45
084: */
085: private class LinkListener implements HyperlinkListener {
086:
087: /**
088: * Aqui ouvimos os aventos relativos a hyperlinks
089: * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
090: */
091: public void hyperlinkUpdate(HyperlinkEvent e) {
092: //Se for umn clique do mouse então
093: if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
094: try {// nós abrimos o link solicitado
095: sobreHTML.setPage(e.getURL());
096: } catch (IOException e1) {
097: ((SimpleLog) GFPController.getGFPController()
098: .getContexto().get(GFPController.LOG))
099: .log("Erro ao navegar na janela sobre: "
100: + e.getURL());
101: ((SimpleLog) GFPController.getGFPController()
102: .getContexto().get(GFPController.LOG))
103: .log(e1.getLocalizedMessage());
104: ((SimpleLog) GFPController.getGFPController()
105: .getContexto().get(GFPController.LOG))
106: .log(e1);
107: }
108: }
109: }
110:
111: }
112: }
|