Revision 11581 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.SQLException;
8 9

  
9 10
import javax.swing.JButton;
10 11
import javax.swing.JPanel;
......
15 16
import com.iver.andami.ui.mdiManager.IWindow;
16 17
import com.iver.andami.ui.mdiManager.WindowInfo;
17 18

  
19
import es.idr.teledeteccion.connection.EpsgConnection;
18 20

  
21

  
19 22
/**
20 23
 * 
21 24
 * @author Luisa Marina Fernndez (luisam.fernandez@uclm.es)
......
41 44
	 final static String SISTEMACOORDENADASPANEL = "SistemaCoordenadas";
42 45
	 
43 46
	private ICrs currentCrs;
47
	private String cadWkt;
48
	private int newCrsCode;
44 49
	
45 50
	public MainPanel(ICrs crs) {
46 51
		super();
......
155 160
		
156 161
		if(e.getSource().equals(getBtnAnterior())){
157 162
			
158
			if(getPCrsUsr().isShowing()){
159
				//Se est mostrando el primer panel del Wizard
163
			if(getPDatum().isShowing()){
164
				//Se va a mostrar el primer panel del Wizard
160 165
				getBtnAnterior().setVisible(false);
161
			}else{
162
				//Mostrar el panel anterior
163
				cl.previous(pCard);
164
				//Establecer los botones del Wizard
165
				getBtnFinalizar().setVisible(false);
166
				getBtnSiguiente().setVisible(true);
167
				
168
				System.out.println("Dentro de botonAnterior");
169 166
			}
167
			//Mostrar el panel anterior
168
			cl.previous(pCard);
169
			//Establecer los botones del Wizard
170
			getBtnFinalizar().setVisible(false);
171
			getBtnSiguiente().setVisible(true);
172
			
170 173
		}else if(e.getSource().equals(getBtnSiguiente())){
171 174
			if (getPCrsUsr().isShowing() && getPCrsUsr().getRbCrsExistente().isSelected() ){
172 175
				String authority = getPCrsUsr().getLblCrs().getText();
......
184 187
				
185 188
		}else if(e.getSource().equals(getBtnFinalizar())){
186 189
			//Realizar las acciones de fin del Wizard
190
			getDataAndUpdate();
187 191
			System.out.println("Finalizar el Asistente");
188 192
			System.out.println("Cerrar el Asistente");
189 193
			PluginServices.getMDIManager().closeWindow(this);
......
216 220
		getPDatum().fillData(getCrs());
217 221
		getPSistCoord().fillData(getCrs());
218 222
	}
219

  
220

  
223
	
224
	private void getDataAndUpdate() {
225
		String[] spheroid = {getPDatum().getTxtElipsoide().getText(),
226
							getPDatum().getTxtSemMay().getText(), 
227
							getPDatum().getTxtInvF().getText()};
228
		String[] primem = {getPDatum().getTxtMeridian().getText(),
229
							getPDatum().getTxtLong().getText()};
230
		
231
		String[] authority = {"\"USR\"", "2001"};
232
		String datum = getPDatum().getTxtDatum().getText();
233
		String sentence;
234
		
235
		if (getPSistCoord().getRbGeografico().isSelected()) {
236
			cadWkt = "GEOGCS[\"" + "Nombre crs usuario" + "\", DATUM[\""+ datum +
237
			"\", SPHEROID[\""+ spheroid[0] + "\", "+ spheroid[1] + ", "+ spheroid[2] +"]], " +
238
			"PRIMEM[\""+ primem[0] + "\", "+ primem[1] +"], UNIT[\"Degree\", " + (Math.PI/180) +
239
			"]]";
240
			
241
			sentence = "INSERT INTO USR VALUES("+authority[1]+",'" +
242
			cadWkt +"','','Nombre crs usuario','"+datum+"')";
243
	
244
		} else {
245
		
246
			cadWkt = "PROJCS[\""+ "crs proyectado usuario"/*A cambiar cuando arreglemos paneles*/+
247
				"\", GEOGCS[\"" + "Nombre crs usuario" + "\", DATUM[\""+ datum +
248
				"\", SPHEROID[\""+ spheroid[0] + "\", "+ spheroid[1] + ", "+ spheroid[2] +"]], " +
249
				"PRIMEM[\""+ primem[0] + "\", "+ primem[1] +"], UNIT[\"Degree\", " + (Math.PI/180) +
250
				"]], PROJECTION[\""+ getPSistCoord().getCbProyeccion().getSelectedItem().toString() + "\"], ";
251
				
252
			/*
253
			 * falta la parte de los parĂ¡metros... metodo para nombres...
254
			 */		
255
			for (int i= 0; i< getPSistCoord().getTableParametros().getRowCount();i++){
256
				cadWkt += "PARAMETER[\""+getPSistCoord().getTableParametros().getValueAt(i, 0)+"\", " + 
257
							getPSistCoord().getTableParametros().getValueAt(i, 1)+ "], ";
258
			}
259
			
260
			cadWkt += "UNIT[\"Meters\", 1.0]]";
261
			
262
			
263
			sentence = "INSERT INTO USR VALUES("+authority[1]+",'" +
264
			cadWkt +"','crs proyectado usuario','Nombre crs usuario','"+datum+"')";
265
	
266
		}
267
		EpsgConnection conn = new EpsgConnection();
268
		conn.setConnectionUsr();
269
				
270
		try {
271
			conn.update(sentence);
272
			conn.shutdown();
273
		} catch (SQLException e) {
274
			// TODO Auto-generated catch block
275
			e.printStackTrace();
276
		}
277
		
278
		setNewCrsCode(Integer.parseInt(authority[1]));
279
	}
280
	
281
	public void setNewCrsCode(int code) {
282
		newCrsCode = code;
283
	}
284
	
285
	public int getNewCrsCode() {
286
		return newCrsCode;
287
	}
288
	
221 289
}

Also available in: Unified diff