Exemplo n.º 1
0
    protected void uploadLayers(List<SaveLayerInfo> toUpload) {
      for (final SaveLayerInfo layerInfo : toUpload) {
        AbstractModifiableLayer layer = layerInfo.getLayer();
        if (canceled) {
          model.setUploadState(layer, UploadOrSaveState.CANCELED);
          continue;
        }
        monitor.subTask(tr("Preparing layer ''{0}'' for upload ...", layerInfo.getName()));

        if (!UploadAction.checkPreUploadConditions(layer)) {
          model.setUploadState(layer, UploadOrSaveState.FAILED);
          continue;
        }

        AbstractUploadDialog dialog = layer.getUploadDialog();
        if (dialog != null) {
          dialog.setVisible(true);
          if (dialog.isCanceled()) {
            model.setUploadState(layer, UploadOrSaveState.CANCELED);
            continue;
          }
          dialog.rememberUserInput();
        }

        currentTask = layer.createUploadTask(monitor);
        if (currentTask == null) {
          model.setUploadState(layer, UploadOrSaveState.FAILED);
          continue;
        }
        currentFuture = worker.submit(currentTask);
        try {
          // wait for the asynchronous task to complete
          //
          currentFuture.get();
        } catch (CancellationException e) {
          Main.trace(e);
          model.setUploadState(layer, UploadOrSaveState.CANCELED);
        } catch (InterruptedException | ExecutionException e) {
          Main.error(e);
          model.setUploadState(layer, UploadOrSaveState.FAILED);
          ExceptionDialogUtil.explainException(e);
        }
        if (currentTask.isCanceled()) {
          model.setUploadState(layer, UploadOrSaveState.CANCELED);
        } else if (currentTask.isFailed()) {
          Main.error(currentTask.getLastException());
          ExceptionDialogUtil.explainException(currentTask.getLastException());
          model.setUploadState(layer, UploadOrSaveState.FAILED);
        } else {
          model.setUploadState(layer, UploadOrSaveState.OK);
        }
        currentTask = null;
        currentFuture = null;
      }
    }
Exemplo n.º 2
0
  @Override
  protected void finish() {
    if (canceled) return;
    if (lastException != null) {
      ExceptionDialogUtil.explainException(lastException);
    }
    Runnable r =
        new Runnable() {
          public void run() {
            ChangesetCache.getInstance().update(downloadedChangesets);
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      r.run();
    } else {
      try {
        SwingUtilities.invokeAndWait(r);
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof RuntimeException) {
          BugReportExceptionHandler.handleException(t);
        } else if (t instanceof Exception) {
          ExceptionUtil.explainException(e);
        } else {
          BugReportExceptionHandler.handleException(t);
        }
      }
    }
  }
Exemplo n.º 3
0
 @Override
 protected void finish() {
   if (canceled) return;
   if (lastException != null) {
     ExceptionDialogUtil.explainException(lastException);
     return;
   }
   columnmodel.setHeadlines(useserver.thirdcol, useserver.fourthcol);
   model.setData(this.data);
 }
Exemplo n.º 4
0
    protected void saveLayers(List<SaveLayerInfo> toSave) {
      for (final SaveLayerInfo layerInfo : toSave) {
        if (canceled) {
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.CANCELED);
          continue;
        }
        // Check save preconditions earlier to avoid a blocking reentring call to EDT (see #10086)
        if (layerInfo.isDoCheckSaveConditions()) {
          if (!layerInfo.getLayer().checkSaveConditions()) {
            continue;
          }
          layerInfo.setDoCheckSaveConditions(false);
        }
        currentTask = new SaveLayerTask(layerInfo, monitor);
        currentFuture = worker.submit(currentTask);

        try {
          // wait for the asynchronous task to complete
          //
          currentFuture.get();
        } catch (CancellationException e) {
          Main.trace(e);
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.CANCELED);
        } catch (InterruptedException | ExecutionException e) {
          Main.error(e);
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.FAILED);
          ExceptionDialogUtil.explainException(e);
        }
        if (currentTask.isCanceled()) {
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.CANCELED);
        } else if (currentTask.isFailed()) {
          if (currentTask.getLastException() != null) {
            Main.error(currentTask.getLastException());
            ExceptionDialogUtil.explainException(currentTask.getLastException());
          }
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.FAILED);
        } else {
          model.setSaveState(layerInfo.getLayer(), UploadOrSaveState.OK);
        }
        this.currentTask = null;
        this.currentFuture = null;
      }
    }
Exemplo n.º 5
0
 @Override
 protected void finish() {
   if (canceled) return;
   if (lastException != null) {
     ExceptionDialogUtil.explainException(lastException);
     return;
   }
   GuiHelper.runInEDTAndWait(
       () -> {
         layer.mergeFrom(ds);
         if (zoom && Main.map != null) AutoScaleAction.zoomTo(ds.allPrimitives());
         layer.onPostDownloadFromServer();
       });
 }