Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / panels / FPanelAbout.java @ 29596

History | View | Annotate | Download (7.29 KB)

1
/*
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 org.gvsig.app.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
import javax.swing.JTabbedPane;
61
import javax.swing.event.HyperlinkEvent;
62

    
63
import org.gvsig.andami.PluginServices;
64
import org.gvsig.andami.ui.mdiManager.IWindow;
65
import org.gvsig.andami.ui.mdiManager.WindowInfo;
66
import org.gvsig.app.extension.Version;
67
import org.gvsig.utils.BrowserControl;
68
import org.slf4j.Logger;
69
import org.slf4j.LoggerFactory;
70

    
71
/**
72
 * @author FJP
73
 *
74
 * A Window with panels showing web pages. A developer
75
 * can write a web page with information about his/her plugin
76
 * and call addAboutUrl to add his/her about to gvSIG's about and
77
 * others.
78
 */
79
public class FPanelAbout extends JPanel implements IWindow {
80
    private static final Logger logger = LoggerFactory
81
    .getLogger(FPanelAbout.class);
82
    
83
        private JEditorPane jEditorPane = null;
84
        private JScrollPane jScrollPane = null;
85
        private JEditorPane jEditorPane1 = null;
86
        private JPanel jPanel = null;
87
        private JButton jButton = null;
88

    
89
        private JLabel jLblVersion = null;
90
        private JLabel jLblJavaVersion = null;
91
    private JTabbedPane jTabbedPane = null;
92
        /**
93
         * This is the default constructor
94
         * @throws FileNotFoundException
95
         */
96
        public FPanelAbout(){
97
                super();
98
                initialize();
99
        }
100
        /**
101
         * This method initializes this
102
         *
103
         * @return void
104
         * @throws FileNotFoundException
105
         */
106
        private  void initialize(){
107
                this.setLayout(new BorderLayout());
108
                this.setSize(600, 450);
109
                this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
110

    
111
                this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
112
        }
113

    
114
        /**
115
         * This method initializes jScrollPane
116
         *
117
         * @return javax.swing.JScrollPane
118
         */
119
        private JScrollPane getJScrollPane(URL url) {
120
                // if (jScrollPane == null) {
121
                        jScrollPane = new JScrollPane();
122
                        jScrollPane.setPreferredSize(new java.awt.Dimension(300,400));
123
                        jScrollPane.setViewportView(getJEditorPane(url));
124
                // }
125
                return jScrollPane;
126
        }
127
        /**
128
         * This method initializes jEditorPane1
129
         *
130
         * @return javax.swing.JEditorPane
131
         */
132
                private JEditorPane getJEditorPane(URL aboutURL) {
133
                        // if (jEditorPane == null) {
134
                                jEditorPane = new JEditorPane();
135

    
136
                                jEditorPane.setEditable(false);
137
                                jEditorPane.setContentType("text/html");
138
                                jEditorPane.setPreferredSize(new java.awt.Dimension(300,200));
139

    
140
                                if (aboutURL != null) {
141
                                    try {
142
                                            jEditorPane.setPage(aboutURL);
143
                                            jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
144
                                                    public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
145
                                                            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
146
                                                            {
147
                                                                   JEditorPane pane = (JEditorPane) e.getSource();
148
                                                                   System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate()
149
                                                                   BrowserControl.displayURL(e.getURL().toString());
150
                                                                   // if (e instanceof HTMLFrameHyperlinkEvent) {
151
                                                            }
152

    
153

    
154
                                                    }
155
                                            });
156
                                    } catch (IOException e) {
157
                                        System.err.println("Attempted to read a bad URL: " + aboutURL);
158
                                    }
159
                                } else {
160
                                    System.err.println("Couldn't find file: about.html" + aboutURL.getPath());
161
                                }
162

    
163
                        // }
164
                        return jEditorPane;
165
                }
166
        /**
167
         * This method initializes jPanel
168
         *
169
         * @return javax.swing.JPanel
170
         */
171
        private JPanel getJPanel() {
172
                if (jPanel == null) {
173
                        jLblVersion = new JLabel();
174
                        jLblJavaVersion = new JLabel();
175
                        jPanel = new JPanel();
176
                        jPanel.setLayout(null);
177
                        jPanel.setPreferredSize(new java.awt.Dimension(10,50));
178
                        jLblVersion.setBounds(10, 16, 205, 17);
179
                        jLblVersion.setText("Version "+Version.longFormat());
180
                        jLblJavaVersion.setBounds(415, 16, 150, 17);
181
                        jLblJavaVersion.setText("Java "+System.getProperties().get("java.version"));
182
                        jPanel.add(getJButton(), null);
183
                        jPanel.add(jLblVersion, null);
184
                        jPanel.add(jLblJavaVersion, null);
185
                }
186
                return jPanel;
187
        }
188
        /**
189
         * This method initializes jButton
190
         *
191
         * @return javax.swing.JButton
192
         */
193
        private JButton getJButton() {
194
                if (jButton == null) {
195
                        jButton = new JButton();
196
                        jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
197
                        jButton.setText(PluginServices.getText(this,"Cerrar"));
198
                        jButton.setBounds(266, 12, 94, 25);
199
                        jButton.addActionListener(new java.awt.event.ActionListener() {
200
                                public void actionPerformed(java.awt.event.ActionEvent e) {
201
                                        System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
202
                                        if (PluginServices.getMainFrame() != null)
203
                                        {
204
                                                PluginServices.getMDIManager().closeWindow(FPanelAbout.this);
205
                                        }
206
                                        else
207
                                        {
208
                                                ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
209
                                        }
210

    
211
                                }
212
                        });
213
                }
214
                return jButton;
215
        }
216
        /* (non-Javadoc)
217
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
218
         */
219
        public WindowInfo getWindowInfo() {
220
                WindowInfo m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
221
                m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de"));
222

    
223
                return m_ViewInfo;
224
        }
225
        /* (non-Javadoc)
226
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
227
         */
228
        public void viewActivated() {
229
                // TODO Auto-generated method stub
230

    
231
        }
232
    public void addAboutUrl(String pluginName, URL url)
233
    {
234
        getJTabbedPane().addTab(pluginName, getJScrollPane(url));
235
        // this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
236
    }
237
    /**
238
     * This method initializes jTabbedPane
239
     *
240
     * @return javax.swing.JTabbedPane
241
     */
242
    private JTabbedPane getJTabbedPane() {
243
            if (jTabbedPane == null) {
244
                    jTabbedPane = new JTabbedPane();
245
                    jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50));
246
            }
247
            return jTabbedPane;
248
    }
249
        public Object getWindowProfile() {
250
                return WindowInfo.DIALOG_PROFILE;
251
        }
252
}  //  @jve:decl-index=0:visual-constraint="10,10"