Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / panels / FPanelAbout.java @ 40558

History | View | Annotate | Download (8.26 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * Created on 02-sep-2004
26
 *
27
 * TODO To change the template for this generated file go to
28
 * Window - Preferences - Java - Code Generation - Code and Comments
29
 */
30
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
31
 *
32
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
33
 *
34
 * This program is free software; you can redistribute it and/or
35
 * modify it under the terms of the GNU General Public License
36
 * as published by the Free Software Foundation; either version 2
37
 * of the License, or (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
47
 *
48
 * For more information, contact:
49
 *
50
 *  Generalitat Valenciana
51
 *   Conselleria d'Infraestructures i Transport
52
 *   Av. Blasco Ib??ez, 50
53
 *   46010 VALENCIA
54
 *   SPAIN
55
 *
56
 *      +34 963862235
57
 *   gvsig@gva.es
58
 *      www.gvsig.gva.es
59
 *
60
 *    or
61
 *
62
 *   IVER T.I. S.A
63
 *   Salamanca 50
64
 *   46005 Valencia
65
 *   Spain
66
 *
67
 *   +34 963163400
68
 *   dac@iver.es
69
 */
70
package org.gvsig.app.gui.panels;
71

    
72
import java.awt.BorderLayout;
73
import java.io.FileNotFoundException;
74
import java.io.IOException;
75
import java.net.URL;
76

    
77
import javax.swing.JButton;
78
import javax.swing.JDialog;
79
import javax.swing.JEditorPane;
80
import javax.swing.JLabel;
81
import javax.swing.JPanel;
82
import javax.swing.JScrollPane;
83
import javax.swing.JTabbedPane;
84
import javax.swing.event.HyperlinkEvent;
85

    
86
import org.gvsig.andami.PluginServices;
87
import org.gvsig.andami.ui.mdiManager.IWindow;
88
import org.gvsig.andami.ui.mdiManager.WindowInfo;
89
import org.gvsig.app.extension.Version;
90
import org.gvsig.utils.BrowserControl;
91
import org.slf4j.Logger;
92
import org.slf4j.LoggerFactory;
93

    
94
/**
95
 * @author FJP
96
 *
97
 * A Window with panels showing web pages. A developer
98
 * can write a web page with information about his/her plugin
99
 * and call addAboutUrl to add his/her about to gvSIG's about and
100
 * others.
101
 * 
102
 * @deprecated see the AboutManager
103
 */
104
public class FPanelAbout extends JPanel implements IWindow {
105
    private static final Logger logger = LoggerFactory
106
    .getLogger(FPanelAbout.class);
107
    
108
        private JEditorPane jEditorPane = null;
109
        private JScrollPane jScrollPane = null;
110
        private JEditorPane jEditorPane1 = null;
111
        private JPanel jPanel = null;
112
        private JButton jButton = null;
113

    
114
        private JLabel jLblVersion = null;
115
        private JLabel jLblJavaVersion = null;
116
    private JTabbedPane jTabbedPane = null;
117
        /**
118
         * This is the default constructor
119
         * @throws FileNotFoundException
120
         */
121
        public FPanelAbout(){
122
                super();
123
                initialize();
124
        }
125
        /**
126
         * This method initializes this
127
         *
128
         * @return void
129
         * @throws FileNotFoundException
130
         */
131
        private  void initialize(){
132
                this.setLayout(new BorderLayout());
133
                this.setSize(600, 450);
134
                this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
135

    
136
                this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
137
        }
138

    
139
        /**
140
         * This method initializes jScrollPane
141
         *
142
         * @return javax.swing.JScrollPane
143
         */
144
        private JScrollPane getJScrollPane(URL url) {
145
                // if (jScrollPane == null) {
146
                        jScrollPane = new JScrollPane();
147
                        jScrollPane.setPreferredSize(new java.awt.Dimension(300,400));
148
                        jScrollPane.setViewportView(getJEditorPane(url));
149
                // }
150
                return jScrollPane;
151
        }
152
        /**
153
         * This method initializes jEditorPane1
154
         *
155
         * @return javax.swing.JEditorPane
156
         */
157
                private JEditorPane getJEditorPane(URL aboutURL) {
158
                        // if (jEditorPane == null) {
159
                                jEditorPane = new JEditorPane();
160

    
161
                                jEditorPane.setEditable(false);
162
                                jEditorPane.setContentType("text/html");
163
                                jEditorPane.setPreferredSize(new java.awt.Dimension(300,200));
164

    
165
                                if (aboutURL != null) {
166
                                    try {
167
                                            jEditorPane.setPage(aboutURL);
168
                                            jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
169
                                                    public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
170
                                                            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
171
                                                            {
172
                                                                   JEditorPane pane = (JEditorPane) e.getSource();
173
                                                                   System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate()
174
                                                                   BrowserControl.displayURL(e.getURL().toString());
175
                                                                   // if (e instanceof HTMLFrameHyperlinkEvent) {
176
                                                            }
177

    
178

    
179
                                                    }
180
                                            });
181
                                    } catch (IOException e) {
182
                                        System.err.println("Attempted to read a bad URL: " + aboutURL);
183
                                    }
184
                                } else {
185
                                    System.err.println("Couldn't find file: about.html" + aboutURL.getPath());
186
                                }
187

    
188
                        // }
189
                        return jEditorPane;
190
                }
