Class Configuration

    • Method Detail

      • isInstanceInitialized

        public static boolean isInstanceInitialized()
      • initialize

        public static void initialize​(java.io.File configurationDirectory)
        Initializes a new persistent Configuration singleton storing configuration files in configurationDirectory.
        Parameters:
        configurationDirectory -
      • initialize

        public static void initialize()
        Initializes a new temporary Configuration singleton storing configuration in memory only.
        Parameters:
        configurationDirectory -
      • setMachine

        public void setMachine​(Machine machine)
      • getScripting

        public Scripting getScripting()
      • getBus

        public com.google.common.eventbus.EventBus getBus()
      • getConfigurationDirectory

        public java.io.File getConfigurationDirectory()
      • getSystemUnits

        public LengthUnit getSystemUnits()
      • setSystemUnits

        public void setSystemUnits​(LengthUnit lengthUnit)
      • getLocale

        public java.util.Locale getLocale()
      • setLocale

        public void setLocale​(java.util.Locale locale)
      • getThemeInfo

        public ThemeInfo getThemeInfo()
      • setThemeInfo

        public void setThemeInfo​(ThemeInfo theme)
      • isAlternateRows

        public java.lang.Boolean isAlternateRows()
      • setAlternateRows

        public void setAlternateRows​(java.lang.Boolean alternateRows)
      • getLengthDisplayFormat

        public java.lang.String getLengthDisplayFormat()
      • setLengthDisplayFormat

        public void setLengthDisplayFormat​(java.lang.String format)
      • getLengthDisplayAlignedFormat

        public java.lang.String getLengthDisplayAlignedFormat()
      • setLengthDisplayAlignedFormat

        public void setLengthDisplayAlignedFormat​(java.lang.String format)
      • getLengthDisplayFormatWithUnits

        public java.lang.String getLengthDisplayFormatWithUnits()
      • setLengthDisplayFormatWithUnits

        public void setLengthDisplayFormatWithUnits​(java.lang.String format)
      • getLengthDisplayAlignedFormatWithUnits

        public java.lang.String getLengthDisplayAlignedFormatWithUnits()
      • setLengthDisplayAlignedFormatWithUnits

        public void setLengthDisplayAlignedFormatWithUnits​(java.lang.String format)
      • getVerticalScrollUnitIncrement

        public int getVerticalScrollUnitIncrement()
      • setVerticalScrollUnitIncrement

        public void setVerticalScrollUnitIncrement​(int verticalScrollUnitIncrement)
      • getResourceDirectory

        public java.io.File getResourceDirectory​(java.lang.Class forClass)
                                          throws java.io.IOException
        Gets a File reference for the resources directory belonging to the given class. The directory is guaranteed to exist.
        Parameters:
        forClass -
        Returns:
        Throws:
        java.io.IOException
      • getResourceFile

        public java.io.File getResourceFile​(java.lang.Class forClass,
                                            java.lang.String name)
                                     throws java.io.IOException
        Gets a File reference for the named file within the configuration directory. forClass is used to uniquely identify the file and keep it separate from other classes' files.
        Parameters:
        forClass -
        name -
        Returns:
        Throws:
        java.io.IOException
      • createResourceFile

        public java.io.File createResourceFile​(java.lang.Class forClass,
                                               java.lang.String prefix,
                                               java.lang.String suffix)
                                        throws java.io.IOException
        Creates a new file with a unique name within the configuration directory. forClass is used to uniquely identify the file within the application and a unique name is generated within that namespace. suffix is appended to the unique part of the filename. The result of calling File.getName() on the returned file can be used to load the same file in the future by calling getResourceFile(). This method uses NanosecondTime.get() so the files names will be unique and ordered.
        Parameters:
        forClass -
        suffix -
        Returns:
        Throws:
        java.io.IOException
      • load

        public void load()
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • save

        public void save()
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createBackedUpFile

        protected java.io.File createBackedUpFile​(java.lang.String fileName,
                                                  java.time.LocalDateTime now)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getPackage

        public Package getPackage​(java.lang.String id)
      • getPackages

        public java.util.List<Package> getPackages()
      • addPackage

        public void addPackage​(Package pkg)
      • removePackage

        public void removePackage​(Package pkg)
      • getPart

        public Part getPart​(java.lang.String id)
      • getParts

        public java.util.List<Part> getParts()
      • addPart

        public void addPart​(Part part)
      • removePart

        public void removePart​(Part part)
      • getBoards

        public java.util.List<Board> getBoards()
        Returns:
        an unmodifiable list of Boards loaded in the configuration
      • getPanels

        public java.util.List<Panel> getPanels()
        Returns:
        an unmodifiable list of Panels loaded in the configuration
      • fireVisionSettingsChanged

        public void fireVisionSettingsChanged()
        Signal that something about the vision settings has changed. Inheritance makes it hard to track how changes affect single properties, therefore this is simply fired globally.
      • getMachine

        public Machine getMachine()
      • addPanel

        public void addPanel​(Panel panel)
        Adds the specified Panel definition to the configuration
        Parameters:
        panel - - the Panel definition to be added
      • addPanel

        public void addPanel​(java.io.File file)
                      throws java.lang.Exception
        Loads a Panel definition into the configuration if it is not already loaded
        Parameters:
        file - - the file containing the Panel definition
        Throws:
        java.lang.Exception - if the specified file does not exist or does not contain a valid Panel
      • removePanel

        public void removePanel​(Panel panel)
        Removes the specified Panel definition from the configuration. If the Panel definition has been flagged as being modified, a dialog is presented to confirm if the operator desires to save the Panel definition to the file system before it is removed.
        Parameters:
        panel - - the Panel definition to remove
      • getPanel

        public Panel getPanel​(java.io.File file)
                       throws java.lang.Exception
        Returns the Panel definition contained in the specified file. If the Panel definition is already loaded in the configuration, it is found and returned. If it is not already loaded into the configuration, the specified file is read and loaded into the configuration. If the specified file does not exist, a new empty Panel definition is created and saved into the specified file and then is loaded into the configuration.
        Parameters:
        file - - the file containing the Panel definition
        Throws:
        java.lang.Exception - if the specified file exists but does not contain a valid Panel
      • addBoard

        public void addBoard​(Board board)
        Adds the specified Board definition to the configuration
        Parameters:
        board - - the Board definition to be added
      • addBoard

        public void addBoard​(java.io.File file)
                      throws java.lang.Exception
        Loads a Board definition into the configuration if it is not already loaded
        Parameters:
        file - - the file containing the Board definition
        Throws:
        java.lang.Exception - if the specified file does not exist or does not contain a valid Board
      • removeBoard

        public void removeBoard​(Board board)
        Removes the specified Board definition from the configuration. If the Board definition has been flagged as being modified, a dialog is presented to confirm if the operator desires to save the Board definition to the file system before it is removed.
        Parameters:
        board - - the Board to remove
      • getBoard

        public Board getBoard​(java.io.File file)
                       throws java.lang.Exception
        Returns the Board definition contained in the specified file. If the Board definition is already loaded in the configuration, it is found and returned. If it is not already loaded, the specified file is read and loaded into the configuration. If the specified file does not exist, a new empty Board definition is created and saved into the specified file and then is loaded into the configuration.
        Parameters:
        file - - the file containing the Board definition
        Returns:
        the Board definition
        Throws:
        java.lang.Exception - if the specified file exists but does not contain a valid Board definition
      • loadJob

        public Job loadJob​(java.io.File file)
                    throws java.lang.Exception
        Returns the Job contained within the specified file
        Parameters:
        file - - the file containing the Job
        Returns:
        the Job
        Throws:
        java.lang.Exception - - if the file can't be read successfully
      • resolveBoard

        public void resolveBoard​(Job job,
                                 BoardLocation boardLocation)
                          throws java.lang.Exception
        Attempts to find the Board definition associated with the given BoardLocation, create a copy of it, and then assign the copy to the given BoardLocation
        Parameters:
        job - - the Job
        boardLocation - - the BoardLocation
        Throws:
        java.lang.Exception - if the Board definition associated with the BoardLocation can't be loaded successfully
      • resolvePanel

        public void resolvePanel​(Job job,
                                 PanelLocation panelLocation)
                          throws java.lang.Exception
        Attempts to find the Panel definition associated with the given PanelLocation, create a copy of it, and assign the copy to the PanelLocation. Recursively resolves the Panel's children.
        Parameters:
        job - - the Job
        panelLocation - - the PanelLocation
        Throws:
        java.lang.Exception - if the Panel and all of its descendants can't be loaded successfully
      • isInUse

        public boolean isInUse​(PlacementsHolder<?> placementsHolder)
        Checks to see if the specified PlacementsHolder is used by the current job or any of the currently loaded panels
        Parameters:
        placementsHolder - - the PlacementsHolder to check
        Returns:
        true if the PlacementsHolder is in use
      • saveJob

        public void saveJob​(Job job,
                            java.io.File file)
                     throws java.lang.Exception
        Serializes the specified job and writes it to the specified file
        Parameters:
        job - - the job to save
        file - - the file into which the job is to be saved
        Throws:
        java.lang.Exception - if the file can't be written successfully
      • getImgurClientId

        public java.lang.String getImgurClientId()
      • savePanel

        public void savePanel​(Panel panel)
                       throws java.lang.Exception
        Saves the specified Panel into its file
        Parameters:
        panel - - the Panel to save
        Throws:
        java.lang.Exception - if the file can't be written successfully
      • saveBoard

        public void saveBoard​(Board board)
                       throws java.lang.Exception
        Saves the specified Board into its file
        Parameters:
        panel - - the Board to save
        Throws:
        java.lang.Exception - if the file can't be written successfully
      • createSerializer

        public static org.simpleframework.xml.Serializer createSerializer()
      • createId

        public static java.lang.String createId​(java.lang.String prefix)