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