示例#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;
      }
    }
 public ReverterPlugin(PluginInformation info) {
   super(info);
   JMenu historyMenu =
       Main.main.menu.addMenu(
           marktr("History"),
           KeyEvent.VK_S,
           Main.main.menu.defaultMenuPos,
           ht("/Plugin/Reverter"));
   // MainMenu.add(historyMenu, new ObjectsHistoryAction());
   MainMenu.add(historyMenu, new RevertChangesetAction());
   UploadAction.registerUploadHook(new ReverterUploadHook(this));
 }
示例#3
0
  /**
   * Creates the plugin and setup the default settings if necessary
   *
   * @throws Exception
   */
  public CadastrePlugin(PluginInformation info) throws Exception {
    super(info);
    System.out.println("Pluging cadastre-fr v" + VERSION + " started...");
    if (Main.pref.get("cadastrewms.cacheDir").equals(""))
      cacheDir =
          Main.pref.getPreferencesDir()
              + "plugins"
              + File.separatorChar
              + "cadastrewms"
              + File.separatorChar;
    else {
      cacheDir = Main.pref.get("cadastrewms.cacheDir");
      if (cacheDir.charAt(cacheDir.length() - 1) != File.separatorChar)
        cacheDir += File.separatorChar;
    }
    System.out.println("current cache directory: " + cacheDir);

    refreshConfiguration();

    UploadAction.registerUploadHook(new CheckSourceUploadHook());
  }