svn-gvsig-desktop / tags / v1_1_Build_1008 / applications / appgvSIG / src / com / iver / cit / gvsig / IntializeApplicationExtension.java @ 12520
History | View | Annotate | Download (4.1 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.IOException; |
5 |
import java.io.StringWriter; |
6 |
import java.security.KeyException; |
7 |
import java.util.Properties; |
8 |
|
9 |
import org.apache.log4j.Logger; |
10 |
|
11 |
import com.iver.andami.Launcher; |
12 |
import com.iver.andami.plugins.Extension; |
13 |
import com.iver.cit.gvsig.fmap.layers.FLayerFileVectorial; |
14 |
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
17 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
18 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
19 |
|
20 |
public class IntializeApplicationExtension extends Extension { |
21 |
private ExtensionPoints extensionPoints =
|
22 |
ExtensionPointsSingleton.getInstance(); |
23 |
private static Logger logger = Logger.getLogger("gvSIG"); |
24 |
|
25 |
public void initialize() { |
26 |
|
27 |
addToLogInfo(); |
28 |
//this.extensionPoints.add("Layers","FileVectorial", FLayerFileVectorial.class);
|
29 |
this.extensionPoints.add("Layers",FLayerFileVectorial.class.getName(), FLayerFileVectorial.class); |
30 |
|
31 |
//this.extensionPoints.add("Layers","GenericVectorial", FLayerGenericVectorial.class);
|
32 |
this.extensionPoints.add("Layers",FLayerGenericVectorial.class.getName(), FLayerGenericVectorial.class); |
33 |
try {
|
34 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerFileVectorial.class.getName(), "FileVectorial"); |
35 |
((ExtensionPoint)this.extensionPoints.get("Layers")).addAlias(FLayerGenericVectorial.class.getName(), "GenericVectorial"); |
36 |
} catch (KeyException e) { |
37 |
// TODO Auto-generated catch block
|
38 |
e.printStackTrace(); |
39 |
} |
40 |
//extensionPoints.add("CRSSelectionPanel", CRSSelectPanel.class.getName(), ProjChooserPanel.class);
|
41 |
|
42 |
//((ExtensionPoint)this.extensionPoints.get("CRSSelectionPanel")).
|
43 |
// put(CRSSelectPanel.class.getName(), " nuevo panel de coordenadas.", ProjChooserPanel.class);
|
44 |
} |
45 |
|
46 |
public void execute(String actionCommand) { |
47 |
|
48 |
} |
49 |
|
50 |
public boolean isEnabled() { |
51 |
return false; |
52 |
} |
53 |
|
54 |
public boolean isVisible() { |
55 |
return false; |
56 |
} |
57 |
|
58 |
private void addToLogInfo() { |
59 |
String info[] = this.getStringInfo().split("\n"); |
60 |
for (int i=0;i< info.length;i++) { |
61 |
logger.info(info[i]); |
62 |
} |
63 |
} |
64 |
|
65 |
public String getStringInfo() { |
66 |
StringWriter writer = new StringWriter(); |
67 |
String andamiPath;
|
68 |
String extensionsPath;
|
69 |
String jaiVersion;
|
70 |
|
71 |
Properties props = System.getProperties(); |
72 |
|
73 |
try {
|
74 |
try {
|
75 |
andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getCanonicalPath(); |
76 |
} catch (IOException e) { |
77 |
andamiPath = (new File(Launcher.class.getResource(".").getFile() + File.separator + ".." + File.separator + ".." + File.separator +"..")).getAbsolutePath(); |
78 |
} |
79 |
} catch (Exception e1) { |
80 |
andamiPath = (String)props.get("user.dir"); |
81 |
} |
82 |
try {
|
83 |
try {
|
84 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getCanonicalPath(); |
85 |
} catch (IOException e) { |
86 |
extensionsPath = (new File(Launcher.getAndamiConfig().getPluginsDirectory())).getAbsolutePath(); |
87 |
} |
88 |
} catch (Exception e1) { |
89 |
extensionsPath = "???";
|
90 |
} |
91 |
|
92 |
|
93 |
|
94 |
writer.write("gvSIG version: " + Version.longFormat() + "\n"); |
95 |
writer.write(" gvSIG app exec path: " + andamiPath + "\n"); |
96 |
writer.write(" gvSIG user app home: " + Launcher.getAppHomeDir() + "\n"); |
97 |
writer.write(" gvSIG extension path: " + extensionsPath + "\n"); |
98 |
writer.write(" gvSIG locale language: " + Launcher.getAndamiConfig().getLocaleLanguage() + "\n"); |
99 |
writer.write("OS name: " + props.get("os.name") + "\n"); |
100 |
writer.write(" arch:" + props.get("os.arch") + "\n"); |
101 |
writer.write(" version:"+ props.get("os.version") + "\n"); |
102 |
writer.write("JAVA vendor: " + props.get("java.vendor") + "\n"); |
103 |
writer.write(" version:" +props.get("java.version")+ "\n"); |
104 |
writer.write(" home: " + props.get("java.home") + "\n"); |
105 |
//if (props.get("os.name").toLowerCase().equals("linux"))
|
106 |
return writer.toString();
|
107 |
} |
108 |
|
109 |
public void terminate() { |
110 |
|
111 |
super.terminate();
|
112 |
try {
|
113 |
LayerFactory.getDataSourceFactory().finalizeThis(); |
114 |
} catch (Exception e) { |
115 |
//e.printStackTrace();
|
116 |
} |
117 |
|
118 |
} |
119 |
} |