Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extHelp / src / org / gvsig / help / HelpExtension.java @ 34523

History | View | Annotate | Download (1.69 KB)

1
package org.gvsig.help;
2

    
3
import java.io.File;
4

    
5
import org.apache.log4j.Logger;
6

    
7
import com.iver.andami.PluginServices;
8
import com.iver.andami.help.Help;
9
import com.iver.andami.plugins.Extension;
10

    
11
public class HelpExtension  extends Extension {
12

    
13

    
14
        private Logger log() {
15
                return Logger.getLogger("org.gvsig");
16
        }
17

    
18
        public void initialize() {
19
                // TODO Auto-generated method stub
20

    
21
        }
22

    
23
        public void execute(String actionCommand) {
24

    
25
                // If the option pressed is help control the help panel is created.
26
                if(actionCommand.equalsIgnoreCase("Help")){
27

    
28
                        Help help = Help.getHelp();        //My constructor.
29
                        help.show();//Launch help panel.
30

    
31
                        return;
32
                }
33
        }
34

    
35
        public boolean isEnabled() {
36
                return true;
37
        }
38

    
39
        public boolean isVisible() {
40
                return true;
41
        }
42

    
43
        public static String getExtensionPath() {
44
                String pluginName = "org.gvsig.help";
45
                PluginServices ps = PluginServices.getPluginServices(pluginName);
46
                return ps.getPluginDirectory().getAbsolutePath();
47
        }
48

    
49
        @Override
50
        public void postInitialize() {
51
                super.postInitialize();
52
                Help help = Help.getHelp();        //My constructor.
53
                File folder = new File(HelpExtension.getExtensionPath()+File.separator+"manuals");
54
                String[] l = folder.list();
55
                for (int i = 0; i < l.length; i++) {
56
                        File file = new File(folder,l[i]);
57
                        String path = file.getAbsolutePath();
58
                        String name = l[i];
59
                        if (file.isDirectory()){
60
                                path = folder.getAbsolutePath();
61
                        } else {
62
                                if ( !path.toLowerCase().endsWith(".zip") ){
63
                                        continue;
64
                                }
65
                        }
66
                        if (name.endsWith(File.separator)){
67
                                name = name.substring(0, name.length()-1);
68
                        }
69
                        if (name.toLowerCase().endsWith(".zip")){
70
                                name = name.substring(0, name.length()-4);
71
                        }
72
                        help.addResource(path);
73
                        help.addHelp(name);
74
                }
75
        }
76

    
77
}