Revision 11699 branches/F2/extensions/extJCRS/src/org/gvsig/crs/gui/panels/wizard/MainPanel.java

View differences:

MainPanel.java
5 5
import java.awt.FlowLayout;
6 6
import java.awt.event.ActionEvent;
7 7
import java.awt.event.ActionListener;
8
import java.sql.ResultSet;
8 9
import java.sql.SQLException;
9 10

  
10 11
import javax.swing.JButton;
12
import javax.swing.JOptionPane;
11 13
import javax.swing.JPanel;
12 14

  
13 15
import org.gvsig.crs.ICrs;
16
import org.gvsig.crs.gui.panels.EPSGpanel;
14 17

  
15 18
import com.iver.andami.PluginServices;
16 19
import com.iver.andami.ui.mdiManager.IWindow;
17 20
import com.iver.andami.ui.mdiManager.WindowInfo;
18 21

  
19 22
import es.idr.teledeteccion.connection.EpsgConnection;
23
import es.idr.teledeteccion.connection.Query;
20 24

  
21 25

  
22 26
/**
......
178 182
				}
179 183
				else fillData(getCrs());
180 184
			}
185
			else if (getPCrsUsr().isShowing() && getPCrsUsr().getRbNuevoCrs().isSelected() ){
186
				cleanData();
187
			}
181 188
			cl.next(pCard);
182 189
			getBtnAnterior().setVisible(true);
183 190
			//Si aparece el ultimo panel visualizar el botn finalizar
......
190 197
				
191 198
		}else if(e.getSource().equals(getBtnFinalizar())){
192 199
			//Realizar las acciones de fin del Wizard
193
			getDataAndUpdate();
194
			System.out.println("Finalizar el Asistente");
195
			System.out.println("Cerrar el Asistente");
196
			PluginServices.getMDIManager().closeWindow(this);
197
			
200
			getDataAndUpdate();			
198 201
		}else if(e.getSource().equals(getBtnCancelar())){
199 202
			//Cerrar el asistente
200 203
			PluginServices.getMDIManager().closeWindow(this);
......
224 227
		getPSistCoord().fillData(crs);
225 228
	}
226 229
	
230
	private void cleanData() {
231
		getPDatum().cleanData();
232
		getPSistCoord().cleanData();
233
	}
234
	
227 235
	private void getDataAndUpdate() {
236
		EpsgConnection conn = new EpsgConnection();
237
		conn.setConnectionUsr();
228 238
		String[] spheroid = {getPDatum().getTxtElipsoide().getText(),
229 239
							getPDatum().getTxtSemMay().getText(), 
230 240
							getPDatum().getTxtInvF().getText()};
......
232 242
							getPDatum().getTxtLong().getText()};
233 243
		
234 244
		String[] authority = {"\"USR\"", "2001"};
245
		String sentence = "SELECT usr_code FROM USR WHERE usr_code = " +authority[1];
246
		ResultSet result = Query.select(sentence, conn.getConnection());
247
		try {
248
			if (result.next()) {
249
				JOptionPane.showMessageDialog(MainPanel.this, 
250
						PluginServices.getText(this,"crsRepeat")+": "+authority[1], 
251
						"Warning...", JOptionPane.WARNING_MESSAGE);
252
				return;
253
			}
254
		} catch (SQLException e1) {
255
			// TODO Auto-generated catch block
256
			e1.printStackTrace();
257
		}
235 258
		String datum = getPDatum().getTxtDatum().getText();
236
		String sentence;
237 259
		
260
		
238 261
		if (getPSistCoord().getRbGeografico().isSelected()) {
239 262
			cadWkt = "GEOGCS[\"" + "Nombre crs usuario" + "\", DATUM[\""+ datum +
240 263
			"\", SPHEROID[\""+ spheroid[0] + "\", "+ spheroid[1] + ", "+ spheroid[2] +"]], " +
......
266 289
			sentence = "INSERT INTO USR VALUES("+authority[1]+",'" +
267 290
			cadWkt +"','crs proyectado usuario','Nombre crs usuario','"+datum+"')";
268 291
	
269
		}
270
		EpsgConnection conn = new EpsgConnection();
271
		conn.setConnectionUsr();
292
		}		
272 293
				
273 294
		try {
274 295
			conn.update(sentence);
......
276 297
		} catch (SQLException e) {
277 298
			// TODO Auto-generated catch block
278 299
			e.printStackTrace();
279
		}
280
		
300
		}		
281 301
		setNewCrsCode(Integer.parseInt(authority[1]));
302
		PluginServices.getMDIManager().closeWindow(this);
282 303
	}
283 304
	
284 305
	public void setNewCrsCode(int code) {

Also available in: Unified diff