Class CommonSubs

  • public class CommonSubs
    extends java.lang.Object
    • Method Detail

      • setMillisecondsEdit

        public static void setMillisecondsEdit​(javax.swing.JFormattedTextField formattedTextField)
      • allowClose

        public static boolean allowClose​(java.awt.Component parentComponent,
                                         boolean dataChanged)
      • addHelpMenu

        public static void addHelpMenu​(javax.swing.JFrame frame,
                                       java.lang.String ref,
                                       boolean direct)
        Add a standard help menu, including the window specific help item.
        frame - The frame receiving the help menu.
        ref - JHelp reference for the desired window-specific help page
        direct - true if the help main-menu item goes directly to the help system, such as when there are no items in the help menu
      • getStringArrayFromDefaultTableModel

        public static java.util.ArrayList<java.lang.String> getStringArrayFromDefaultTableModel​(javax.swing.table.DefaultTableModel defaultTableModel)
      • compactDefaultTableModel

        public static int compactDefaultTableModel​(javax.swing.table.DefaultTableModel defaultTableModel)
      • populateJComboBoxWithBeans

        public static void populateJComboBoxWithBeans​(javax.swing.JComboBox<java.lang.String> jComboBox,
                                                      java.lang.String beanType,
                                                      java.lang.String currentSelection,
                                                      boolean firstRowBlank)
        Populate a combo box with bean names using getDisplayName().

        If a panel xml file has not been loaded, the combo box will behave as a text field (editable), otherwise it will behave as standard combo box (not editable).

        jComboBox - The string based combo box to be populated.
        beanType - The bean type to be loaded. It has to be in the switch list.
        currentSelection - The current item to be selected, none if null.
        firstRowBlank - True to create a blank row. If the selection is null or empty, the blank row will be selected.
      • numberButtonGroup

        public static void numberButtonGroup​(javax.swing.ButtonGroup buttonGroup)
      • setButtonSelected

        public static void setButtonSelected​(javax.swing.ButtonGroup buttonGroup,
                                             int selected)
      • missingFieldsErrorDialogDisplayed

        public static boolean missingFieldsErrorDialogDisplayed​(java.awt.Component parentComponent,
                                                                java.util.ArrayList<java.lang.String> errors,
                                                                boolean isCancel)
      • checkJTextFieldNotEmpty

        public static void checkJTextFieldNotEmpty​(javax.swing.JTextField field,
                                                   javax.swing.JLabel promptName,
                                                   java.util.ArrayList<java.lang.String> errors)
      • isJTextFieldNotEmpty

        public static boolean isJTextFieldNotEmpty​(javax.swing.JTextField field)
      • checkJComboBoxNotEmpty

        public static void checkJComboBoxNotEmpty​(javax.swing.JComboBox<java.lang.String> combo,
                                                  javax.swing.JLabel promptName,
                                                  java.util.ArrayList<java.lang.String> errors)
      • isJComboBoxNotEmpty

        public static boolean isJComboBoxNotEmpty​(javax.swing.JComboBox<java.lang.String> combo)
      • getNBHSensor

        public static NBHSensor getNBHSensor​(java.lang.String newName,
                                             boolean isInternal)
        Get a NBHSensor from the CtcManager NBHSensor map or create a new one.
        newName - The new name to be retrieved from the map or created.
        isInternal - True if an internal sensor is being requested. Internal will create the sensor if necessary using provide(String).
        a NBHSensor or null.
      • getNBHTurnout

        public static NBHTurnout getNBHTurnout​(java.lang.String newName,
                                               boolean feedbackDifferent)
        Get a NBHTurnout from the CtcManager NBHTurnout map or create a new one.
        newName - The new name to be retrieved from the map or created.
        feedbackDifferent - The feedback different state.
        a valid NBHTurnout or an empty NBHTurnout.
      • getNBHSignal

        public static NBHSignal getNBHSignal​(java.lang.String newName)
        Get a NBHSignal from the CtcManager NBHSignal map or create a new one.
        newName - The new name to be retrieved from the map or created.
        a valid NBHSignal or null.
      • addSensorToSensorList

        public static void addSensorToSensorList​(java.util.ArrayList<NBHSensor> list,
                                                 java.lang.String sensorName)
        Add a valid NBHSensor entry to an ArrayList. The sensor name has to match an existing sensor in the JMRI sensor table.
        list - The NBHSensor array list.
        sensorName - The proposed sensor name.