root / branches / gvSIG_1.11.0_Mejoras_gvSIG-EIEL / extensions / extOracleSpatial / src / es / prodevelop / cit / gvsig / jdbc_spatial / NewOracleSpatialTableExtension.java @ 34767
History | View | Annotate | Download (4.22 KB)
1 |
package es.prodevelop.cit.gvsig.jdbc_spatial; |
---|---|
2 |
|
3 |
import javax.swing.ImageIcon; |
4 |
|
5 |
import org.apache.log4j.Logger; |
6 |
|
7 |
import com.hardcode.driverManager.Driver; |
8 |
import com.hardcode.driverManager.DriverManager; |
9 |
import com.iver.andami.PluginServices; |
10 |
import com.iver.andami.plugins.Extension; |
11 |
import com.iver.andami.ui.mdiManager.IWindow; |
12 |
import com.iver.andami.ui.wizard.WizardAndami; |
13 |
import com.iver.cit.gvsig.fmap.MapContext; |
14 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
17 |
import com.prodevelop.cit.gvsig.vectorialdb.wizard.NewVectorDBConnectionPanel; |
18 |
|
19 |
import es.prodevelop.cit.gvsig.fmap.drivers.jdbc.oracle.OracleSpatialDriver; |
20 |
import es.prodevelop.cit.gvsig.jdbc_spatial.gui.jdbcwizard.RepeatedChooseGeometryTypePanel; |
21 |
import es.prodevelop.cit.gvsig.jdbc_spatial.gui.jdbcwizard.RepeatedFieldDefinitionPanel; |
22 |
|
23 |
public class NewOracleSpatialTableExtension extends Extension { |
24 |
|
25 |
private static Logger logger = Logger.getLogger(NewOracleSpatialTableExtension.class.getName()); |
26 |
public static boolean ORACLE_JAR_PRESENT = false; |
27 |
|
28 |
public void initialize() { |
29 |
ORACLE_JAR_PRESENT = isOracleJarPresent(); |
30 |
} |
31 |
|
32 |
public void execute(String actionCommand) { |
33 |
if (actionCommand.compareToIgnoreCase("NEW_ORACLE_SPATIAL") == 0) { |
34 |
|
35 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
36 |
if (w instanceof View) { |
37 |
try {
|
38 |
String _file = createResourceUrl("images/new_geodb_table.png").getFile(); |
39 |
ImageIcon iicon = new ImageIcon(_file); |
40 |
|
41 |
DriverManager writerManager = LayerFactory.getDM();
|
42 |
WizardAndami wizard = new WizardAndami(iicon);
|
43 |
RepeatedChooseGeometryTypePanel panelChoose = |
44 |
new RepeatedChooseGeometryTypePanel(wizard.getWizardComponents());
|
45 |
RepeatedFieldDefinitionPanel panelFields = |
46 |
new RepeatedFieldDefinitionPanel(wizard.getWizardComponents());
|
47 |
NewVectorDBConnectionPanel connPanel = |
48 |
new NewVectorDBConnectionPanel(
|
49 |
wizard.getWizardComponents(), |
50 |
OracleSpatialDriver.NAME, |
51 |
OracleSpatialDriver.MAX_ID_LENGTH); |
52 |
|
53 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
54 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
55 |
wizard.getWizardComponents().addWizardPanel(connPanel); |
56 |
|
57 |
Driver driver = writerManager.getDriver(OracleSpatialDriver.NAME);
|
58 |
panelFields.setWriter(((IWriteable) driver).getWriter()); |
59 |
panelChoose.setDriver(driver); |
60 |
|
61 |
|
62 |
View theView = (View) w; |
63 |
MapContext mc = theView.getMapControl().getMapContext(); |
64 |
|
65 |
NewOracleSpatialTableFinishAction action = |
66 |
new NewOracleSpatialTableFinishAction(
|
67 |
wizard.getWizardComponents(), |
68 |
wizard, |
69 |
connPanel, |
70 |
mc); |
71 |
|
72 |
wizard.getWizardComponents().setFinishAction(action); |
73 |
wizard.getWizardComponents().getFinishButton().setEnabled(false);
|
74 |
wizard.getWindowInfo().setWidth(640);
|
75 |
wizard.getWindowInfo().setHeight(350);
|
76 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this, "new_layer")); |
77 |
PluginServices.getMDIManager().addWindow(wizard); |
78 |
|
79 |
} catch (Exception ex) { |
80 |
logger.error("While showing new oracle spatial table wizard: " + ex.getMessage());
|
81 |
} |
82 |
} |
83 |
} |
84 |
} |
85 |
|
86 |
public boolean isEnabled() { |
87 |
|
88 |
if (!ORACLE_JAR_PRESENT) return false; |
89 |
|
90 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
91 |
return (w instanceof View); |
92 |
} |
93 |
|
94 |
public boolean isVisible() { |
95 |
return isEnabled();
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Check presence of ojdbc14.jar.
|
100 |
* @return
|
101 |
*/
|
102 |
private boolean isOracleJarPresent() { |
103 |
|
104 |
try {
|
105 |
Class rowid_class = Class.forName("oracle.sql.ROWID"); |
106 |
} catch (Exception ex) { |
107 |
logger.error("Unable to instantiate ROWID (oracle jar missing?) : " + ex.getMessage());
|
108 |
return false; |
109 |
} |
110 |
return true; |
111 |
} |
112 |
|
113 |
private java.net.URL createResourceUrl(String path) { |
114 |
return getClass().getClassLoader().getResource(path);
|
115 |
} |
116 |
|
117 |
} |
118 |
|
119 |
// [eiel-gestion-conexiones]
|
120 |
|