Revision 76

View differences:

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
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;
25 24
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
26 25
import org.gvsig.fmap.geom.Geometry;
27 26
import org.gvsig.fmap.geom.primitive.Point;
......
54 53
import org.gvsig.vectorediting.lib.api.EditingService;
55 54
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
56 55
import org.gvsig.vectorediting.lib.api.EditingServiceParameter.TYPE;
57
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException;
58 56
import org.gvsig.vectorediting.lib.api.exceptions.InvalidEntryException;
59 57
import org.gvsig.vectorediting.lib.api.exceptions.ParsePointException;
60 58
import org.gvsig.vectorediting.lib.api.exceptions.ParseValueException;
59
import org.gvsig.vectorediting.lib.api.exceptions.StartServiceException;
60
import org.gvsig.vectorediting.lib.api.exceptions.StopServiceException;
61 61
import org.gvsig.vectorediting.lib.api.exceptions.VectorEditingException;
62 62
import org.gvsig.vectorediting.swing.api.EditingBehavior;
63 63
import org.slf4j.Logger;
......
140 140
    activeService = null;
141 141
    currentParam = null;
142 142

  
143
    showConsoleMessage("\n" + i18nManager.getTranslation("select_new_tool")+ "\n");
144
    // MainFrame main = PluginServices.getMainFrame();
145
    // main.setSelectedTool(""); We can define a default tool. I.E Zoom in.
143
    showConsoleMessage("\n" + i18nManager.getTranslation("select_new_tool")
144
        + "\n");
146 145
  }
147 146

  
148 147
  public DefaultEditingBehavior(MapControl mapControl) {
......
171 170
        try {
172 171
          textEntered(response);
173 172
        }
174
        catch (VectorEditingException e) {
173
        catch (InvalidEntryException e) {
175 174
          showConsoleMessage(i18nManager.getTranslation("invalid_option"));
176 175
        }
176
        catch (StopServiceException e) {
177
          logger.error("Can't stop "+ activeService.getName(), e);
178
        }
177 179
        finally {
178 180
          if (activeService != null) {
179 181
            getNextParameter();
......
184 186

  
185 187
  }
186 188

  
187
  public void activateTool(String name) {
189
  public void activateService(String name) {
188 190

  
189 191
    EditingManager manager = EditingLocator.getManager();
190 192

  
......
210 212
    }
211 213
  }
212 214

  
215
  /**
216
   * Shows description of parameter on console.
217
   */
213 218
  private void askQuestion(EditingServiceParameter param) {
214 219
    if (getConsolePanel() != null) {
215 220
      showConsoleMessage("\n#" + param.getDescription() + " > ");
......
240 245
    };
241 246
  }
242 247

  
248
  /**
249
   * Gets next parameter of {@link #activateService(String)} and sets
250
   * {@link #currentParam}. If currentParam is null means all service parameters
251
   * have value and service doesn't need more values.
252
   */
243 253
  private void getNextParameter() {
244 254
    currentParam = activeService.next();
245 255
    if (currentParam == null) {
......
385 395
      logger.error("An error ocurred when draw service geometries", e);
386 396
    }
387 397
    if (helperGeo != null) {
388
      for (Iterator iterator = helperGeo.getGeometries().iterator(); iterator
398
      for (@SuppressWarnings("rawtypes")
399
      Iterator iterator = helperGeo.getGeometries().iterator(); iterator
389 400
          .hasNext();) {
390 401
        Geometry geometry = (Geometry) iterator.next();
391 402
        mapControl.getMapControlDrawer().draw(geometry,
......
402 413

  
403 414
  }
404 415

  
416
  /**
417
   * Sets the layer received as parameter as {@link #currentLayer}
418
   * 
419
   * @param layer
420
   */
405 421
  private void changeCurrentLayer(FLyrVect layer) {
406 422
    this.currentLayer = layer;
407 423
    this.activeService = serviceRegistration.get(layer);
......
412 428
    }
413 429
  }
414 430

  
431
  /**
432
   * Show coordinates at status bar
433
   * 
434
   * @param point
435
   */
415 436
  private void showCoords(Point2D point) {
416 437
    String[] axisText = new String[2];
417 438
    axisText[0] = "X = ";
......
442 463

  
443 464
  }
444 465

  
445
  private void textEntered(String response) throws InvalidEntryException {
466
  /**
467
   * Processes console entries from console. Tries to process entry in each type
468
   * of {@link #currentParam}. If there is some error, It will continue
469
   * checking. If entry has been processed, It will set value in {@link #activeService}.
470
   * 
471
   * @param response Console entry.
472
   * @throws InvalidEntryException If console entries has not been able to
473
   *           process, it will throw an exception to indicate that entry is not
474
   *           valid.
475
   * @throws StopServiceException If there are some errors stopping service.
476
   */
477
  private void textEntered(String response) throws InvalidEntryException, StopServiceException {
446 478
    if (response == null) {
447
      if(activeService != null){
479
      if (activeService != null) {
448 480
        this.activeService.stop();
449 481
        cleanBehavior();
450 482
      }
......
503 535
    }
504 536
  }
505 537

  
538
  /**
539
   * Parse String to value.
540
   * 
541
   * @param response String to be parsed.
542
   * @return Values of string.
543
   * @throws ParseValueException If there is error trying to parse <code>String</code>.
544
   */
506 545
  private Double parseValue(String response) throws ParseValueException {
507 546
    try {
508 547
      return Double.valueOf(response);
......
513 552

  
514 553
  }
515 554

  
555
  /**
556
   * Parse String to point. Formats accepted: (x,y) and x,y.
557
   * 
558
   * @param response String to be parsed.
559
   * @return Point of string.
560
   * @throws ParsePointException If there is error trying to parse <code>String</code>.
561
   */
516 562
  private Point parsePoint(String response) throws ParsePointException {
517 563
    String[] numbers = new String[1];
518 564
    numbers[0] = response;

Also available in: Unified diff