Statistics
| Revision:

root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / FPanelAbout.java @ 11023

History | View | Annotate | Download (7.25 KB)

1 6117 jaume
/*
2
 * Created on 02-sep-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig.gui.panels;
48
49
import java.awt.BorderLayout;
50
import java.io.FileNotFoundException;
51
import java.io.IOException;
52
import java.net.URL;
53
54
import javax.swing.JButton;
55
import javax.swing.JDialog;
56
import javax.swing.JEditorPane;
57
import javax.swing.JLabel;
58
import javax.swing.JPanel;
59
import javax.swing.JScrollPane;
60 8765 jjdelcerro
import javax.swing.JTabbedPane;
61 6117 jaume
import javax.swing.event.HyperlinkEvent;
62
63
import org.apache.log4j.Logger;
64
65
import com.iver.andami.PluginServices;
66 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
67 6880 cesar
import com.iver.andami.ui.mdiManager.WindowInfo;
68 6436 jmvivo
import com.iver.cit.gvsig.Version;
69 11023 jaume
import com.iver.utiles.BrowserControl;
70 6117 jaume
/**
71
 * @author FJP
72
 *
73
 * A Window with panels showing web pages. A developer
74
 * can write a web page with information about his/her plugin
75
 * and call addAboutUrl to add his/her about to gvSIG's about and
76
 * others.
77
 */
78 6877 cesar
public class FPanelAbout extends JPanel implements IWindow {
79 6117 jaume
        private static Logger logger = Logger.getLogger(FPanelAbout.class.getName());
80
        private JEditorPane jEditorPane = null;
81
        private JScrollPane jScrollPane = null;
82
        private JEditorPane jEditorPane1 = null;
83
        private JPanel jPanel = null;
84
        private JButton jButton = null;
85
86
        private JLabel jLblVersion = null;
87 10733 jmvivo
        private JLabel jLblJavaVersion = null;
88 6117 jaume
    private JTabbedPane jTabbedPane = null;
89
        /**
90
         * This is the default constructor
91
         * @throws FileNotFoundException
92
         */
93
        public FPanelAbout(){
94
                super();
95
                initialize();
96
        }
97
        /**
98
         * This method initializes this
99
         *
100
         * @return void
101
         * @throws FileNotFoundException
102
         */
103
        private  void initialize(){
104
                this.setLayout(new BorderLayout());
105
                this.setSize(600, 450);
106
                this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
107
108
                this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
109
        }
110
111
        /**
112
         * This method initializes jScrollPane
113
         *
114
         * @return javax.swing.JScrollPane
115
         */
116
        private JScrollPane getJScrollPane(URL url) {
117
                // if (jScrollPane == null) {
118
                        jScrollPane = new JScrollPane();
119
                        jScrollPane.setPreferredSize(new java.awt.Dimension(300,400));
120
                        jScrollPane.setViewportView(getJEditorPane(url));
121
                // }
122
                return jScrollPane;
123
        }
124
        /**
125
         * This method initializes jEditorPane1
126
         *
127
         * @return javax.swing.JEditorPane
128
         */
129
                private JEditorPane getJEditorPane(URL aboutURL) {
130
                        // if (jEditorPane == null) {
131
                                jEditorPane = new JEditorPane();
132
133
                                jEditorPane.setEditable(false);
134
                                jEditorPane.setContentType("text/html");
135
                                jEditorPane.setPreferredSize(new java.awt.Dimension(300,200));
136
137
                                if (aboutURL != null) {
138
                                    try {
139
                                            jEditorPane.setPage(aboutURL);
140
                                            jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
141
                                                    public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
142
                                                            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
143
                                                            {
144
                                                                   JEditorPane pane = (JEditorPane) e.getSource();
145
                                                                   System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate()
146
                                                                   BrowserControl.displayURL(e.getURL().toString());
147
                                                                   // if (e instanceof HTMLFrameHyperlinkEvent) {
148
                                                            }
149
150
151
                                                    }
152
                                            });
153
                                    } catch (IOException e) {
154
                                        System.err.println("Attempted to read a bad URL: " + aboutURL);
155
                                    }
156
                                } else {
157
                                    System.err.println("Couldn't find file: about.html" + aboutURL.getPath());
158
                                }
159
160
                        // }
161
                        return jEditorPane;
162
                }
163
        /**
164
         * This method initializes jPanel
165
         *
166
         * @return javax.swing.JPanel
167
         */
168
        private JPanel getJPanel() {
169
                if (jPanel == null) {
170
                        jLblVersion = new JLabel();
171 10733 jmvivo
                        jLblJavaVersion = new JLabel();
172 6117 jaume
                        jPanel = new JPanel();
173
                        jPanel.setLayout(null);
174
                        jPanel.setPreferredSize(new java.awt.Dimension(10,50));
175 10733 jmvivo
                        jLblVersion.setBounds(10, 16, 205, 17);
176 8765 jjdelcerro
                        jLblVersion.setText("Version "+Version.longFormat());
177 10733 jmvivo
                        jLblJavaVersion.setBounds(415, 16, 150, 17);
178
                        jLblJavaVersion.setText("Java "+System.getProperties().get("java.version"));
179 6117 jaume
                        jPanel.add(getJButton(), null);
180
                        jPanel.add(jLblVersion, null);
181 10733 jmvivo
                        jPanel.add(jLblJavaVersion, null);
182 6117 jaume
                }
183
                return jPanel;
184
        }
185
        /**
186
         * This method initializes jButton
187
         *
188
         * @return javax.swing.JButton
189
         */
190
        private JButton getJButton() {
191
                if (jButton == null) {
192
                        jButton = new JButton();
193
                        jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
194
                        jButton.setText(PluginServices.getText(this,"Cerrar"));
195
                        jButton.setBounds(266, 12, 94, 25);
196
                        jButton.addActionListener(new java.awt.event.ActionListener() {
197
                                public void actionPerformed(java.awt.event.ActionEvent e) {
198
                                        System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
199
                                        if (PluginServices.getMainFrame() != null)
200
                                        {
201 6880 cesar
                                                PluginServices.getMDIManager().closeWindow(FPanelAbout.this);
202 6117 jaume
                                        }
203
                                        else
204
                                        {
205
                                                ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
206
                                        }
207
208
                                }
209
                        });
210
                }
211
                return jButton;
212
        }
213
        /* (non-Javadoc)
214
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
215
         */
216 6880 cesar
        public WindowInfo getWindowInfo() {
217
                WindowInfo m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
218 6117 jaume
                m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de"));
219
220
                return m_ViewInfo;
221
        }
222
        /* (non-Javadoc)
223
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
224
         */
225
        public void viewActivated() {
226
                // TODO Auto-generated method stub
227
228
        }
229
    public void addAboutUrl(String pluginName, URL url)
230
    {
231
        getJTabbedPane().addTab(pluginName, getJScrollPane(url));
232
        // this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
233
    }
234
    /**
235
     * This method initializes jTabbedPane
236
     *
237
     * @return javax.swing.JTabbedPane
238
     */
239
    private JTabbedPane getJTabbedPane() {
240
            if (jTabbedPane == null) {
241
                    jTabbedPane = new JTabbedPane();
242
                    jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50));
243
            }
244
            return jTabbedPane;
245
    }
246
}  //  @jve:decl-index=0:visual-constraint="10,10"