package seedu.task.logic.commands;

import java.util.Optional;

import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import seedu.task.model.TaskManager;

/**
 * Clears the task manager.
 */
public class ClearCommand extends Command {

    public static final String COMMAND_WORD = "clear";
    public static final String MESSAGE_SUCCESS = "Task Manager has been cleared!";
    public static final String MESSAGE_FAILURE = "Task Manager has not been cleared";

    public ClearCommand() {}


    @Override
    public CommandResult execute() {
        assert model != null;
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle("Clear all tasks");
        alert.setHeaderText("Are you sure you want to clear ALL TASKS in the task manager?");
        alert.setContentText("NOTE: This cannot be undone! ");

        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == ButtonType.OK){
            model.resetData(TaskManager.getEmptyTaskManager());
            return new CommandResult(MESSAGE_SUCCESS);
        } else {
            return new CommandResult(MESSAGE_FAILURE);
        }

    }
}

@@ -181,44 +181,8 @@
 pe;%0A
-import javafx.scene.control.Dialog;%0A
 impo
@@ -519,16 +519,85 @@
 leared%22;
+%0A    public static final String MESSAGE_NO_TASKS = %220 tasks listed!%22;
 %0A%0A    pu
@@ -617,18 +617,22 @@
 mand() %7B
-%7D
 %0A
+    %7D
 %0A%0A    @O
@@ -706,16 +706,49 @@
 = null;%0A
+        if (model != null) %7B%0A    
         
@@ -795,32 +795,36 @@
 ATION);%0A        
+  
+  
 alert.setTitle(%22
@@ -838,24 +838,28 @@
 ll tasks%22);%0A
+    
         aler
@@ -948,68 +948,8 @@
     
-    alert.setContentText(%22NOTE: This cannot be undone! %22);%0A%0A
     
@@ -1007,24 +1007,28 @@
 ();%0A        
+    
 if (result.g
@@ -1049,18 +1049,23 @@
 Type.OK)
+ 
 %7B%0A
+    
         
@@ -1124,32 +1124,36 @@
 ));%0A            
+    
 return new Comma
@@ -1179,16 +1179,20 @@
 CCESS);%0A
+    
         
@@ -1204,32 +1204,36 @@
 e %7B%0A            
+    
 return new Comma
@@ -1259,16 +1259,20 @@
 ILURE);%0A
+    
         
@@ -1268,22 +1268,89 @@
            %7D
+%0A        %7D%0A        else return new CommandResult(MESSAGE_NO_TASKS);
 %0A%0A    %7D%0A%7D%0A

Allow undo command to work after the clear command