Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / FPanelAbout.java @ 8184

History | View | Annotate | Download (7.07 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 com.iver.cit.gvsig.gui.panels;
48

    
49
import java.awt.BorderLayout;
50
import java.io.BufferedReader;
51
import java.io.FileNotFoundException;
52
import java.io.FileReader;
53
import java.io.IOException;
54
import java.net.URL;
55
import java.util.StringTokenizer;
56

    
57
import javax.swing.JButton;
58
import javax.swing.JDialog;
59
import javax.swing.JEditorPane;
60
import javax.swing.JLabel;
61
import javax.swing.JPanel;
62
import javax.swing.JScrollPane;
63
import javax.swing.JTabbedPane;
64
import javax.swing.event.HyperlinkEvent;
65

    
66
import org.apache.log4j.Logger;
67

    
68
import com.iver.andami.PluginServices;
69
import com.iver.andami.ui.mdiManager.IWindow;
70
import com.iver.andami.ui.mdiManager.WindowInfo;
71
import com.iver.cit.gvsig.Version;
72
/**
73
 * @author FJP
74
 *
75
 * A Window with panels showing web pages. A developer
76
 * can write a web page with information about his/her plugin
77
 * and call addAboutUrl to add his/her about to gvSIG's about and
78
 * others.
79
 */
80
public class FPanelAbout extends JPanel implements IWindow {
81
        private static Logger logger = Logger.getLogger(FPanelAbout.class.getName());
82
        private JEditorPane jEditorPane = null;
83
        private JScrollPane jScrollPane = null;
84
        private JEditorPane jEditorPane1 = null;
85
        private JPanel jPanel = null;
86
        private JButton jButton = null;
87
        
88
        private JLabel jLblVersion = null;
89
    private JTabbedPane jTabbedPane = null;
90
        /**
91
         * This is the default constructor
92
         * @throws FileNotFoundException
93
         */
94
        public FPanelAbout(){
95
                super();
96
                initialize();
97
        }
98
        /**
99
         * This method initializes this
100
         * 
101
         * @return void
102
         * @throws FileNotFoundException
103
         */
104
        private  void initialize(){
105
                this.setLayout(new BorderLayout());
106
                this.setSize(600, 450);
107
                this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
108
                
109
                this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
110
        }
111

    
112
        /**
113
         * This method initializes jScrollPane        
114
         *         
115
         * @return javax.swing.JScrollPane        
116
         */    
117
        private JScrollPane getJScrollPane(URL url) {
118
                // if (jScrollPane == null) {
119
                        jScrollPane = new JScrollPane();
120
                        jScrollPane.setPreferredSize(new java.awt.Dimension(300,400));
121
                        jScrollPane.setViewportView(getJEditorPane(url));
122
                // }
123
                return jScrollPane;
124
        }
125
        /**
126
         * This method initializes jEditorPane1        
127
         *         
128
         * @return javax.swing.JEditorPane        
129
         */    
130
                private JEditorPane getJEditorPane(URL aboutURL) {
131
                        // if (jEditorPane == null) {
132
                                jEditorPane = new JEditorPane();
133
                                
134
                                jEditorPane.setEditable(false);
135
                                jEditorPane.setContentType("text/html");
136
                                jEditorPane.setPreferredSize(new java.awt.Dimension(300,200));
137
                                
138
                                if (aboutURL != null) {
139
                                    try {
140
                                            jEditorPane.setPage(aboutURL);
141
                                            jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() { 
142
                                                    public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
143
                                                            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
144
                                                            {
145
                                                                   JEditorPane pane = (JEditorPane) e.getSource();
146
                                                                   System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate()
147
                                                                   BrowserControl.displayURL(e.getURL().toString());
148
                                                                   // if (e instanceof HTMLFrameHyperlinkEvent) {
149
                                                            }
150

    
151
                                                            
152
                                                    }
153
                                            });
154
                                    } catch (IOException e) {
155
                                        System.err.println("Attempted to read a bad URL: " + aboutURL);
156
                                    }
157
                                } else {
158
                                    System.err.println("Couldn't find file: about.html" + aboutURL.getPath());
159
                                }
160
                                
161
                        // }
162
                        return jEditorPane;
163
                }
164
        /**
165
         * This method initializes jPanel        
166
         *         
167
         * @return javax.swing.JPanel        
168
         */    
169
        private JPanel getJPanel() {
170
                if (jPanel == null) {
171
                        jLblVersion = new JLabel();
172
                        jPanel = new JPanel();
173
                        jPanel.setLayout(null);
174
                        jPanel.setPreferredSize(new java.awt.Dimension(10,50));
175
                        jLblVersion.setBounds(31, 20, 172, 17);
176
                        jLblVersion.setText("Version "+Version.longFormat());
177
                        jPanel.add(getJButton(), null);
178
                        jPanel.add(jLblVersion, null);
179
                }
180
                return jPanel;
181
        }
182
        /**
183
         * This method initializes jButton        
184
         *         
185
         * @return javax.swing.JButton        
186
         */    
187
        private JButton getJButton() {
188
                if (jButton == null) {
189
                        jButton = new JButton();
190
                        jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
191
                        jButton.setText(PluginServices.getText(this,"Cerrar"));
192
                        jButton.setBounds(266, 12, 94, 25);
193
                        jButton.addActionListener(new java.awt.event.ActionListener() { 
194
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
195
                                        System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
196
                                        if (PluginServices.getMainFrame() != null)
197
                                        {
198
                                                PluginServices.getMDIManager().closeWindow(FPanelAbout.this);
199
                                        }
200
                                        else 
201
                                        {
202
                                                ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
203
                                        }
204
                                        
205
                                }
206
                        });
207
                }
208
                return jButton;
209
        }
210
        /* (non-Javadoc)
211
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
212
         */
213
        public WindowInfo getWindowInfo() {
214
                WindowInfo m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
215
                m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de"));
216

    
217
                return m_ViewInfo;
218
        }
219
        /* (non-Javadoc)
220
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
221
         */
222
        public void viewActivated() {
223
                // TODO Auto-generated method stub
224
                
225
        }
226
    public void addAboutUrl(String pluginName, URL url)
227
    {
228
        getJTabbedPane().addTab(pluginName, getJScrollPane(url));
229
        // this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);   
230
    }
231
    /**
232
     * This method initializes jTabbedPane        
233
     *         
234
     * @return javax.swing.JTabbedPane        
235
     */    
236
    private JTabbedPane getJTabbedPane() {
237
            if (jTabbedPane == null) {
238
                    jTabbedPane = new JTabbedPane();
239
                    jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50));
240
            }
241
            return jTabbedPane;
242
    }
243
}  //  @jve:decl-index=0:visual-constraint="10,10"