package de.renew.navigator.gui.actions;

import java.awt.event.ActionEvent;

import de.renew.navigator.NavigatorAction;
import de.renew.navigator.gui.NavigatorIcons;
import de.renew.navigator.models.NavigatorFileTree;
import de.renew.plugin.PluginProperties;


/**
 * @author Konstantin Simon Maria Moellers
 * @version 2015-08-26
 */
public class RemoveAllAction extends NavigatorAction {
    /**
     * The {@link NavigatorFileTree} instance that this action interacts with.
     */
    private final NavigatorFileTree _model;
    /**
     * Property name in plugin.cfg of the remove all hotkey.
     */
    public static final String REMOVE_ALL_HOTKEY_PROP_NAME =
        "de.renew.hotkeymap.navigator.removeall";

    /**
     * Constructor for the RemoveAllAction.
     * @param model the {@link NavigatorFileTree} instance that this action interacts with.
     */
    public RemoveAllAction(final NavigatorFileTree model, PluginProperties plugincfg) {
        super(
            "Remove All", NavigatorIcons.ICON_REMOVE_ALL,
            PluginProperties.getUserProperties().getHotkeyProperty(
                REMOVE_ALL_HOTKEY_PROP_NAME,
                plugincfg.getHotkeyProperty(REMOVE_ALL_HOTKEY_PROP_NAME)));
        this._model = model;
    }

    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        _model.clearTreeRoots();
        _model.notifyObservers();
    }
}