Class TopLevelModelAccessor


  • public class TopLevelModelAccessor
    extends java.lang.Object
    Defines the generic access to the top-level model. This class is needed as some models and their editors shall be optional.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • TopLevelModelAccessor

        private TopLevelModelAccessor()
        Prevents external instantiation.
    • Method Detail

      • register

        public static void register​(java.lang.String extension,
                                    TopLevelModelAccessor.IModelAccessor<?> accessor)
        Registers an accessor via the model file extension / id.
        Parameters:
        extension - the model extension
        accessor - the model accessor
      • unregister

        public static void unregister​(java.lang.String extension)
        Removes a registered accessor.
        Parameters:
        extension - the model extension / id
      • getRegisteredCount

        public static int getRegisteredCount()
        Returns the number of registered accessors.
        Returns:
        the number of registered accessors
      • getAccessor

        public static TopLevelModelAccessor.IModelAccessor<?> getAccessor​(java.lang.String extension)
        Returns the registered accessor for extension.
        Parameters:
        extension - the model extension / id
        Returns:
        the registered accessor (may be null if none was registered)
      • getTopLevelModel

        public static ModelInfo<?> getTopLevelModel​(java.lang.String extension,
                                                    java.lang.String projectName,
                                                    java.lang.Object project)
        Returns the top-level model info through a registered accessor for extension.
        Parameters:
        extension - the model extension / id
        project - an optional instance to access the top level model from some EASy instance
        projectName - the name of the containing project (EASy convention)
        Returns:
        the registered accessor (may be null if none was registered)
      • registerLoader

        public static void registerLoader​(ProgressObserver observer,
                                          boolean failOnFirst)
                                   throws ModelManagementException
        Called to register the model loader (optional). Bulk operation on all registered accessors.s
        Parameters:
        observer - the progress observer
        failOnFirst - if true, bulk stops on first exception thrown and that exception is also thrown by this method, if false try all bulk operations and throw only the first exception occurred
        Throws:
        ModelManagementException - in case of failures
      • unregisterLoader

        public void unregisterLoader​(ProgressObserver observer,
                                     boolean failOnFirst)
                              throws ModelManagementException
        Called to unregister the model loader (optional). Bulk operation on all registered accessors.
        Parameters:
        observer - the progress observer
        failOnFirst - if true, bulk stops on first exception thrown and that exception is also thrown by this method, if false try all bulk operations and throw only the first exception occurred
        Throws:
        ModelManagementException - in case of failures
      • addLocation

        public void addLocation​(java.io.File location,
                                ProgressObserver observer,
                                boolean failOnFirst)
                         throws ModelManagementException
        Called to add a model location (optional). Bulk operation on all registered accessors.
        Parameters:
        location - the location
        observer - the progress observer
        failOnFirst - if true, bulk stops on first exception thrown and that exception is also thrown by this method, if false try all bulk operations and throw only the first exception occurred
        Throws:
        ModelManagementException - in case of failures
      • removeLocation

        public void removeLocation​(java.io.File location,
                                   ProgressObserver observer,
                                   boolean failOnFirst)
                            throws ModelManagementException
        Called to remove a model location (optional). Bulk operation on all registered accessors.
        Parameters:
        location - the location
        observer - the progress observer
        failOnFirst - if true, bulk stops on first exception thrown and that exception is also thrown by this method, if false try all bulk operations and throw only the first exception occurred
        Throws:
        ModelManagementException - in case of failures