001package jmri.jmrit.logixng;
002
003/**
004 * The category of expressions and actions.
005 * <P>
006 * It's used to group expressions or actions then the user creates a new
007 * expression or action.
008 * <P>
009 * This class is intended to be an Enum, but implemented as an abstract class
010 * to allow adding more categories later without needing to change this class.
011 * For example, external programs using JMRI as a lib might want to add their
012 * own categories.
013 *
014 * @author Daniel Bergqvist Copyright 2018
015 */
016public abstract class LogixNG_Category extends jmri.Category {
017
018    /**
019     * A item on the layout, for example turnout, sensor and signal mast.
020     */
021    public static final Item ITEM = new Item();
022
023    /**
024     * Common.
025     */
026    public static final Common COMMON = new Common();
027
028    /**
029     * Flow Control.
030     */
031    public static final FlowControl FLOW_CONTROL = new FlowControl();
032
033    /**
034     * Other things.
035     */
036    public static final Other OTHER = new Other();
037
038    /**
039     * Linux specific things.
040     */
041    public static final Linux LINUX = new Linux();
042
043    static {
044        // It's not often any item is added to this list so we use CopyOnWriteArrayList
045        registerCategory(ITEM);
046        registerCategory(COMMON);
047        registerCategory(FLOW_CONTROL);
048        if (jmri.util.SystemType.isLinux()) {
049            registerCategory(LINUX);
050        }
051    }
052
053
054    protected LogixNG_Category(String name, String description, int order) {
055        super(name, description, order);
056    }
057
058
059    public static final class Item extends LogixNG_Category {
060
061        public Item() {
062            super("ITEM", Bundle.getMessage("CategoryItem"), 100);
063        }
064    }
065
066
067    public static final class Common extends LogixNG_Category {
068
069        public Common() {
070            super("COMMON", Bundle.getMessage("CategoryCommon"), 200);
071        }
072    }
073
074
075    public static final class FlowControl extends LogixNG_Category {
076
077        public FlowControl() {
078            super("FLOW_CONTROL", Bundle.getMessage("CategoryFlowControl"), 210);
079        }
080    }
081
082
083    public static final class Linux extends LogixNG_Category {
084
085        public Linux() {
086            super("LINUX", Bundle.getMessage("CategoryLinux"), 2000);
087        }
088    }
089
090
091    public static final class Other extends LogixNG_Category {
092
093        public Other() {
094            super("OTHER", Bundle.getMessage("CategoryOther"), Integer.MAX_VALUE);
095        }
096    }
097
098}