package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import _VisualDVM.ComponentsServer.Component.ComponentType;
import _VisualDVM.Global;

import java.awt.*;
import java.io.File;
public class ShowInstruction extends Pass<File> {
    @Override
    public String getIconPath() {
        return "/icons/Help.png";
    }
    @Override
    public String getButtonText() {
        return "";
    }
    @Override
    protected boolean canStart(Object... args) throws Exception {
        target = Global.components.get(ComponentType.Instruction).getFile();
        if (!target.exists()) {
            Log.Writeln("файл инструкции:\n" + target.getAbsolutePath() + "\nне найден! Обновите компонент 'Инструкция'");
            return false;
        }
        return true;
    }
    @Override
    protected void body() throws Exception {
        if (Desktop.isDesktopSupported()) {
            Desktop.getDesktop().open(target);
        }
    }
}
