root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / IntializeApplicationExtension.java @ 23176
History | View | Annotate | Download (6.64 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.io.BufferedReader; |
4 |
import java.io.File; |
5 |
import java.io.IOException; |
6 |
import java.io.InputStream; |
7 |
import java.io.InputStreamReader; |
8 |
import java.io.StringWriter; |
9 |
import java.security.KeyException; |
10 |
import java.util.Properties; |
11 |
|
12 |
import org.apache.log4j.Logger; |
13 |
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 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
17 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLayerFileVectorial; |
18 |
import org.gvsig.tools.observer.Observer; |
19 |
|
20 |
import com.iver.andami.Launcher; |
21 |
import com.iver.andami.PluginServices; |
22 |
import com.iver.andami.plugins.Extension; |
23 |
import com.iver.cit.gvsig.vectorialdb.PrepareDBResourceObserver; |
24 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
25 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
26 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
27 |
|
28 |
public class IntializeApplicationExtension extends Extension { |
29 |
private ExtensionPoints extensionPoints =
|
30 |
ExtensionPointsSingleton.getInstance(); |
31 |
private static Logger logger = Logger.getLogger("gvSIG"); |
32 |
private Observer dbPasswordResorceObserver; |
33 |
public void initialize() { |
34 |
|
35 |
addToLogInfo(); |
36 |
//this.extensionPoints.add("Layers","FileVectorial", FLayerFileVectorial.class);
|
37 |
this.extensionPoints.add("Layers",FLayerFileVectorial.class.getName(), FLayerFileVectorial.class); |
38 |
|
39 |
//this.extensionPoints.add("Layers","GenericVectorial", FLayerGenericVectorial.class);
|
40 |
// this.extensionPoints.add("Layers",FLayerGenericVectorial.class.getName(), FLayerGenericVectorial.class);
|
41 |
try {
|
42 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerFileVectorial.class.getName(), "FileVectorial"); |
43 |
// ((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerGenericVectorial.class.getName(), "GenericVectorial");
|
44 |
} catch (KeyException e) { |
45 |
// TODO Auto-generated catch block
|
46 |
e.printStackTrace(); |
47 |
} |
48 |
registerIcons(); |
49 |
|
50 |
} |
51 |
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 |
|
60 |
//Registro en esta extension los iconos que no se donde registrarlos.
|
61 |
private void registerIcons(){ |
62 |
|
63 |
PluginServices.getIconTheme().registerDefault( |
64 |
"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 |
"mapa-icono",
|
76 |
this.getClass().getClassLoader().getResource("images/mapas.png") |
77 |
); |
78 |
|
79 |
PluginServices.getIconTheme().registerDefault( |
80 |
"layout-insert-view",
|
81 |
this.getClass().getClassLoader().getResource("images/MapaVista.png") |
82 |
); |
83 |
|
84 |
PluginServices.getIconTheme().registerDefault( |
85 |
"vista-icono",
|
86 |
this.getClass().getClassLoader().getResource("images/Vista.png") |
87 |
); |
88 |
|
89 |
PluginServices.getIconTheme().registerDefault( |
90 |
"hand-icono",
|
91 |
this.getClass().getClassLoader().getResource("images/Hand.png") |
92 |
); |
93 |
|
94 |
PluginServices.getIconTheme().registerDefault( |
95 |
"add-layer-icono",
|
96 |
this.getClass().getClassLoader().getResource("images/add-layer.png") |
97 |
); |
98 |
|
99 |
PluginServices.getIconTheme().registerDefault( |
100 |
"delete-icono",
|
101 |
this.getClass().getClassLoader().getResource("images/delete.png") |
102 |
); |
103 |
|
104 |
PluginServices.getIconTheme().registerDefault( |
105 |
"arrow-up-icono",
|
106 |
this.getClass().getClassLoader().getResource("images/up-arrow.png") |
107 |
); |
108 |
|
109 |
PluginServices.getIconTheme().registerDefault( |
110 |
"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 |
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 |
|
131 |
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 |
|
138 |
public String getStringInfo() { |
139 |
StringWriter writer = new StringWriter(); |
140 |
String andamiPath;
|
141 |
String extensionsPath;
|
142 |
String jaiVersion;
|
143 |
|
144 |
Properties props = System.getProperties(); |
145 |
|
146 |
try {
|
147 |
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 |
} |
155 |
try {
|
156 |
try {
|
157 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getCanonicalPath(); |
158 |
} catch (IOException e) { |
159 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getAbsolutePath(); |
160 |
} |
161 |
} catch (Exception e1) { |
162 |
extensionsPath = "???";
|
163 |
} |
164 |
|
165 |
|
166 |
|
167 |
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 |
String osName = props.getProperty("os.name"); |
173 |
writer.write("OS name: " + osName + "\n"); |
174 |
writer.write(" arch:" + props.get("os.arch") + "\n"); |
175 |
writer.write(" version:"+ props.get("os.version") + "\n"); |
176 |
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 |
|
188 |
} |
189 |
} |
190 |
|
191 |
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 |
|
197 |
public void terminate() { |
198 |
|
199 |
super.terminate();
|
200 |
// try {
|
201 |
// LayerFactory.getDataSourceFactory().finalizeThis();
|
202 |
// } catch (Exception e) {
|
203 |
// //e.printStackTrace();
|
204 |
// }
|
205 |
|
206 |
} |
207 |
} |