Revision 37144 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/StopEditing.java

View differences:

StopEditing.java
5 5

  
6 6
import javax.swing.JOptionPane;
7 7

  
8
import org.cresques.cts.IProjection;
8 9
import org.gvsig.andami.PluginServices;
10
import org.gvsig.andami.PluginsLocator;
9 11
import org.gvsig.andami.messages.NotificationManager;
10 12
import org.gvsig.andami.plugins.Extension;
11 13
import org.gvsig.andami.plugins.IExtension;
12 14
import org.gvsig.andami.plugins.status.IExtensionStatus;
13 15
import org.gvsig.andami.plugins.status.IUnsavedData;
14 16
import org.gvsig.andami.plugins.status.UnsavedData;
15
import org.gvsig.app.extension.ProjectExtension;
16 17
import org.gvsig.app.project.Project;
17 18
import org.gvsig.app.project.ProjectManager;
18
import org.gvsig.app.project.documents.table.exceptions.CancelEditingTableException;
19
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
19
import org.gvsig.app.project.documents.view.DefaultViewDocument;
20 20
import org.gvsig.app.project.documents.view.ViewDocument;
21
import org.gvsig.app.project.documents.view.DefaultViewDocument;
22 21
import org.gvsig.app.project.documents.view.ViewManager;
23 22
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
24 23
import org.gvsig.editing.gui.cad.CADToolAdapter;
25 24
import org.gvsig.editing.layers.VectorialLayerEdited;
25
import org.gvsig.exportto.app.extension.ExporttoLayerExtension;
26 26
import org.gvsig.fmap.dal.exception.DataException;
27 27
import org.gvsig.fmap.dal.exception.ReadException;
28 28
import org.gvsig.fmap.dal.exception.WriteException;
......
139 139
//			// TODO Auto-generated catch block
140 140
//			e1.printStackTrace();
141 141
//		}
142
		int resp = JOptionPane.NO_OPTION;
142
		int resp = JOptionPane.CANCEL_OPTION;
