Revision 24625

View differences:

trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSAreaPanel.java
207 207

  
208 208
/**
209 209
 * VERSI?N PROVISIONAL ESTABLE
210
 * 
210
 *
211 211
 * This panel allows user to select the area he/she wants to get in the view.
212 212
 * There are two options to do this:
213 213
 *  - Indicating the coordinates of the top-left and down-right corners
......
240 240
	private final int SELECTION_BY_AREA_OPERATION = 2;
241 241
	private boolean hasUserDefinedAnArea = false;
242 242
//	private Rectangle2D lastExtentValid = null;
243
	private ExtentHistory previousExtentValids = null; 
243
	private ExtentHistory previousExtentValids = null;
244 244

  
245 245
	private WFSWizardData data = null;
246 246
	private AreaCoordinatesPanel coordinatesPanel = null;
......
285 285
		// We will use the adjusted extent because increases the usability
286 286
		Rectangle2D r2d = activeView.getMapControl().getViewPort().getAdjustedExtent();
287 287
//		Rectangle2D r2d = activeView.getMapControl().getViewPort().getExtent();
288
		
288

  
289 289
		if (r2d != null){
290 290
			previousExtentValids.put(r2d);
291
			
291

  
292 292
			setCoordinates(r2d.getMaxX(), r2d.getMaxY(), r2d.getMinX(), r2d.getMinY());
293 293
//			System.out.println("Extent de la vista activa: " + r2d);
294 294
//			getCoordinatesPanel().getJTextFieldVertex1X().setText(Double.toString(r2d.getMinX() + r2d.getWidth()));
......
299 299
//			getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(r2d.getMinY()));
300 300
		}
301 301
	}
302
	
302

  
303 303
	/**
304 304
	 * Removes all registered extents
305 305
	 */
......
310 310
			previousExtentValids.removePrev();
311 311
		}
312 312
	}
313
	
313

  
314 314
	/**
315
	 * <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p> 
316
	 * 
315
	 * <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p>
316
	 *
317 317
	 * @param v1x value of the x coordinate of the right-up corner of the rectangle
318 318
	 * @param v1y value of the y coordinate of the right-up corner of the rectangle
319 319
	 * @param v2x value of the x coordinate of the left-up corner of the rectangle
......
325 325
		getCoordinatesPanel().getJTextFieldVertex2X().setText(Double.toString(v2x));
326 326
		getCoordinatesPanel().getJTextFieldVertex2Y().setText(Double.toString(v2y));
327 327
	}
328
	
328

  
329 329
	/**
330
	 * <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p> 
331
	 * 
330
	 * <p>Sets the coordinates of all the text fields. It's supposed that all coordinates are valid.</p>
331
	 *
332 332
	 * @param bbox the bounding box that represents a rectangle with the information of all coordinates
333 333
	 */
334 334
	private void setCoordinates(Rectangle2D bbox) {
......
349 349
		}
350 350
		return coordinatesPanel;
351 351
	}
352
	
352

  
353 353
	/**
354 354
	 * This method initializes jEnablingCheckBox
355
	 * 
355
	 *
356 356
	 * @return javax.swing.JCheckBox
357 357
	 */
358 358
	private JCheckBox getEnablingJCheckBox() {
......
375 375
						jEnablingCheckBox.setToolTipText(PluginServices.getText(this, "enable_filter_by_area"));
376 376
				 		disableCoorderatesRegionOperation();
377 377
					}
378
					
378

  
379 379
					IPanelGroup panelGroup = getPanelGroup();
380
					
380

  
381 381
					if (panelGroup == null)
382 382
						return;
383
					
383

  
384 384
					((WFSParamsPanel)panelGroup).setApplicable(true);
385 385
				}
386 386
			});
......
475 475
//			getJToggleButtonScaling().setEnabled(true);
476 476
//			getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
477 477
		}
478
		
478

  
479 479
		getCoordinatesPanel().getJButtonValidateArea().setEnabled(true);
480
		
480

  
481 481
		this.repaint();
482 482
	}
483 483

  
......
512 512

  
513 513
		getCoordinatesPanel().setAllTextFieldsEnabled(false);
514 514
		getCoordinatesPanel().getJButtonValidateArea().setEnabled(false);
515
		
515

  
516 516
		this.repaint();
517 517
	}
