package cz.cvut.fit.bioop.ui.actions;

import cz.cvut.fit.bioop.ui.AppView;
import javax.swing.*;
import java.awt.event.ActionEvent;

public class DrawClearAction extends AbstractAction {
    private AppView.OnActionPerformObserver mOnActionObserver;

    DrawClearAction(String actionName, AppView.OnActionPerformObserver mOnActionObserver) {
        super(actionName);
        this.mOnActionObserver =  mOnActionObserver;
    }

    @Override
    public void actionPerformed(ActionEvent e){
        String variations[] = {"Yes","No"};
        int promptResult = JOptionPane.showOptionDialog(
                null,
                "Are you sure you want to clear the canvas?",
                "Clearing",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE,
                null,
                variations,
                variations[1]
        );
        if(promptResult == JOptionPane.YES_OPTION && mOnActionObserver != null) {
            mOnActionObserver.onClearAction();
        }
    }

}


