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