Revision 29579 branches/v2_0_0_prep/extensions/extOracleSpatial/src/org/gvsig/oraclespatial/extension/NewOracleSpatialTableExtension.java
NewOracleSpatialTableExtension.java | ||
---|---|---|
15 | 15 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
16 | 16 |
|
17 | 17 |
public class NewOracleSpatialTableExtension extends Extension { |
18 |
|
|
19 |
private static Logger logger = Logger.getLogger(NewOracleSpatialTableExtension.class.getName()); |
|
20 |
public static boolean ORACLE_JAR_PRESENT = false; |
|
21 |
|
|
22 | 18 |
|
19 |
private static Logger logger = Logger |
|
20 |
.getLogger(NewOracleSpatialTableExtension.class.getName()); |
|
21 |
public static boolean ORACLE_JAR_PRESENT = false; |
|
22 |
|
|
23 |
/** |
|
24 |
* Initialize extension |
|
25 |
*/ |
|
23 | 26 |
public void initialize() { |
27 |
// Validate if Oracle Jar is present |
|
24 | 28 |
ORACLE_JAR_PRESENT = isOracleJarPresent(); |
25 | 29 |
} |
26 | 30 |
|
31 |
/** |
|
32 |
* execute extension process |
|
33 |
* |
|
34 |
* @param event |
|
35 |
* name |
|
36 |
*/ |
|
27 | 37 |
public void execute(String actionCommand) { |
28 |
if (actionCommand.compareToIgnoreCase("NEW_ORACLE_SPATIAL") == 0) { |
|
29 | 38 |
|
30 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
31 |
if (w instanceof View) { |
|
32 |
try { |
|
33 |
String _file = createResourceUrl("images/new_geodb_table.png").getFile(); |
|
34 |
ImageIcon iicon = new ImageIcon(_file); |
|
35 |
|
|
36 |
WizardAndami wizard = new WizardAndami(iicon); |
|
37 |
RepeatedChooseGeometryTypePanel panelChoose = |
|
38 |
new RepeatedChooseGeometryTypePanel(wizard.getWizardComponents()); |
|
39 |
RepeatedFieldDefinitionPanel panelFields = |
|
40 |
new RepeatedFieldDefinitionPanel(wizard.getWizardComponents()); |
|
41 |
NewOracleSpatialTableWizard connPanel = |
|
42 |
new NewOracleSpatialTableWizard(wizard.getWizardComponents()); |
|
39 |
// NEW ORACLE TABLE |
|
40 |
if (actionCommand.compareToIgnoreCase("NEW_ORACLE_SPATIAL") == 0) { |
|
43 | 41 |
|
44 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
|
45 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
|
46 |
wizard.getWizardComponents().addWizardPanel(connPanel); |
|
42 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
43 |
if (w instanceof View) { |
|
44 |
try { |
|
45 |
String _file = createResourceUrl( |
|
46 |
"images/new_geodb_table.png").getFile(); |
|
47 |
ImageIcon iicon = new ImageIcon(_file); |
|
47 | 48 |
|
48 |
View theView = (View) w; |
|
49 |
MapContext mc = theView.getMapControl().getMapContext(); |
|
50 |
|
|
51 |
NewOracleSpatialTableFinishAction action = |
|
52 |
new NewOracleSpatialTableFinishAction( |
|
53 |
wizard.getWizardComponents(), |
|
54 |
wizard, |
|
55 |
connPanel, |
|
56 |
mc); |
|
57 |
|
|
58 |
wizard.getWizardComponents().setFinishAction(action); |
|
59 |
wizard.getWizardComponents().getFinishButton().setEnabled(false); |
|
60 |
wizard.getWindowInfo().setWidth(640); |
|
61 |
wizard.getWindowInfo().setHeight(350); |
|
62 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this, "new_layer")); |
|
63 |
PluginServices.getMDIManager().addWindow(wizard); |
|
64 |
|
|
65 |
} catch (Exception ex) { |
|
66 |
logger.error("While showing new oracle spatial table wizard: " + ex.getMessage()); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
49 |
WizardAndami wizard = new WizardAndami(iicon); |
|
50 |
RepeatedChooseGeometryTypePanel panelChoose = new RepeatedChooseGeometryTypePanel( |
|
51 |
wizard.getWizardComponents()); |
|
52 |
RepeatedFieldDefinitionPanel panelFields = new RepeatedFieldDefinitionPanel( |
|
53 |
wizard.getWizardComponents()); |
|
54 |
NewOracleSpatialTableWizard connPanel = new NewOracleSpatialTableWizard( |
|
55 |
wizard.getWizardComponents()); |
|
56 |
|
|
57 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
|
58 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
|
59 |
wizard.getWizardComponents().addWizardPanel(connPanel); |
|
60 |
|
|
61 |
View theView = (View) w; |
|
62 |
MapContext mc = theView.getMapControl().getMapContext(); |
|
63 |
|
|
64 |
NewOracleSpatialTableFinishAction action = new NewOracleSpatialTableFinishAction( |
|
65 |
wizard.getWizardComponents(), wizard, connPanel, mc); |
|
66 |
|
|
67 |
wizard.getWizardComponents().setFinishAction(action); |
|
68 |
wizard.getWizardComponents().getFinishButton().setEnabled( |
|
69 |
false); |
|
70 |
wizard.getWindowInfo().setWidth(640); |
|
71 |
wizard.getWindowInfo().setHeight(350); |
|
72 |
wizard.getWindowInfo().setTitle( |
|
73 |
PluginServices.getText(this, "new_layer")); |
|
74 |
PluginServices.getMDIManager().addWindow(wizard); |
|
75 |
|
|
76 |
} catch (Exception ex) { |
|
77 |
logger |
|
78 |
.error("While showing new oracle spatial table wizard: " |
|
79 |
+ ex.getMessage()); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
70 | 83 |
} |
71 | 84 |
|
85 |
/** |
|
86 |
* extension enable |
|
87 |
* |
|
88 |
* @return |
|
89 |
*/ |
|
72 | 90 |
public boolean isEnabled() { |
73 | 91 |
|
74 |
if (!ORACLE_JAR_PRESENT) return false; |
|
75 |
|
|
92 |
if (!ORACLE_JAR_PRESENT) |
|
93 |
return false; |
|
94 |
|
|
76 | 95 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
77 |
return (w instanceof View);
|
|
96 |
return (w instanceof View);
|
|
78 | 97 |
} |
79 | 98 |
|
99 |
/** |
|
100 |
* extension functionalities visible |
|
101 |
* |
|
102 |
* @return |
|
103 |
*/ |
|
80 | 104 |
public boolean isVisible() { |
81 | 105 |
return isEnabled(); |
82 | 106 |
} |
83 |
|
|
107 |
|
|
84 | 108 |
/** |
85 | 109 |
* Check presence of ojdbc14.jar. |
110 |
* |
|
86 | 111 |
* @return |
87 | 112 |
*/ |
88 |
private boolean isOracleJarPresent() { |
|
89 |
|
|
90 |
try { |
|
91 |
Class rowid_class = Class.forName("oracle.sql.ROWID"); |
|
92 |
} catch (Exception ex) { |
|
93 |
logger.error("Unable to instantiate ROWID (oracle jar missing?) : " + ex.getMessage()); |
|
94 |
return false; |
|
95 |
} |
|
113 |
private boolean isOracleJarPresent() { |
|
114 |
|
|
115 |
try { |
|
116 |
Class rowid_class = Class.forName("oracle.sql.ROWID"); |
|
117 |
} catch (Exception ex) { |
|
118 |
logger.error("Unable to instantiate ROWID (oracle jar missing?) : " |
|
119 |
+ ex.getMessage()); |
|
120 |
return false; |
|
121 |
} |
|
96 | 122 |
return true; |
97 |
} |
|
98 |
|
|
99 |
private java.net.URL createResourceUrl(String path) { |
|
100 |
return getClass().getClassLoader().getResource(path); |
|
101 |
} |
|
123 |
} |
|
102 | 124 |
|
125 |
private java.net.URL createResourceUrl(String path) { |
|
126 |
return getClass().getClassLoader().getResource(path); |
|
127 |
} |
|
128 |
|
|
103 | 129 |
} |
Also available in: Unified diff