Exemplo n.º 1
0
 public void actionPerformed(ActionEvent e) {
   if (!isEnabled()) return;
   if (getEditLayer().isUploadDiscouraged()) {
     if (UploadAction.warnUploadDiscouraged(getEditLayer())) {
       return;
     }
   }
   UploadHullBuilder builder = new UploadHullBuilder();
   UploadSelectionDialog dialog = new UploadSelectionDialog();
   Collection<OsmPrimitive> modifiedCandidates =
       getModifiedPrimitives(getEditLayer().data.getAllSelected());
   Collection<OsmPrimitive> deletedCandidates = getDeletedPrimitives(getEditLayer().data);
   if (modifiedCandidates.isEmpty() && deletedCandidates.isEmpty()) {
     JOptionPane.showMessageDialog(
         Main.parent, tr("No changes to upload."), tr("Warning"), JOptionPane.INFORMATION_MESSAGE);
     return;
   }
   dialog.populate(modifiedCandidates, deletedCandidates);
   dialog.setVisible(true);
   if (dialog.isCanceled()) return;
   Collection<OsmPrimitive> toUpload = builder.build(dialog.getSelectedPrimitives());
   if (toUpload.isEmpty()) {
     JOptionPane.showMessageDialog(
         Main.parent, tr("No changes to upload."), tr("Warning"), JOptionPane.INFORMATION_MESSAGE);
     return;
   }
   uploadPrimitives(getEditLayer(), toUpload);
 }
Exemplo n.º 2
0
 /**
  * Uploads the primitives in <code>toUpload</code> to the server. Only uploads primitives which
  * are either new, modified or deleted.
  *
  * <p>Also checks whether <code>toUpload</code> has to be extended with deleted parents in order
  * to avoid precondition violations on the server.
  *
  * @param layer the data layer from which we upload a subset of primitives
  * @param toUpload the primitives to upload. If null or empty returns immediatelly
  */
 public void uploadPrimitives(OsmDataLayer layer, Collection<OsmPrimitive> toUpload) {
   if (toUpload == null || toUpload.isEmpty()) return;
   UploadHullBuilder builder = new UploadHullBuilder();
   toUpload = builder.build(toUpload);
   if (hasPrimitivesToDelete(toUpload)) {
     // runs the check for deleted parents and then invokes
     // processPostParentChecker()
     //
     Main.worker.submit(new DeletedParentsChecker(layer, toUpload));
   } else {
     processPostParentChecker(layer, toUpload);
   }
 }