svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / IntializeApplicationExtension.java @ 28960
History | View | Annotate | Download (6.06 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 |
|
14 |
import com.iver.andami.Launcher; |
15 |
import com.iver.andami.PluginServices; |
16 |
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 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
20 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
21 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
22 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
23 |
|
24 |
public class IntializeApplicationExtension extends Extension { |
25 |
private ExtensionPoints extensionPoints =
|
26 |
ExtensionPointsSingleton.getInstance(); |
27 |
private static Logger logger = Logger.getLogger("gvSIG"); |
28 |
|
29 |
public void initialize() { |
30 |
|
31 |
addToLogInfo(); |
32 |
//this.extensionPoints.add("Layers","FileVectorial", FLayerFileVectorial.class);
|
33 |
this.extensionPoints.add("Layers",FLayerFileVectorial.class.getName(), FLayerFileVectorial.class); |
34 |
|
35 |
//this.extensionPoints.add("Layers","GenericVectorial", FLayerGenericVectorial.class);
|
36 |
this.extensionPoints.add("Layers",FLayerGenericVectorial.class.getName(), FLayerGenericVectorial.class); |
37 |
try {
|
38 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerFileVectorial.class.getName(), "FileVectorial"); |
39 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerGenericVectorial.class.getName(), "GenericVectorial"); |
40 |
} catch (KeyException e) { |
41 |
// TODO Auto-generated catch block
|
42 |
e.printStackTrace(); |
43 |
} |
44 |
registerIcons(); |
45 |
} |
46 |
|
47 |
//Registro en esta extension los iconos que no se donde registrarlos.
|
48 |
private void registerIcons(){ |
49 |
|
50 |
PluginServices.getIconTheme().registerDefault( |
51 |
"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 |
"mapa-icono",
|
63 |
this.getClass().getClassLoader().getResource("images/mapas.png") |
64 |
); |
65 |
|
66 |
PluginServices.getIconTheme().registerDefault( |
67 |
"layout-insert-view",
|
68 |
this.getClass().getClassLoader().getResource("images/MapaVista.png") |
69 |
); |
70 |
|
71 |
PluginServices.getIconTheme().registerDefault( |
72 |
"vista-icono",
|
73 |
this.getClass().getClassLoader().getResource("images/Vista.png") |
74 |
); |
75 |
|
76 |
PluginServices.getIconTheme().registerDefault( |
77 |
"hand-icono",
|
78 |
this.getClass().getClassLoader().getResource("images/Hand.png") |
79 |
); |
80 |
|
81 |
PluginServices.getIconTheme().registerDefault( |
82 |
"add-layer-icono",
|
83 |
this.getClass().getClassLoader().getResource("images/add-layer.png") |
84 |
); |
85 |
|
86 |
PluginServices.getIconTheme().registerDefault( |
87 |
"delete-icono",
|
88 |
this.getClass().getClassLoader().getResource("images/delete.png") |
89 |
); |
90 |
|
91 |
PluginServices.getIconTheme().registerDefault( |
92 |
"arrow-up-icono",
|
93 |
this.getClass().getClassLoader().getResource("images/up-arrow.png") |
94 |
); |
95 |
|
96 |
PluginServices.getIconTheme().registerDefault( |
97 |
"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 |
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 |
|
118 |
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 |
|
125 |
public String getStringInfo() { |
126 |
StringWriter writer = new StringWriter(); |
127 |
String andamiPath;
|
128 |
String extensionsPath;
|
129 |
String jaiVersion;
|
130 |
|
131 |
Properties props = System.getProperties(); |
132 |
|
133 |
try {
|
134 |
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 |
} |
142 |
try {
|
143 |
try {
|
144 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getCanonicalPath(); |
145 |
} catch (IOException e) { |
146 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getAbsolutePath(); |
147 |
} |
148 |
} catch (Exception e1) { |
149 |
extensionsPath = "???";
|
150 |
} |
151 |
|
152 |
|
153 |
|
154 |
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 |
String osName = props.getProperty("os.name"); |
160 |
writer.write("OS name: " + osName + "\n"); |
161 |
writer.write(" arch:" + props.get("os.arch") + "\n"); |
162 |
writer.write(" version:"+ props.get("os.version") + "\n"); |
163 |
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 |
|
175 |
} |
176 |
} |
177 |
|
178 |
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 |
|
184 |
public void terminate() { |
185 |
|
186 |
super.terminate();
|
187 |
try {
|
188 |
LayerFactory.getDataSourceFactory().finalizeThis(); |
189 |
} catch (Exception e) { |
190 |
//e.printStackTrace();
|
191 |
} |
192 |
|
193 |
} |
194 |
} |