|
39 | 39 | import org.openstreetmap.josm.gui.MainApplication;
|
40 | 40 | import org.openstreetmap.josm.gui.SideButton;
|
41 | 41 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
|
| 42 | +import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
42 | 43 | import org.openstreetmap.josm.gui.widgets.HtmlPanel;
|
43 | 44 | import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
|
44 | 45 | import org.openstreetmap.josm.plugins.maproulette.api.enums.TaskStatus;
|
@@ -417,22 +418,37 @@ public void actionPerformed(ActionEvent e) {
|
417 | 418 | private void handleTask(Task task) {
|
418 | 419 | // TODO put extended dialog here, ask for comment/tags/null -- don't forget to use the bulk operation methods
|
419 | 420 | if (task != null) {
|
420 |
| - ModifiedObjects.addModifiedTask(new ModifiedTask(task, this.status, null, null, null, |
421 |
| - getSelections(this.currentDocumentProvider.get()))); |
422 |
| - } |
423 |
| - if (task != null && task.isCooperativeWorkOsmChange() && this.status == TaskStatus.FIXED) { |
424 |
| - final var command = new ApplyCooperativeChange( |
425 |
| - Objects.requireNonNull(task.cooperativeWorkAsOsmChange())) |
426 |
| - .generateCommand(OsmDataManager.getInstance().getEditDataSet()); |
427 |
| - if (command != null) { |
428 |
| - command.executeCommand(); |
429 |
| - if (!command.getParticipatingPrimitives().isEmpty()) { |
430 |
| - UndoRedoHandler.getInstance().add(command, false); |
| 421 | + final var modifiedTask = new ModifiedTask(task, this.status, null, null, null, |
| 422 | + getSelections(this.currentDocumentProvider.get())); |
| 423 | + ModifiedObjects.addModifiedTask(modifiedTask); |
| 424 | + if (task.isCooperativeWorkOsmChange() && this.status == TaskStatus.FIXED) { |
| 425 | + final var command = new ApplyCooperativeChange( |
| 426 | + Objects.requireNonNull(task.cooperativeWorkAsOsmChange())) |
| 427 | + .generateCommand(OsmDataManager.getInstance().getEditDataSet()); |
| 428 | + if (command != null) { |
| 429 | + command.executeCommand(); |
| 430 | + if (!command.getParticipatingPrimitives().isEmpty()) { |
| 431 | + UndoRedoHandler.getInstance().add(command, false); |
| 432 | + } |
| 433 | + } |
| 434 | + } else if (task.isCooperativeWorkOsc() && this.status == TaskStatus.FIXED) { |
| 435 | + final var message = tr("Apply OSC directly to the edit layer?"); |
| 436 | + final var options = new String[] { tr("Apply"), tr("Show"), tr("Cancel") }; |
| 437 | + final var option = ConditionalOptionPaneUtil.showOptionDialog("maproulette.task.apply_osc", |
| 438 | + MainApplication.getMainFrame(), message, message, JOptionPane.YES_NO_CANCEL_OPTION, |
| 439 | + JOptionPane.YES_OPTION, options, options[0]); |
| 440 | + final var osc = Objects.requireNonNull(task.cooperativeWorkAsOsc()); |
| 441 | + if (option == 0) { |
| 442 | + UndoRedoHandler.getInstance() |
| 443 | + .add(new ApplyOscChange(OsmDataManager.getInstance().getEditDataSet(), osc.a)); |
| 444 | + } else if (option == 1) { |
| 445 | + final var layer = new OsmDataLayer(osc.a, task.name(), null); |
| 446 | + MainApplication.getLayerManager().addLayer(layer); |
| 447 | + } else { |
| 448 | + ModifiedObjects.removeModifiedTask(modifiedTask); |
| 449 | + return; |
431 | 450 | }
|
432 | 451 | }
|
433 |
| - } else if (task != null && task.isCooperativeWorkOsc() && this.status == TaskStatus.FIXED) { |
434 |
| - UndoRedoHandler.getInstance().add(new ApplyOscChange(OsmDataManager.getInstance().getEditDataSet(), |
435 |
| - Objects.requireNonNull(task.cooperativeWorkAsOsc()).a)); |
436 | 452 | }
|
437 | 453 | Optional.ofNullable(MainApplication.getMap().getToggleDialog(CurrentTaskPanel.class))
|
438 | 454 | .ifPresent(p -> p.refreshModel(task));
|
|
0 commit comments