Class ViewModelHelper.ViewLoader

  • Enclosing class:
    ViewModelHelper

    public static class ViewModelHelper.ViewLoader
    extends java.lang.Object
    Helper class for encapsulating view loading functionality.
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewLoader()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean ecoreExistsInWorkspace​(java.lang.String ecorePath)
      Indicates whether the Ecore denoted by the path exists in the workspace.
      protected java.lang.String getPath​(org.eclipse.core.resources.IFile file)
      Returns the path string of the given file.
      protected ReportService getReportService()
      Returns the service used for error reporting.
      protected java.util.Optional<java.lang.String> getViewName​(VView view)
      Determines a name for the given view.
      protected java.lang.String getViewNameAndLocation​(VView view, java.lang.String viewLocation)
      Returns a string representation of the view and its location.
      protected VView loadView​(java.lang.String path)
      Loads the view denoted by the given path.
      VView loadView​(org.eclipse.core.resources.IFile file, java.util.Collection<java.lang.String> registeredEcores)
      Loads the view denoted by the given file.
      protected void registerEcore​(java.lang.String ecorePath)
      Try to register the Ecore denoted by the path.
      protected void registerReferencedEcores​(VView view, java.lang.String viewLocation, java.util.Collection<java.lang.String> registeredEcores)
      Registers the referenced Ecores of the given view.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ViewLoader

        public ViewLoader()
    • Method Detail

      • loadView

        public VView loadView​(org.eclipse.core.resources.IFile file,
                              java.util.Collection<java.lang.String> registeredEcores)
                       throws java.io.IOException
        Loads the view denoted by the given file. Also tries to register referenced Ecores.
        Parameters:
        file - the view to load
        registeredEcores - a collection to which all Ecores which are successfully registered are added.
        Returns:
        the VView denoted by the given file.
        Throws:
        java.io.IOException - if something goes wrong during loading or registering
      • getPath

        protected java.lang.String getPath​(org.eclipse.core.resources.IFile file)
        Returns the path string of the given file.
        Parameters:
        file - the IFile for which the path string shall be determined.
        Returns:
        The determined string path.
      • loadView

        protected VView loadView​(java.lang.String path)
        Loads the view denoted by the given path.
        Parameters:
        path - the path denoting the VView
        Returns:
        the loaded VView
      • registerReferencedEcores

        protected void registerReferencedEcores​(VView view,
                                                java.lang.String viewLocation,
                                                java.util.Collection<java.lang.String> registeredEcores)
                                         throws java.io.IOException
        Registers the referenced Ecores of the given view.
        Parameters:
        view - the VView which possibly references Ecores.
        viewLocation - the location of the given view. Used for error reporting.
        registeredEcores - a collection to which all Ecores which are successfully registered are added.
        Throws:
        java.io.IOException - if something goes wrong during loading or registering
      • getViewNameAndLocation

        protected java.lang.String getViewNameAndLocation​(VView view,
                                                          java.lang.String viewLocation)
        Returns a string representation of the view and its location.
        Parameters:
        view - the VView.
        viewLocation - the location.
        Returns:
        a string representation of the view and its location
      • getViewName

        protected java.util.Optional<java.lang.String> getViewName​(VView view)
        Determines a name for the given view.
        Parameters:
        view - the [@link VView}.
        Returns:
        an optional possibly containing a determined name, empty otherwise.
      • ecoreExistsInWorkspace

        protected boolean ecoreExistsInWorkspace​(java.lang.String ecorePath)
        Indicates whether the Ecore denoted by the path exists in the workspace.
        Parameters:
        ecorePath - the potential path to an Ecore
        Returns:
        true if an Ecore exists at the path in the workspace, false otherwise.
      • getReportService

        protected ReportService getReportService()
        Returns the service used for error reporting.
        Returns:
        the ReportService
      • registerEcore

        protected void registerEcore​(java.lang.String ecorePath)
                              throws java.io.IOException
        Try to register the Ecore denoted by the path.
        Parameters:
        ecorePath - the path to the Ecore in the workspace which shall be registered.
        Throws:
        java.io.IOException - if something goes wrong during registering.