package com.axis.innovators.box.python;

import com.axis.innovators.box.AxisInnovatorsBox;
import com.axis.innovators.box.gui.MainWindow;
import com.axis.innovators.box.register.LanguageManager;

import javax.swing.*;
import java.awt.event.ActionEvent;

/**
 * 在py脚本的程序调用本程序注册各种信息
 * @author tzdwindows 7
 */
public class PyLocalSide {
    public static void addLanguage(String languageName,
                                   String registeredName,
                                   String languageFileName) {
        LanguageManager.Language language = new LanguageManager.Language(
                languageName,
                registeredName,
                languageFileName
        );
        LanguageManager.addLanguage(language);
    }
    public static MainWindow.ToolCategory getToolCategory(String name,
                                                          String icon,
                                                          String description) {

        return new MainWindow.ToolCategory(name, icon, description);
    }

    public static Action getAction(Runnable runnable){
        return new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                runnable.run();
            }
        };
    }
    public static MainWindow.ToolItem getToolItem(String title,
                                                  String icon,
                                                  String description,
                                                  int id,
                                                  Action action){
        System.out.println(action);
        return new MainWindow.ToolItem(title, icon, description, id, action);
    }

    public static void addToolCategory(MainWindow.ToolCategory category, String registeredName){
        AxisInnovatorsBox.getMain().
                getRegistrationTool().addToolCategory(category, registeredName);
    }
}
