package com.sencorsta.rabs.obj;

import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLightLaf;

import javax.swing.LookAndFeel;
import javax.swing.plaf.metal.MetalLookAndFeel;

/**
 * @author daibin
 */
public enum ThemeOption {
    /**
     * Light theme option.
     */
    LIGHT("Light Theme"),

    /**
     * Dark theme option.
     */
    DARK("Dark Theme"),

    /**
     * IntelliJ theme option.
     */
    INTELLIJ("IntelliJ Theme"),

    /**
     * Darcula theme option.
     */
    DARCULA("Darcula Theme"),

//    /**
//     * Windows theme option.
//     */
//    WINDOWS("Windows Theme"),
//
//    /**
//     * Windows Classic theme option.
//     */
//    WINDOWS_CLASSIC("Classic Theme"),

    /**
     * Metal theme option.
     */
    METAL("Metal Theme");

    /**
     * 枚举常量对应的文本内容
     */
    private String text;

    /**
     * 构造函数，用于初始化枚举常量的文本内容
     *
     * @param text 枚举常量对应的文本内容
     */
    private ThemeOption(String text) {
        this.text = text;
    }

    /**
     * 公共方法，用于获取枚举常量对应的文本内容
     *
     * @return 枚举常量对应的文本内容
     */
    public String getText() {
        return text;
    }

    /**
     * 添加一个静态方法用于根据文本查找对应的枚举对象
     */
    public static ThemeOption fromString(String text) {
        for (ThemeOption option : ThemeOption.values()) {
            if (option.text.equalsIgnoreCase(text)) {
                return option;
            }
        }
        throw new IllegalArgumentException("No enum constant " + ThemeOption.class.getName() + " with text " + text);
    }

    public static LookAndFeel getLookAndFeel(ThemeOption option) {
        LookAndFeel laf = null;
        switch (option) {
            case LIGHT:
                laf = new FlatLightLaf();
                break;
            case DARK:
                laf = new FlatDarkLaf();
                break;
            case INTELLIJ:
                laf = new FlatIntelliJLaf();
                break;
            case DARCULA:
                laf = new FlatDarculaLaf();
                break;
//            case WINDOWS:
//                laf = new WindowsLookAndFeel();
//                break;
//            case WINDOWS_CLASSIC:
//                laf = new WindowsClassicLookAndFeel();
//                break;
            case METAL:
                laf = new MetalLookAndFeel();
                break;
        }
        return laf;
    }
}
