001package jmri.jmrit.display;
002
003import javax.annotation.Nonnull;
004
005/**
006 * A factory for Positionables.
007 * The purpose of this interface is to allow Positionables to be loaded
008 * conditionally, for example if a particular connection type is available,
009 * and to have the code for that Positionable in a package related to that
010 * connection type.
011 *
012 * @author Daniel Bergqvist (C) 2026
013 */
014public interface PositionableFactory {
015
016    /**
017     * Get an unique identifier for this factory.
018     * It's recommended that identifiers for connection specific factories
019     * begins with the connection type. Example: DCC-EX-VirtualDisplay.
020     *
021     * @return an unique identifier for this factory
022     */
023    @Nonnull
024    public String getIdentifier();
025
026    /**
027     * Get the description for this factory.
028     *
029     * @return the description
030     */
031    @Nonnull
032    public String getDescription();
033
034    /**
035     * Determines whenever this factory enabled.
036     * This method can for example check if a particular connection type is
037     * available. This is useful for positionables like DCC-VirtualLCD which
038     * are useful only for particular connections.
039     * @return true if enabled, false otherwise
040     */
041    boolean isEnabled();
042
043    /**
044     * Add a positionable to the panel.
045     * The method might show a dialog to let the user configure the positionable.
046     * @param editor   the editor to which the new positionable should be added
047     * @param doAfter  an optional task to run after the positionable is added
048     *                 to the editor, or null if no task is needed
049     */
050    void addPositionable(@Nonnull Editor editor, DoAfter doAfter);
051
052
053    /**
054     * A task to do after the positionable is added to the editor.
055     */
056    interface DoAfter {
057
058        /**
059         * The task to do.
060         * @param p the positionable
061         */
062        void doAfter(Positionable p);
063    }
064
065}