Revision 62 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingBehavior.java

View differences:

DefaultEditingBehavior.java
21 21
import org.cresques.cts.IProjection;
22 22
import org.gvsig.andami.PluginServices;
23 23
import org.gvsig.andami.ui.mdiFrame.MainFrame;
24
import org.gvsig.app.extension.CheckSOAndArquitectureExtension.ShowMessageControler;
24 25
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
25 26
import org.gvsig.fmap.geom.Geometry;
26 27
import org.gvsig.fmap.geom.primitive.Point;
......
51 52
import org.gvsig.vectorediting.lib.api.EditingService;
52 53
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
53 54
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE;
54
import org.gvsig.vectorediting.lib.api.exceptions.InvalidOptionException;
55
import org.gvsig.vectorediting.lib.api.exceptions.InvalidValueException;
55
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException;
56 56
import org.gvsig.vectorediting.lib.api.exceptions.ParsePointException;
57 57
import org.gvsig.vectorediting.lib.api.exceptions.ParseValueException;
58 58
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException;
......
163 163
    addConsoleListener("ViewEditing", new ResponseListener() {
164 164

  
165 165
      public void acceptResponse(String response) {
166
        textEntered(response);
166
        try{
167
          textEntered(response);
168
        } catch( VectorEditingException e){
169
          showConsoleMessage(e.getMessage());
170
        } finally{
171
          getNextParameter();
172
        }
167 173
      }
168 174
    });
169 175

  
......
414 420

  
415 421
  }
416 422

  
417
  private void textEntered(String response) {
423
  private void textEntered(String response) throws InvalidEntryException{
418 424
    if (response == null) {
419 425
      this.activeService.stop();
420 426
      cleanBehavior();
......
423 429
      List<TYPE> types = currentParam.getTypes();
424 430
      Point point = null;
425 431
      Double value = null;
426
      try {
427
        if (types.contains(TYPE.OPTION)) {
428
          response = response.replace("\n", "");
429
          if (response != null) {
430
            this.activeService.value(response);
432

  
433
      boolean insertedValue = false;
434
      if (!insertedValue && types.contains(TYPE.POSITION)
435
          || types.contains(TYPE.LIST_POSITIONS)) {
436
        try {
437
          point = parsePoint(response);
438
          if (point != null) {
439
            this.activeService.value(point);
440
            insertedValue = true;
431 441
          }
432 442
        }
433
        else if (types.contains(TYPE.VALUE)) {
443
        catch (VectorEditingException e) {
444
          // Do nothing
445
        }
446
      }
447
      if (!insertedValue && types.contains(TYPE.VALUE)) {
448
        try {
434 449
          value = parseValue(response);
435 450
          if (value != null) {
436 451
            this.activeService.value(value);
452
            insertedValue = true;
437 453
          }
438 454
        }
439
        else if (types.contains(TYPE.POSITION)
440
            || types.contains(TYPE.LIST_POSITIONS)) {
441
          point = parsePoint(response);
442
          if (point != null) {
443
            this.activeService.value(point);
455
        catch (VectorEditingException e) {
456
          // Do nothing
457
        }
458

  
459
      }
460
      if (!insertedValue && types.contains(TYPE.OPTION)) {
461
        try {
462
          response = response.replace("\n", "");
463
          if (response != null) {
464
            this.activeService.value(response);
465
            insertedValue = true;
444 466
          }
445 467
        }
468
        catch (VectorEditingException e) {
469
          // Do nothing
470
        }
446 471
      }
447
      catch (VectorEditingException e) {
448
        showConsoleMessage(e.getMessage());
472
      // TODO: contemplar el resto de casos
473
      // TYPE.OPTION,
474
      // TYPE.SELECTION,
475
      // TYPE.GEOMETRY
476
      if (!insertedValue) {
477
        throw new InvalidEntryException(null);
449 478
      }
450
      finally {
451
        getNextParameter();
452
      }
453
      // TODO: contemplar el resto de casos TYPE.SELECTION, TYPE.GEOMETRY
454

  
455
      // if (!insertedValue) {
456
      // // TODO Show console message
457
      // }
458

  
459 479
    }
460 480
  }
461 481

  
482
   
483

  
462 484
  private Double parseValue(String response) throws ParseValueException {
463
    try{
485
    try {
464 486
      return Double.valueOf(response);
465
    } catch( Exception e){
487
    }
488
    catch (Exception e) {
466 489
      throw new ParseValueException(e);
467 490
    }
468
    
491

  
469 492
  }
470 493

  
471 494
  private Point parsePoint(String response) throws ParsePointException {

Also available in: Unified diff