Update SketchOnMapSample.java
changes to redo and undo
@@ -35,7 +35,6 @@ import com.esri.arcgisruntime.mapping.view.SketchGeometryChangedListener;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
-import com.sun.xml.internal.bind.v2.TODO;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
@@ -139,6 +138,7 @@ public class SketchOnMapSample extends Application {
selectGraphic();
graphicsOverlay.clearSelection();
clearButton.setDisable(false);
+ undoButton.setDisable(false);
redoButton.setDisable(true);
editButton.setDisable(true);
cancelButton.setDisable(true);
@@ -155,23 +155,19 @@ public class SketchOnMapSample extends Application {
undoButton.setOnAction(event -> {
if (sketchEditor.canUndo()) {
sketchEditor.undo();
- //undoButton.setDisable(false);
}
- ;
});
// redo the last change made whilst sketching graphic
redoButton.setOnAction(event -> {
if (sketchEditor.canRedo()) {
sketchEditor.redo();
- //redoButton.setDisable(false);
}
});
editButton.setOnAction(event -> {
// this edits the feature
- undoButton.setDisable(false);
- redoButton.setDisable(false);
+
cancelButton.setDisable(false);
if (graphicsOverlay.getSelectedGraphics().size() > 0) {
@@ -181,8 +177,6 @@ public class SketchOnMapSample extends Application {
// remove the underlying graphic to live update. This clears the graphic.
graphicsOverlay.getGraphics().remove(graphic);
}
-
-
});
cancelButton.setOnAction(event -> {
@@ -198,7 +192,6 @@ public class SketchOnMapSample extends Application {
sketchEditor.stop();
cancelButton.setDisable(true);
-
}
// }
});
@@ -238,9 +231,17 @@ public class SketchOnMapSample extends Application {
}
+ } catch (Exception e) {
+ new Alert(Alert.AlertType.ERROR, "Error finding draw style").show();
+ }
+
+ });
+
// add a listener for when geometry is changed, to enable cancelling the button
sketchEditor.addGeometryChangedListener(SketchGeometryChangedListener -> {
+ System.out.println("Listened to geometry changed" + sketchEditor.canUndo());
+
// if the geometry being listened to is not empty, then enable the cancel button
if (!SketchGeometryChangedListener.getGeometry().isEmpty()) {
cancelButton.setDisable(false);
@@ -249,6 +250,7 @@ public class SketchOnMapSample extends Application {
// if the sketch editor can undo, enable the undo button otherwise disable it
if (sketchEditor.canUndo()) {
undoButton.setDisable(false);
+ System.out.println("Listening for undo button");
} else {undoButton.setDisable(true);}
// if the sketch editor can redo, enable the redo button otherwise disable it
@@ -258,11 +260,6 @@ public class SketchOnMapSample extends Application {
});
- } catch (Exception e) {
- new Alert(Alert.AlertType.ERROR, "Error finding draw style").show();
- }
-
- });
// create a control panel
VBox controlsVBox = new VBox(6);
