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