518 518

  
......
840 840
	public Rectangle2D getExtent() {
841 841
		if (!getEnablingJCheckBox().isSelected())
842 842
			return null;
843
		
843

  
844 844
		if (!hasUserDefinedAnArea)
845 845
			return null;
846 846

  
......
850 850
		else {
851 851
			if (getCoordinatesPanel().validVertexes()) {
852 852
//				System.out.println("Extent que devuelve: " + getCoordinatesPanel().getExtent());
853
				
853

  
854 854
				return getCoordinatesPanel().getExtent();
855 855
			}
856 856
			else {
......
866 866
	 */
867 867
	private void setApplicable(boolean b) {
868 868
		IPanelGroup panelGroup = getPanelGroup();
869
		
869

  
870 870
		if (panelGroup == null)
871 871
			return;
872
		
872

  
873 873
		if (! ((WFSParamsPanel)panelGroup).getFilterPanel().getWFSFilterPanelIsAsTabForWFSLayersLoad())
874 874
			((WFSParamsPanel)panelGroup).setApplicable(b);
875 875
//			parent.isApplicable(true);
......
928 928
			for (i = (numberOfLayers-1); i >= 0; i--) {
929 929
				mapContext.getLayers().removeLayer(i);
930 930
			}
931

  
931
			PluginServices.getMainFrame().enableControls();
932 932
			// Adds the extent of the viewport of the current active view
933 933
			BaseView view = (BaseView) PluginServices.getMDIManager().getActiveWindow();
934 934
			ViewPort vP = view.getMapControl().getMapContext().getViewPort();
......
1413 1413
					public void focusLost(FocusEvent e) {
1414 1414
						if (!getEnablingJCheckBox().isSelected())
1415 1415
							return;
1416
						
1416

  
1417 1417
						JTextField jTF = (JTextField)e.getSource();
1418 1418

  
1419 1419
						// If a coordinate has lost focus, is valid and has changed -> store the new value and set its related 'hasChanged' flag to true
......
1427 1427
//									jTF.setText(last_Coordinates[0]);
1428 1428
//									return;
1429 1429
//								}
1430
								
1430

  
1431 1431
								hasChanged_v1X = true;
1432 1432

  
1433 1433
//								if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
......
1445 1445
//									jTF.setText(last_Coordinates[1]);
1446 1446
//									return;
1447 1447
//								}
1448
								
1448

  
1449 1449
								hasChanged_v1Y = true;
1450 1450

  
1451 1451
//								if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
......
1463 1463
//									jTF.setText(last_Coordinates[2]);
1464 1464
//									return;
1465 1465
//								}
1466
								
1466

  
1467 1467
								hasChanged_v2X = true;
1468 1468

  
1469 1469
//								if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
......
1481 1481
//									jTF.setText(last_Coordinates[3]);
1482 1482
//									return;
1483 1483
//								}
1484
								
1484

  
1485 1485
								hasChanged_v2Y = true;
1486 1486

  
1487 1487
//								if (getJComboBoxToolSelection().getSelectedIndex() != 0) {
......
2201 2201

  
2202 2202
		/**
2203 2203
		 * Changes the color of all coordinates text fields to <code>c</code>.
2204
		 * 
2204
		 *
2205 2205
		 * @param c the new background color
2206 2206
		 */
2207 2207
		private void setBackGroundColorToCoordinatesFields(Color c) {
......
2221 2221

  
2222 2222
			if (! validateCoordinate(getJTextFieldVertex1X())) {
2223 2223
				if (infoSufix == null) {
2224
					infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": "; 
2224
					infoPrefix = PluginServices.getText(this, "invalid_coordinate") + ": ";
2225 2225
					infoSufix = PluginServices.getText(this, "v1x");
2226 2226
				}
2227
				
2227

  
2228 2228
				getJTextFieldVertex1X().setBackground(Color.RED);
2229
				
2229

  
2230 2230
//				else {
2231 2231
//					infoSufix += ", " + PluginServices.getText(this, "v1x");
2232 2232
//				}
......
2270 2270
					infoPrefix = PluginServices.getText(this, "invalid_coordinates") + ": ";
2271 2271
					infoSufix += ", " + PluginServices.getText(this, "v2y");
2272 2272
				}
2273
				
2273

  
2274 2274
				getJTextFieldVertex2Y().setBackground(Color.RED);
2275 2275
//				return new ValidationInfo(false, PluginServices.getText(this, "invalid_coordinate") + ": " + PluginServices.getText(this, "v2y"));
2276 2276
			}
2277
			
2277

  
2278 2278
			if (infoPrefix != null)
2279 2279
				return new ValidationInfo(false, infoPrefix + infoSufix);
2280
			
2280

  
2281 2281
			// If arrives here, all coordinates are valid
2282 2282
			setBackGroundColorToCoordinatesFields(Color.GREEN);
2283 2283
			return new ValidationInfo(true, "");
......
2296 2296
			// Check if no coordinate it's defined
2297 2297
			if (getJTextFieldVertex1X().getText().compareTo("") == 0) {
2298 2298
				if (infoSufix == null) {
2299
					infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": "; 
2299
					infoPrefix = PluginServices.getText(this, "undefined_coordinate") + ": ";
2300 2300
					infoSufix = PluginServices.getText(this, "v1x");
2301 2301
				}
2302
				
2302

  
2303 2303
				getJTextFieldVertex1X().setBackground(Color.RED);
2304
				
2304

  
2305 2305
//				else {
2306 2306
//					infoSufix += ", " + PluginServices.getText(this, "v1x");
2307 2307
//				}
......
2317 2317
					infoPrefix = PluginServices.getText(this, "undefined_coordinates") + ": ";
2318 2318
					infoSufix += ", " + PluginServices.getText(this, "v1y");
2319 2319
				}
2320
				
2320

  
2321 2321
				getJTextFieldVertex1Y().setBackground(Color.RED);
2322 2322
//				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v1y"));
2323 2323
			}
......
2349 2349
				getJTextFieldVertex2Y().setBackground(Color.RED);
2350 2350
//				return new ValidationInfo(false, PluginServices.getText(this, "undefined_coordinate") + ": " + PluginServices.getText(this, "v2y"));
2351 2351
			}
2352
			
2352

  
2353 2353
			if (infoPrefix != null)
2354 2354
				return new ValidationInfo(false, infoPrefix + infoSufix);
2355 2355

  
......
2370 2370
			setBackGroundColorToCoordinatesFields(Color.GREEN);
2371 2371
			return new ValidationInfo(true, "");
2372 2372
		}
2373
		
2373

  
2374 2374
//		/** OLD VERSION
2375 2375
//		 * Validates all coordinates of both vertexes separately
2376 2376
//		 *
......
2444 2444
			ValidationInfo v1 = validVertexesCoordinates();
2445 2445

  
2446 2446
			if (!v1.isValid()) {
2447
				
2447

  
2448 2448
//				setApplicable(false);
2449 2449

  
2450 2450
				// Notify to user that no filter area will be applied
......
2454 2454
				if (previousExtentValids.hasPrevious()) {
2455 2455
					Rectangle2D previousExtent = previousExtentValids.removePrev();
2456 2456
					setCoordinates(previousExtent);
2457
					
2457

  
2458 2458
					if (!previousExtentValids.hasPrevious()) {
2459 2459
						hasUserDefinedAnArea = false;
2460 2460
						setApplicable(false);
2461 2461
					}
2462
					
2462

  
2463 2463
					previousExtentValids.put(previousExtent);
2464 2464
				}
2465 2465

  
......
2477 2477
					if (previousExtentValids.hasPrevious()) {
2478 2478
						Rectangle2D previousExtent = previousExtentValids.removePrev();
2479 2479
						setCoordinates(previousExtent);
2480
						
2480

  
2481 2481
						if (!previousExtentValids.hasPrevious()) {
2482 2482
							hasUserDefinedAnArea = false;
2483 2483
							setApplicable(false);
......
2505 2505
						previousExtentValids.put(getExtent());
2506 2506
						setApplicable(true);
2507 2507
					}
2508
					
2508

  
2509 2509
					return true;
2510 2510
				}
2511 2511
			}
2512 2512
		}
2513
		
2513

  
2514 2514
		/**
2515 2515
		 * <p>Compares two bi-dimensional rectangles, and returns <code>true</code> if both are equals.</p>
2516
		 * 
2516
		 *
2517 2517
		 * @param rect1 first rectangle 2D to compare
2518 2518
		 * @param rect2 second rectangle 2D to compare
2519
		 * 
2519
		 *
2520 2520
		 * @return <code>true</code> if both are equals; otherwise <code>false</code>
2521 2521
		 */
2522 2522
		private boolean areEqual(Rectangle2D rect1, Rectangle2D rect2) {
......
2681 2681
				public void extentChanged(ExtentEvent e) {
2682 2682
					if (!getEnablingJCheckBox().isSelected())
2683 2683
						return;
2684
					
2684

  
2685 2685
					if (getMapContext().getViewPort().getExtents().hasPrevious()) {
2686 2686
						// We will use the adjusted extent because increases the usability
2687 2687
						Rectangle2D r2d = getViewPort().getAdjustedExtent();
......
2888 2888

  
2889 2889
///**
2890 2890
// * VERSI?N PROVISIONAL
2891
// * 
2891
// *
2892 2892
// * This panel allows user to select the area he/she wants to get in the view.
2893 2893
// * There are two options to do this:
2894 2894
// *  - Indicating the coordinates of the top-left and down-right corners
......
3016 3016
//		}
3017 3017
//		return coordinatesPanel;
3018 3018
//	}
3019
//	
3019
//
3020 3020
//	private JCheckBox getEnablingJCheckBox() {
3021 3021
//		if (jEnablingCheckBox == null) {
3022 3022
//			jEnablingCheckBox = new JCheckBox(PluginServices.getText(this, "enabled"));
......
3129 3129
////			getJToggleButtonScaling().setEnabled(true);
3130 3130
////			getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
3131 3131
//		}
3132
//		
3132
//
3133 3133
//		getCoordinatesPanel().getJButtonPreviewArea().setEnabled(true);
3134
//		
3134
//
3135 3135
//		this.repaint();
3136 3136
//	}
3137 3137
//
......
3166 3166
//
3167 3167
//		getCoordinatesPanel().setAllTextFieldsEnabled(false);
3168 3168
//		getCoordinatesPanel().getJButtonPreviewArea().setEnabled(false);
3169
//		
3169
//
3170 3170
//		this.repaint();
3171 3171
//	}
3172 3172
//
......
3491 3491
//	public Rectangle2D getExtent() {
3492 3492
//		if (!getEnablingJCheckBox().isSelected())
3493 3493
//			return null;
3494
//		
3494
//
3495 3495
////		if (!hasUserDefinedAnArea)
3496 3496
////			return null;
3497 3497
//

Also available in: Unified diff