svn-gvsig-desktop / tags / v10_RC2c / extensions / extCAD / src / com / iver / cit / gvsig / CreateNewLayer.java @ 8745
History | View | Annotate | Download (4.95 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import javax.swing.ImageIcon; |
6 |
|
7 |
import org.gvsig.gui.beans.wizard.WizardAndami; |
8 |
|
9 |
import com.hardcode.driverManager.Driver; |
10 |
import com.hardcode.driverManager.DriverManager; |
11 |
import com.iver.andami.PluginServices; |
12 |
import com.iver.andami.plugins.Extension; |
13 |
import com.iver.cit.gvsig.fmap.MapControl; |
14 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.cit.gvsig.gui.View; |
17 |
import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
18 |
import com.iver.cit.gvsig.gui.cad.MyFinishAction; |
19 |
import com.iver.cit.gvsig.gui.cad.panels.ChooseGeometryType; |
20 |
import com.iver.cit.gvsig.gui.cad.panels.FileBasedPanel; |
21 |
import com.iver.cit.gvsig.gui.cad.panels.JPanelFieldDefinition; |
22 |
import com.iver.cit.gvsig.gui.cad.panels.PostGISpanel; |
23 |
|
24 |
/**
|
25 |
* DOCUMENT ME!
|
26 |
*
|
27 |
* @author Vicente Caballero Navarro
|
28 |
*/
|
29 |
public class CreateNewLayer extends Extension { |
30 |
static ImageIcon LOGO; |
31 |
|
32 |
/**
|
33 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
34 |
*/
|
35 |
public void initialize() { |
36 |
} |
37 |
|
38 |
/**
|
39 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
40 |
*/
|
41 |
public void execute(String actionCommand) { |
42 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
43 |
.getActiveWindow(); |
44 |
|
45 |
if (f instanceof View) { |
46 |
View vista = (View) f; |
47 |
|
48 |
LOGO = new javax.swing.ImageIcon(this.getClass().getClassLoader() |
49 |
.getResource("images/package_graphics.png"));
|
50 |
CADToolAdapter cta=CADExtension.getCADToolAdapter(); |
51 |
MapControl mapControl = vista.getMapControl(); |
52 |
cta.setMapControl(mapControl); |
53 |
/* SimpleLogoJWizardFrame wizardFrame = new SimpleLogoJWizardFrame(
|
54 |
LOGO);
|
55 |
wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
56 |
|
57 |
SwingUtilities.updateComponentTreeUI(wizardFrame);
|
58 |
|
59 |
wizardFrame.setTitle("Creaci?n de un nuevo Tema"); */
|
60 |
WizardAndami wizard = new WizardAndami(LOGO);
|
61 |
|
62 |
DriverManager writerManager = LayerFactory.getDM();
|
63 |
ArrayList spatialDrivers = new ArrayList(); |
64 |
String[] writerNames = writerManager.getDriverNames(); |
65 |
for (int i=0; i<writerNames.length; i++) |
66 |
{ |
67 |
Driver drv = writerManager.getDriver(writerNames[i]);
|
68 |
if (drv instanceof ISpatialWriter) |
69 |
spatialDrivers.add(drv.getName()); |
70 |
} |
71 |
|
72 |
ChooseGeometryType panelChoose = new ChooseGeometryType(wizard.getWizardComponents());
|
73 |
JPanelFieldDefinition panelFields = new JPanelFieldDefinition(wizard.getWizardComponents());
|
74 |
|
75 |
if (actionCommand.equals("SHP")) |
76 |
{ |
77 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
78 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
79 |
|
80 |
panelChoose.setDriver(writerManager.getDriver("gvSIG shp driver"));
|
81 |
FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
|
82 |
filePanel.setFileExtension("shp");
|
83 |
wizard.getWizardComponents().addWizardPanel(filePanel); |
84 |
|
85 |
wizard.getWizardComponents().setFinishAction( |
86 |
new MyFinishAction(wizard.getWizardComponents(),
|
87 |
vista, actionCommand)); |
88 |
} |
89 |
if (actionCommand.equals("DXF")) |
90 |
{ |
91 |
panelChoose.setDriver(writerManager.getDriver("gvSIG DXF Memory Driver"));
|
92 |
FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
|
93 |
filePanel.setFileExtension("dxf");
|
94 |
wizard.getWizardComponents().addWizardPanel(filePanel); |
95 |
wizard.getWizardComponents().getBackButton().setEnabled(false);
|
96 |
wizard.getWizardComponents().getNextButton().setEnabled(false);
|
97 |
|
98 |
wizard.getWizardComponents().setFinishAction( |
99 |
new MyFinishAction(wizard.getWizardComponents(),
|
100 |
vista, actionCommand)); |
101 |
} |
102 |
if (actionCommand.equals("POSTGIS")) |
103 |
{ |
104 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
105 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
106 |
Driver driver = writerManager.getDriver("PostGIS JDBC Driver"); |
107 |
panelChoose.setDriver(driver); |
108 |
wizard.getWizardComponents().addWizardPanel( |
109 |
new PostGISpanel(wizard.getWizardComponents()));
|
110 |
|
111 |
wizard.getWizardComponents().setFinishAction( |
112 |
new MyFinishAction(wizard.getWizardComponents(),
|
113 |
vista, actionCommand)); |
114 |
} |
115 |
wizard.getWizardComponents().getFinishButton().setEnabled(false);
|
116 |
wizard.getWindowInfo().setWidth(540);
|
117 |
wizard.getWindowInfo().setHeight(350);
|
118 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this,"new_layer")); |
119 |
// Utilities.centerComponentOnScreen(wizard);
|
120 |
// wizardFrame.show();
|
121 |
PluginServices.getMDIManager().addWindow(wizard); |
122 |
// System.out.println("Salgo con " + panelChoose.getLayerName());
|
123 |
} |
124 |
} |
125 |
/**
|
126 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
127 |
*/
|
128 |
public boolean isEnabled() { |
129 |
View f = (View) PluginServices.getMDIManager().getActiveWindow(); |
130 |
|
131 |
if (f == null) |
132 |
return false; |
133 |
return true; |
134 |
} |
135 |
|
136 |
/**
|
137 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
138 |
*/
|
139 |
public boolean isVisible() { |
140 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
141 |
.getActiveWindow(); |
142 |
|
143 |
if (f == null) { |
144 |
return false; |
145 |
} |
146 |
|
147 |
if (f instanceof View) |
148 |
return true; |
149 |
return false; |
150 |
} |
151 |
} |