143 143

  
144 144
		try {
145 145
			if (layer.isWritable()) {
146
				resp = JOptionPane.showConfirmDialog((Component) PluginServices
147
						.getMainFrame(), PluginServices.getText(this,
148
						"realmente_desea_guardar_la_capa")
149
						+ " : " + layer.getName()+"?", PluginServices.getText(this,
150
						"guardar"), JOptionPane.YES_NO_OPTION);
151
				if (resp == JOptionPane.YES_OPTION) { // GUARDAMOS EL TEMA
146
//				resp = JOptionPane.showConfirmDialog((Component) PluginServices
147
//						.getMainFrame(), PluginServices.getText(this,
148
//						"realmente_desea_guardar_la_capa")
149
//						+ " : " + layer.getName()+"?", PluginServices.getText(this,
150
//						"guardar"), JOptionPane.YES_NO_OPTION);
151
//				if (resp == JOptionPane.YES_OPTION) { // GUARDAMOS EL TEMA
152
//					saveLayer(layer);
153
//
154
//				} else if (resp == JOptionPane.NO_OPTION){ // CANCEL EDITING
155
//					cancelEdition(layer);
156
//				} else {
157
//					return false;
158
//				}
159
				
160
				
161
				Object[] options = {PluginServices.getText(this, "guardar"),
162
						PluginServices.getText(this, "finish_editing_without_saving_changes"),
163
						PluginServices.getText(this, "continue_editing")};
164

  
165
				resp = JOptionPane.showOptionDialog(
166
						(Component) PluginServices.getMainFrame(),
167
						PluginServices
168
						.getText(
169
								this,
170
								"realmente_desea_guardar_la_capa")
171
						+ " : " + layer.getName(),
172
						PluginServices.getText(this, "stop_edition"),
173
						JOptionPane.YES_NO_CANCEL_OPTION,
174
						JOptionPane.QUESTION_MESSAGE,
175
						null, options, options[2]);
176
				if (resp == JOptionPane.YES_OPTION) { //SAVE
152 177
					saveLayer(layer);
153

  
154
				} else if (resp == JOptionPane.NO_OPTION){ // CANCEL EDITING
178
					layer.setEditing(false);
179
				} else if (resp == JOptionPane.NO_OPTION) { // CANCEL EDITING
155 180
					cancelEdition(layer);
156
				} else {
157
					return false;
181
					layer.setEditing(false);
182
					return true;
158 183
				}
184
				
185
				
159 186

  
160 187
//				featureStore.deleteObservers();
161
				layer.setEditing(false);
188
//				layer.setEditing(false);
162 189
//				if (layer.isSpatiallyIndexed())
163 190
//	            {
164 191
//	            	if(vea.getSpatialIndex() != null)
......
175 202
				return true;
176 203
			}
177 204
			// Si no existe writer para la capa que tenemos en edici?n
178
				resp = JOptionPane
179
						.showConfirmDialog(
180
								(Component) PluginServices.getMainFrame(),
181
								PluginServices
182
										.getText(
183
												this,
184
												"no_existe_writer_para_este_formato_de_capa_o_no_tiene_permisos_de_escritura_los_datos_no_se_guardaran_desea_continuar")
185
										+ " : " + layer.getName(),
186
								PluginServices.getText(this, "cancelar_edicion"),
187
								JOptionPane.YES_NO_OPTION);
188
				if (resp == JOptionPane.YES_OPTION) { // CANCEL EDITING
205
//				resp = JOptionPane
206
//						.showConfirmDialog(
207
//								(Component) PluginServices.getMainFrame(),
208
//								PluginServices
209
//										.getText(
210
//												this,
211
//												"no_existe_writer_para_este_formato_de_capa_o_no_tiene_permisos_de_escritura_los_datos_no_se_guardaran_desea_continuar")
212
//										+ " : " + layer.getName(),
213
//								PluginServices.getText(this, "stop_edition"),
214
//								JOptionPane.YES_NO_OPTION);
215
				Object[] options = {PluginServices.getText(this, "export"),
216
						PluginServices.getText(this, "finish_editing_without_saving_changes"),
217
						PluginServices.getText(this, "continue_editing")};
218

  
219
				resp = JOptionPane.showOptionDialog(
220
						(Component) PluginServices.getMainFrame(),
221
						PluginServices
222
						.getText(
223
								this,
224
								"no_existe_writer_para_este_formato_de_capa_o_no_tiene_permisos_de_escritura_los_datos_que_desea_hacer")
225
						+ " : " + layer.getName(),
226
						PluginServices.getText(this, "stop_edition"),
227
						JOptionPane.YES_NO_CANCEL_OPTION,
228
						JOptionPane.QUESTION_MESSAGE,
229
						null, options, options[2]);
230
				if (resp == JOptionPane.NO_OPTION) { // CANCEL EDITING
189 231
					cancelEdition(layer);
190

  
191
//					featureStore.deleteObservers();
192
//					if (!(layer.getSource().getDriver() instanceof IndexedShpDriver)){
193
//						VectorialLayerEdited vle=(VectorialLayerEdited)CADExtension.getEditionManager().getLayerEdited(layer);
194
//						layer.setLegend((IVectorLegend)vle.getLegend());
195
//					}
196 232
					layer.setEditing(false);
197 233
					return true;
234
				} else if (resp == JOptionPane.YES_OPTION) {
235
					int status = exportLayer(layer);
236
					if (status == JOptionPane.OK_OPTION){
237
						cancelEdition(layer);
238
						layer.setEditing(false);
239
					}
198 240
				}
199 241

  
200 242
		} catch (StartEditionLayerException e) {
......
232 274
			throw new CancelEditingLayerException(layer.getName(), e);
233 275
		}
234 276
	}
235
	/**
277

  
278
	private int exportLayer(FLyrVect layer) throws ReadException{
279
		//FIXME
280
//		JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), "NO IMPLEMENTADO. Utilice la herramieneta de exportaci?n.");
281
		
282
		ViewDocument model = vista.getModel();
283
		MapContext mapContext = model.getMapContext();
284
		IProjection projection = mapContext.getProjection();
285
		
286
		ExporttoLayerExtension extension = (ExporttoLayerExtension) PluginsLocator.getManager().getExtension(ExporttoLayerExtension.class);
287
		return extension.showExportto(layer, projection, mapContext);
288
	}
289
/**
236 290
	 * @see org.gvsig.andami.plugins.IExtension#isVisible()
237 291
	 */
238 292
	public boolean isVisible() {

Also available in: Unified diff