Statistics
| Revision:

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

History | View | Annotate | Download (6.98 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.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.apache.log4j.Logger;
64

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

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

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

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