root / tags / v1_0_2_Build_901 / extensions / extCAD / src / com / iver / cit / gvsig / CreateNewLayer.java @ 10571
History | View | Annotate | Download (5.17 KB)
1 |
package com.iver.cit.gvsig; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import javax.swing.ImageIcon; |
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.wizard.WizardAndami; |
12 |
import com.iver.cit.gvsig.fmap.MapControl; |
13 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
14 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
17 |
import com.iver.cit.gvsig.gui.cad.MyFinishAction; |
18 |
import com.iver.cit.gvsig.gui.cad.panels.ChooseGeometryType; |
19 |
import com.iver.cit.gvsig.gui.cad.panels.FileBasedPanel; |
20 |
import com.iver.cit.gvsig.gui.cad.panels.JPanelFieldDefinition; |
21 |
import com.iver.cit.gvsig.gui.cad.panels.PostGISpanel; |
22 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
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 |
Driver driver = writerManager.getDriver("gvSIG shp driver"); |
81 |
panelFields.setWriter(((IWriteable)driver).getWriter()); |
82 |
panelChoose.setDriver(driver); |
83 |
FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
|
84 |
filePanel.setFileExtension("shp");
|
85 |
wizard.getWizardComponents().addWizardPanel(filePanel); |
86 |
|
87 |
wizard.getWizardComponents().setFinishAction( |
88 |
new MyFinishAction(wizard.getWizardComponents(),
|
89 |
vista, actionCommand)); |
90 |
} |
91 |
if (actionCommand.equals("DXF")) |
92 |
{ |
93 |
panelChoose.setDriver(writerManager.getDriver("gvSIG DXF Memory Driver"));
|
94 |
FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
|
95 |
filePanel.setFileExtension("dxf");
|
96 |
wizard.getWizardComponents().addWizardPanel(filePanel); |
97 |
wizard.getWizardComponents().getBackButton().setEnabled(false);
|
98 |
wizard.getWizardComponents().getNextButton().setEnabled(false);
|
99 |
|
100 |
wizard.getWizardComponents().setFinishAction( |
101 |
new MyFinishAction(wizard.getWizardComponents(),
|
102 |
vista, actionCommand)); |
103 |
} |
104 |
if (actionCommand.equals("POSTGIS")) |
105 |
{ |
106 |
wizard.getWizardComponents().addWizardPanel(panelChoose); |
107 |
wizard.getWizardComponents().addWizardPanel(panelFields); |
108 |
Driver driver = writerManager.getDriver("PostGIS JDBC Driver"); |
109 |
panelChoose.setDriver(driver); |
110 |
panelFields.setWriter(((IWriteable)driver).getWriter()); |
111 |
wizard.getWizardComponents().addWizardPanel( |
112 |
new PostGISpanel(wizard.getWizardComponents()));
|
113 |
|
114 |
wizard.getWizardComponents().setFinishAction( |
115 |
new MyFinishAction(wizard.getWizardComponents(),
|
116 |
vista, actionCommand)); |
117 |
} |
118 |
wizard.getWizardComponents().getFinishButton().setEnabled(false);
|
119 |
wizard.getWindowInfo().setWidth(640);
|
120 |
wizard.getWindowInfo().setHeight(350);
|
121 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this,"new_layer")); |
122 |
// Utilities.centerComponentOnScreen(wizard);
|
123 |
// wizardFrame.show();
|
124 |
PluginServices.getMDIManager().addWindow(wizard); |
125 |
// System.out.println("Salgo con " + panelChoose.getLayerName());
|
126 |
} |
127 |
} |
128 |
/**
|
129 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
130 |
*/
|
131 |
public boolean isEnabled() { |
132 |
View f = (View) PluginServices.getMDIManager().getActiveWindow(); |
133 |
|
134 |
if (f == null) |
135 |
return false; |
136 |
return true; |
137 |
} |
138 |
|
139 |
/**
|
140 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
141 |
*/
|
142 |
public boolean isVisible() { |
143 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
144 |
.getActiveWindow(); |
145 |
|
146 |
if (f == null) { |
147 |
return false; |
148 |
} |
149 |
|
150 |
if (f instanceof View) |
151 |
return true; |
152 |
return false; |
153 |
} |
154 |
} |