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