root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / IntializeApplicationExtension.java @ 23377
History | View | Annotate | Download (6.06 KB)
1 | 6764 | jmvivo | package com.iver.cit.gvsig; |
---|---|---|---|
2 | |||
3 | 9897 | cesar | import java.io.BufferedReader; |
4 | 8185 | jmvivo | import java.io.File; |
5 | import java.io.IOException; |
||
6 | 9897 | cesar | import java.io.InputStream; |
7 | import java.io.InputStreamReader; |
||
8 | 8185 | jmvivo | import java.io.StringWriter; |
9 | 6790 | jmvivo | import java.security.KeyException; |
10 | 8185 | jmvivo | import java.util.Properties; |
11 | 6790 | jmvivo | |
12 | 8185 | jmvivo | import org.apache.log4j.Logger; |
13 | |||
14 | import com.iver.andami.Launcher; |
||
15 | 14821 | jmvivo | import com.iver.andami.PluginServices; |
16 | 6764 | jmvivo | import com.iver.andami.plugins.Extension; |
17 | import com.iver.cit.gvsig.fmap.layers.FLayerFileVectorial; |
||
18 | import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
||
19 | 9295 | jmvivo | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
20 | 6790 | jmvivo | import com.iver.utiles.extensionPoints.ExtensionPoint; |
21 | 6764 | jmvivo | import com.iver.utiles.extensionPoints.ExtensionPoints; |
22 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
23 | |||
24 | public class IntializeApplicationExtension extends Extension { |
||
25 | 14821 | jmvivo | private ExtensionPoints extensionPoints =
|
26 | 6764 | jmvivo | ExtensionPointsSingleton.getInstance(); |
27 | 8185 | jmvivo | private static Logger logger = Logger.getLogger("gvSIG"); |
28 | 14821 | jmvivo | |
29 | 8185 | jmvivo | public void initialize() { |
30 | 14821 | jmvivo | |
31 | 8185 | jmvivo | addToLogInfo(); |
32 | 6764 | jmvivo | //this.extensionPoints.add("Layers","FileVectorial", FLayerFileVectorial.class);
|
33 | this.extensionPoints.add("Layers",FLayerFileVectorial.class.getName(), FLayerFileVectorial.class); |
||
34 | 14821 | jmvivo | |
35 | 6764 | jmvivo | //this.extensionPoints.add("Layers","GenericVectorial", FLayerGenericVectorial.class);
|
36 | this.extensionPoints.add("Layers",FLayerGenericVectorial.class.getName(), FLayerGenericVectorial.class); |
||
37 | 6790 | jmvivo | try {
|
38 | 6801 | fjp | ((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerFileVectorial.class.getName(), "FileVectorial"); |
39 | ((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerGenericVectorial.class.getName(), "GenericVectorial"); |
||
40 | 6790 | jmvivo | } catch (KeyException e) { |
41 | // TODO Auto-generated catch block
|
||
42 | e.printStackTrace(); |
||
43 | } |
||
44 | 14821 | jmvivo | registerIcons(); |
45 | 6764 | jmvivo | } |
46 | |||
47 | 14821 | jmvivo | //Registro en esta extension los iconos que no se donde registrarlos.
|
48 | private void registerIcons(){ |
||
49 | 15912 | jmvivo | |
50 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
51 | 15912 | jmvivo | "view-add-event-layer",
|
52 | this.getClass().getClassLoader().getResource("images/addeventtheme.png") |
||
53 | ); |
||
54 | PluginServices.getIconTheme().registerDefault( |
||
55 | "gvsig-logo-icon",
|
||
56 | this.getClass().getClassLoader().getResource("images/icon_gvsig.png") |
||
57 | ); |
||
58 | |||
59 | |||
60 | |||
61 | PluginServices.getIconTheme().registerDefault( |
||
62 | 14821 | jmvivo | "mapa-icono",
|
63 | this.getClass().getClassLoader().getResource("images/mapas.png") |
||
64 | ); |
||
65 | |||
66 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
67 | 14821 | jmvivo | "layout-insert-view",
|
68 | this.getClass().getClassLoader().getResource("images/MapaVista.png") |
||
69 | ); |
||
70 | |||
71 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
72 | 14821 | jmvivo | "vista-icono",
|
73 | this.getClass().getClassLoader().getResource("images/Vista.png") |
||
74 | ); |
||
75 | |||
76 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
77 | 14821 | jmvivo | "hand-icono",
|
78 | this.getClass().getClassLoader().getResource("images/Hand.png") |
||
79 | ); |
||
80 | |||
81 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
82 | 14821 | jmvivo | "add-layer-icono",
|
83 | this.getClass().getClassLoader().getResource("images/add-layer.png") |
||
84 | ); |
||
85 | |||
86 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
87 | 14821 | jmvivo | "delete-icono",
|
88 | this.getClass().getClassLoader().getResource("images/delete.png") |
||
89 | ); |
||
90 | |||
91 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
92 | 14821 | jmvivo | "arrow-up-icono",
|
93 | this.getClass().getClassLoader().getResource("images/up-arrow.png") |
||
94 | ); |
||
95 | |||
96 | 15647 | jmvivo | PluginServices.getIconTheme().registerDefault( |
97 | 14821 | jmvivo | "arrow-down-icono",
|
98 | this.getClass().getClassLoader().getResource("images/down-arrow.png") |
||
99 | ); |
||
100 | // PluginServices.getIconTheme().register(
|
||
101 | // "arrow-down-icono",
|
||
102 | // PrintPropertiesPage.class.getClassLoader().getResource("images/prepare-page.png")
|
||
103 | // );
|
||
104 | } |
||
105 | |||
106 | 6764 | jmvivo | public void execute(String actionCommand) { |
107 | |||
108 | } |
||
109 | |||
110 | public boolean isEnabled() { |
||
111 | return false; |
||
112 | } |
||
113 | |||
114 | public boolean isVisible() { |
||
115 | return false; |
||
116 | } |
||
117 | 14821 | jmvivo | |
118 | 8185 | jmvivo | private void addToLogInfo() { |
119 | String info[] = this.getStringInfo().split("\n"); |
||
120 | for (int i=0;i< info.length;i++) { |
||
121 | logger.info(info[i]); |
||
122 | } |
||
123 | } |
||
124 | 14821 | jmvivo | |
125 | 8185 | jmvivo | public String getStringInfo() { |
126 | StringWriter writer = new StringWriter(); |
||
127 | String andamiPath;
|
||
128 | String extensionsPath;
|
||
129 | String jaiVersion;
|
||
130 | 14821 | jmvivo | |
131 | 8233 | jmvivo | Properties props = System.getProperties(); |
132 | 14821 | jmvivo | |
133 | 8185 | jmvivo | try {
|
134 | 8233 | jmvivo | try {
|
135 | andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getCanonicalPath(); |
||
136 | } catch (IOException e) { |
||
137 | andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getAbsolutePath(); |
||
138 | } |
||
139 | } catch (Exception e1) { |
||
140 | andamiPath = (String)props.get("user.dir"); |
||
141 | 8185 | jmvivo | } |
142 | try {
|
||
143 | 8233 | jmvivo | try {
|
144 | extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getCanonicalPath(); |
||
145 | } catch (IOException e) { |
||
146 | 14821 | jmvivo | extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getAbsolutePath(); |
147 | 8233 | jmvivo | } |
148 | } catch (Exception e1) { |
||
149 | extensionsPath = "???";
|
||
150 | 8185 | jmvivo | } |
151 | 14821 | jmvivo | |
152 | |||
153 | |||
154 | 8185 | jmvivo | writer.write("gvSIG version: " + Version.longFormat() + "\n"); |
155 | writer.write(" gvSIG app exec path: " + andamiPath + "\n"); |
||
156 | writer.write(" gvSIG user app home: " + Launcher.getAppHomeDir() + "\n"); |
||
157 | writer.write(" gvSIG extension path: " + extensionsPath + "\n"); |
||
158 | writer.write(" gvSIG locale language: " + Launcher.getAndamiConfig().getLocaleLanguage() + "\n"); |
||
159 | 9897 | cesar | String osName = props.getProperty("os.name"); |
160 | writer.write("OS name: " + osName + "\n"); |
||
161 | 8185 | jmvivo | writer.write(" arch:" + props.get("os.arch") + "\n"); |
162 | writer.write(" version:"+ props.get("os.version") + "\n"); |
||
163 | 9897 | cesar | if (osName.startsWith("Linux")) { |
164 | try {
|
||
165 | String[] command = {"lsb_release", "-a"}; |
||
166 | Process p = Runtime.getRuntime().exec(command); |
||
167 | InputStream is = p.getInputStream();
|
||
168 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
||
169 | String line;
|
||
170 | while ( (line = reader.readLine()) != null) |
||
171 | writer.write(" "+line+"\n"); |
||
172 | } |
||
173 | catch (Exception ex) { |
||
174 | 14821 | jmvivo | |
175 | 9897 | cesar | } |
176 | } |
||
177 | 14821 | jmvivo | |
178 | 8185 | jmvivo | writer.write("JAVA vendor: " + props.get("java.vendor") + "\n"); |
179 | writer.write(" version:" +props.get("java.version")+ "\n"); |
||
180 | writer.write(" home: " + props.get("java.home") + "\n"); |
||
181 | return writer.toString();
|
||
182 | } |
||
183 | 14821 | jmvivo | |
184 | 9295 | jmvivo | public void terminate() { |
185 | 14821 | jmvivo | |
186 | 9295 | jmvivo | super.terminate();
|
187 | try {
|
||
188 | LayerFactory.getDataSourceFactory().finalizeThis(); |
||
189 | } catch (Exception e) { |
||
190 | //e.printStackTrace();
|
||
191 | } |
||
192 | 14821 | jmvivo | |
193 | 9295 | jmvivo | } |
194 | 6764 | jmvivo | } |