Package net.ssehub.easy.dslCore
Class TopLevelModelAccessor
- java.lang.Object
-
- net.ssehub.easy.dslCore.TopLevelModelAccessor
-
public class TopLevelModelAccessor extends java.lang.ObjectDefines the generic access to the top-level model. This class is needed as some models and their editors shall be optional.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTopLevelModelAccessor.AbstractDefaultModelAccessor<M extends IModel>Implements the register methods empty.static classTopLevelModelAccessor.AbstractModelAccessor<M extends IModel>Basic implementation ofTopLevelModelAccessor.IModelAccessorperforming model loader registration and location registration.static interfaceTopLevelModelAccessor.IModelAccessor<M extends IModel>Defines the interface for the model accessor.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,TopLevelModelAccessor.IModelAccessor<?>>ACCESSORS
-
Constructor Summary
Constructors Modifier Constructor Description privateTopLevelModelAccessor()Prevents external instantiation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocation(java.io.File location, ProgressObserver observer, boolean failOnFirst)Called to add a model location (optional).static TopLevelModelAccessor.IModelAccessor<?>getAccessor(java.lang.String extension)Returns the registered accessor forextension.static intgetRegisteredCount()Returns the number of registered accessors.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 forextension.static voidregister(java.lang.String extension, TopLevelModelAccessor.IModelAccessor<?> accessor)Registers an accessor via the model file extension / id.static java.lang.Iterable<TopLevelModelAccessor.IModelAccessor<?>>registered()Returns the registered accessors.static voidregisterLoader(ProgressObserver observer, boolean failOnFirst)Called to register the model loader (optional).voidremoveLocation(java.io.File location, ProgressObserver observer, boolean failOnFirst)Called to remove a model location (optional).static voidunregister(java.lang.String extension)Removes a registered accessor.voidunregisterLoader(ProgressObserver observer, boolean failOnFirst)Called to unregister the model loader (optional).
-
-
-
Field Detail
-
ACCESSORS
private static final java.util.Map<java.lang.String,TopLevelModelAccessor.IModelAccessor<?>> ACCESSORS
-
-
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 extensionaccessor- the model accessor
-
unregister
public static void unregister(java.lang.String extension)
Removes a registered accessor.- Parameters:
extension- the model extension / id
-
registered
public static java.lang.Iterable<TopLevelModelAccessor.IModelAccessor<?>> registered()
Returns the registered accessors.- Returns:
- the registered accessors
-
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 forextension.- 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 forextension.- Parameters:
extension- the model extension / idproject- an optional instance to access the top level model from some EASy instanceprojectName- 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 observerfailOnFirst- iftrue, bulk stops on first exception thrown and that exception is also thrown by this method, iffalsetry 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 observerfailOnFirst- iftrue, bulk stops on first exception thrown and that exception is also thrown by this method, iffalsetry 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 ModelManagementExceptionCalled to add a model location (optional). Bulk operation on all registered accessors.- Parameters:
location- the locationobserver- the progress observerfailOnFirst- iftrue, bulk stops on first exception thrown and that exception is also thrown by this method, iffalsetry 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 ModelManagementExceptionCalled to remove a model location (optional). Bulk operation on all registered accessors.- Parameters:
location- the locationobserver- the progress observerfailOnFirst- iftrue, bulk stops on first exception thrown and that exception is also thrown by this method, iffalsetry all bulk operations and throw only the first exception occurred- Throws:
ModelManagementException- in case of failures
-
-