package _VisualDVM.Visual.Menus;
import Common.Visual.Controls.StableMenuItem;
import Common.Visual.Menus.VisualiserMenu;
import _VisualDVM.ProjectData.Files.FileType;

import javax.swing.*;
import java.awt.event.ActionEvent;
public abstract class TypesSubmenu extends VisualiserMenu {
    public TypesSubmenu() {
        this("Тип");
    }
    public TypesSubmenu(String text) {
        super(text, "/icons/type.png", true);
        for (FileType fileType : FileType.values()) {
            if (fileType != FileType.forbidden) {
                JMenuItem m = new StableMenuItem(fileType.getDescription());
                m.addActionListener(new AbstractAction() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        action(fileType);
                    }
                });
                add(m);
            }
        }
    }
    public abstract void action(FileType fileType);
}
