package de.renew.navigator.gui.actions;

import java.awt.event.ActionEvent;

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


/**
 * Refreshes all files contained in the navigator.
 *
 * @author Konstantin Simon Maria Moellers
 * @version 2015-08-26
 */
public class RefreshAllAction extends NavigatorAction {
    /**
     * The {@link FilesystemController} instance that this action interacts with.
     */
    private final FilesystemController _fileSystem;
    /**
     * Property name in plugin.cfg of the refresh all hotkey.
     */
    public static final String REFRESH_ALL_HOTKEY_PROP_NAME =
        "de.renew.hotkeymap.navigator.refreshall";

    /**
     * Constructor for the RefreshAllAction.
     * @param filesystem the {@link FilesystemController} instance that this action interacts with.
     */
    public RefreshAllAction(FilesystemController filesystem, PluginProperties plugincfg) {
        super(
            "Refresh All", NavigatorIcons.ICON_REFRESH_ALL,
            PluginProperties.getUserProperties().getHotkeyProperty(
                REFRESH_ALL_HOTKEY_PROP_NAME,
                plugincfg.getHotkeyProperty(REFRESH_ALL_HOTKEY_PROP_NAME)));
        this._fileSystem = filesystem;
    }

    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        _fileSystem.refreshPaths();
    }
}