package de.renew.navigator.gui.actions;

import java.awt.event.ActionEvent;

import de.renew.navigator.NavigatorAction;
import de.renew.navigator.NavigatorGui;
import de.renew.navigator.gui.NavigatorIcons;
import de.renew.plugin.PluginProperties;


/**
 * @author Konstantin Simon Maria Moellers
 * @version 2015-08-26
 */
public class CollapseAllAction extends NavigatorAction {
    /**
     * The {@link NavigatorGui} instance that this action interacts with.
     */
    private final NavigatorGui _gui;
    /**
     * Property name in plugin.cfg of the collapse all Hotkey.
     */
    public static final String COLLAPSE_ALL_HOTKEY_PROP_NAME =
        "de.renew.hotkeymap.navigator.collapseall";

    /**
     * Constructor for creating an instance of CollapseAllAction.
     *
     * @param gui the {@link NavigatorGui} instance that this action interacts with.
     */
    @SuppressWarnings("deprecation")
    public CollapseAllAction(final NavigatorGui gui, PluginProperties plugincfg) {
        super(
            "Collapse All", NavigatorIcons.ICON_COLLAPSE_ALL,
            PluginProperties.getUserProperties().getHotkeyProperty(
                COLLAPSE_ALL_HOTKEY_PROP_NAME,
                plugincfg.getHotkeyProperty(COLLAPSE_ALL_HOTKEY_PROP_NAME)));
        this._gui = gui;
    }

    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        _gui.collapseAll();
    }
}