191
        /**
192
         * This method initializes jPanel
193
         *
194
         * @return javax.swing.JPanel
195
         */
196
        private JPanel getJPanel() {
197
                if (jPanel == null) {
198
                        jLblVersion = new JLabel();
199
                        jLblJavaVersion = new JLabel();
200
                        jPanel = new JPanel();
201
                        jPanel.setLayout(null);
202
                        jPanel.setPreferredSize(new java.awt.Dimension(10,50));
203
                        jLblVersion.setBounds(10, 16, 205, 17);
204
                        jLblVersion.setText("Version "+Version.longFormat());
205
                        jLblJavaVersion.setBounds(415, 16, 150, 17);
206
                        jLblJavaVersion.setText("Java "+System.getProperties().get("java.version"));
207
                        jPanel.add(getJButton(), null);
208
                        jPanel.add(jLblVersion, null);
209
                        jPanel.add(jLblJavaVersion, null);
210
                }
211
                return jPanel;
212
        }
213
        /**
214
         * This method initializes jButton
215
         *
216
         * @return javax.swing.JButton
217
         */
218
        private JButton getJButton() {
219
                if (jButton == null) {
220
                        jButton = new JButton();
221
                        jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
222
                        jButton.setText(PluginServices.getText(this,"Cerrar"));
223
                        jButton.setBounds(266, 12, 94, 25);
224
                        jButton.addActionListener(new java.awt.event.ActionListener() {
225
                                public void actionPerformed(java.awt.event.ActionEvent e) {
226
                                        System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
227
                                        if (PluginServices.getMainFrame() != null)
228
                                        {
229
                                                PluginServices.getMDIManager().closeWindow(FPanelAbout.this);
230
                                        }
231
                                        else
232
                                        {
233
                                                ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
234
                                        }
235

    
236
                                }
237
                        });
238
                }
239
                return jButton;
240
        }
241
        /* (non-Javadoc)
242
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
243
         */
244
        public WindowInfo getWindowInfo() {
245
                WindowInfo m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
246
                m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de"));
247

    
248
                return m_ViewInfo;
249
        }
250
        /* (non-Javadoc)
251
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
252
         */
253
        public void viewActivated() {
254
                // TODO Auto-generated method stub
255

    
256
        }
257
    public void addAboutUrl(String pluginName, URL url)
258
    {
259
        getJTabbedPane().addTab(pluginName, getJScrollPane(url));
260
        // this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
261
    }
262
    /**
263
     * This method initializes jTabbedPane
264
     *
265
     * @return javax.swing.JTabbedPane
266
     */
267
    private JTabbedPane getJTabbedPane() {
268
            if (jTabbedPane == null) {
269
                    jTabbedPane = new JTabbedPane();
270
                    jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50));
271
            }
272
            return jTabbedPane;
273
    }
274
        public Object getWindowProfile() {
275
                return WindowInfo.DIALOG_PROFILE;
276
        }
277
}  //  @jve:decl-index=0:visual-constraint="10,10"