Class BeanSelectCreatePanel<E extends NamedBean>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class BeanSelectCreatePanel<E extends NamedBean> extends JPanel
See Also:
  • Field Details

  • Constructor Details

    • BeanSelectCreatePanel

      public BeanSelectCreatePanel(@Nonnull Manager<E> manager, E defaultSelect)
      Create a JPanel that provides the option to the user to either select an already created bean, or to create one on the fly. This only currently works with Turnouts, Sensors, Memories and Blocks.
      Parameters:
      manager - the bean manager
      defaultSelect - the bean that is selected by default
  • Method Details

    • update

      void update()
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • getDisplayName

      Get the display name of the bean that has either been selected in the drop down list or was asked to be created.
      Returns:
      the name of the bean
    • hasBeanOrBeanName

      public boolean hasBeanOrBeanName()
      Is a bean either selected or has the user entered a new name in the combo box? If either is false, the caller should not try to create a new bean.
      Returns:
      true if a bean is selected or a name is entered
    • getNamedBean

      public E getNamedBean() throws JmriException
      Get the named bean that has either been selected in the drop down list or was asked to be created.
      Returns:
      the selected bean or a new bean
      Throws:
      JmriException - if a bean needs to be created but can't be
    • setReference

      public void setReference(String ref)
      Set a reference that can be set against the comment for a bean.
      Parameters:
      ref - the default comment for a bean without a comment
    • setDefaultNamedBean

      public void setDefaultNamedBean(E nBean)
      Set the default selected item in the combo box. After it has been set, the combo box becomes active and the Add Hardware box details are then hidden.
      Parameters:
      nBean - the bean that is selected by default
    • isEmpty

      public boolean isEmpty()
      Check that the user selected something in this BeanSelectCreatePanel.
      Returns:
      true if not empty
    • updateComment

      public void updateComment(@Nonnull E nBean, String content)
      Update comment on bean if there's content AND there's not already a comment.
      Parameters:
      nBean - the bean to edit
      content - comment to add
    • dispose

      public void dispose()