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 @ 44535
History | View | Annotate | Download (4 KB)
1 | 43404 | jjdelcerro | /**
|
---|---|---|---|
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 | 43431 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
30 | 43404 | jjdelcerro | import org.gvsig.andami.LocaleManager; |
31 | import org.gvsig.andami.PluginServices; |
||
32 | import org.gvsig.andami.PluginsLocator; |
||
33 | import org.gvsig.andami.PluginsManager; |
||
34 | import org.gvsig.andami.plugins.Extension; |
||
35 | import org.gvsig.tools.ToolsLocator; |
||
36 | import org.gvsig.tools.i18n.I18nManager; |
||
37 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
38 | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
||
39 | import org.gvsig.webbrowser.WebBrowserFactory; |
||
40 | import org.gvsig.webbrowser.WebBrowserPanel; |
||
41 | |||
42 | |||
43 | public class HelpExtension extends Extension { |
||
44 | |||
45 | @Override
|
||
46 | public void initialize() { |
||
47 | 43431 | jjdelcerro | IconThemeHelper.registerIcon("action", "help-contents", this); |
48 | IconThemeHelper.registerIcon("action", "help-search", this); |
||
49 | 43404 | jjdelcerro | } |
50 | |||
51 | @Override
|
||
52 | public void execute(String actionCommand) { |
||
53 | WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
||
54 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
55 | WebBrowserPanel webbrowser; |
||
56 | |||
57 | LocaleManager localeManager = PluginsLocator.getLocaleManager(); |
||
58 | PluginsManager pluginsManager = PluginsLocator.getManager(); |
||
59 | PluginServices plugin = pluginsManager.getPlugin(this);
|
||
60 | String baseHelpURL = (String) plugin.getPluginProperties().getDynValue("baseHelpURL"); |
||
61 | if( !baseHelpURL.endsWith("/") ) { |
||
62 | baseHelpURL = baseHelpURL + "/";
|
||
63 | } |
||
64 | |||
65 | Locale locale = localeManager.getCurrentLocale();
|
||
66 | String localeid = locale.getLanguage();
|
||
67 | Locale[] localeAlternatives = localeManager.getLocaleAlternatives(locale); |
||
68 | if( !ArrayUtils.isEmpty(localeAlternatives) ) {
|
||
69 | 43438 | jjdelcerro | localeid = localeAlternatives[0].getLanguage();
|
70 | 43404 | jjdelcerro | } |
71 | switch( StringUtils.defaultIfEmpty(actionCommand, "").toLowerCase() ) { |
||
72 | case "help-contents": |
||
73 | webbrowser = WebBrowserFactory.createWebBrowserPanel(); |
||
74 | webbrowser.asJComponent().setPreferredSize(new Dimension(900,500)); |
||
75 | webbrowser.setPage(baseHelpURL + localeid +"/build/html/user_manual/2.3/index.html");
|
||
76 | winmanager.showWindow( |
||
77 | webbrowser.asJComponent(), |
||
78 | i18n.getTranslation("_Help_contents"),
|
||
79 | WindowManager.MODE.WINDOW |
||
80 | ); |
||
81 | break;
|
||
82 | case "help-search": |
||
83 | webbrowser = WebBrowserFactory.createWebBrowserPanel(); |
||
84 | webbrowser.asJComponent().setPreferredSize(new Dimension(900,500)); |
||
85 | 43442 | jjdelcerro | webbrowser.setPage(baseHelpURL + localeid +"/build/html/gvsigsearch_all.html");
|
86 | 43404 | jjdelcerro | winmanager.showWindow( |
87 | webbrowser.asJComponent(), |
||
88 | i18n.getTranslation("_Help_contents"),
|
||
89 | WindowManager.MODE.WINDOW |
||
90 | ); |
||
91 | break;
|
||
92 | } |
||
93 | } |
||
94 | |||
95 | @Override
|
||
96 | public boolean isEnabled() { |
||
97 | return true; |
||
98 | } |
||
99 | |||
100 | @Override
|
||
101 | public boolean isVisible() { |
||
102 | return true; |
||
103 | } |
||
104 | |||
105 | } |