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 / extension / HelpExtension.java @ 43404

History | View | Annotate | Download (3.8 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 modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.app.extension;
24

    
25
import java.awt.Dimension;
26
import java.util.Locale;
27
import org.apache.commons.lang3.ArrayUtils;
28
import org.apache.commons.lang3.StringUtils;
29
import org.gvsig.andami.LocaleManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.PluginsLocator;
32
import org.gvsig.andami.PluginsManager;
33
import org.gvsig.andami.plugins.Extension;
34
import org.gvsig.tools.ToolsLocator;
35
import org.gvsig.tools.i18n.I18nManager;
36
import org.gvsig.tools.swing.api.ToolsSwingLocator;
37
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
38
import org.gvsig.webbrowser.WebBrowserFactory;
39
import org.gvsig.webbrowser.WebBrowserPanel;
40

    
41

    
42
public class HelpExtension extends Extension {
43

    
44
    @Override
45
    public void initialize() {
46
    }
47

    
48
    @Override
49
    public void execute(String actionCommand) {
50
        WindowManager winmanager = ToolsSwingLocator.getWindowManager();
51
        I18nManager i18n = ToolsLocator.getI18nManager();
52
        WebBrowserPanel webbrowser;
53
        
54
        LocaleManager localeManager = PluginsLocator.getLocaleManager();
55
        PluginsManager pluginsManager = PluginsLocator.getManager();
56
        PluginServices plugin = pluginsManager.getPlugin(this);
57
        String baseHelpURL = (String) plugin.getPluginProperties().getDynValue("baseHelpURL");        
58
        if( !baseHelpURL.endsWith("/") ) {
59
            baseHelpURL = baseHelpURL + "/";
60
        }
61
        
62
        Locale locale = localeManager.getCurrentLocale();
63
        String localeid = locale.getLanguage();
64
        Locale[] localeAlternatives = localeManager.getLocaleAlternatives(locale);
65
        if( !ArrayUtils.isEmpty(localeAlternatives) ) {
66
            localeid = locale.getLanguage();
67
        }
68
        switch( StringUtils.defaultIfEmpty(actionCommand, "").toLowerCase() ) {
69
        case "help-contents":
70
            webbrowser = WebBrowserFactory.createWebBrowserPanel();
71
            webbrowser.asJComponent().setPreferredSize(new Dimension(900,500));
72
            webbrowser.setPage(baseHelpURL + localeid +"/build/html/user_manual/2.3/index.html");
73
            winmanager.showWindow( 
74
                webbrowser.asJComponent(), 
75
                i18n.getTranslation("_Help_contents"), 
76
                WindowManager.MODE.WINDOW
77
            );
78
            break;
79
        case "help-search":
80
            webbrowser = WebBrowserFactory.createWebBrowserPanel();
81
            webbrowser.asJComponent().setPreferredSize(new Dimension(900,500));
82
            webbrowser.setPage(baseHelpURL + "es" +"/build/html/gvsigsearch_all.html");
83
            winmanager.showWindow( 
84
                webbrowser.asJComponent(), 
85
                i18n.getTranslation("_Help_contents"), 
86
                WindowManager.MODE.WINDOW
87
            );
88
            break;
89
        }
90
    }
91
    
92
    @Override
93
    public boolean isEnabled() {
94
        return true;
95
    }
96

    
97
    @Override
98
    public boolean isVisible() {
99
        return true;
100
    }
101
    
102
}