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