Class CommandFactory
java.lang.Object
com.amalgamasimulation.desktop.appelements.commands.CommandFactory
- All Implemented Interfaces:
ICommandFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends org.eclipse.emf.ecore.EObject>
com.amalgamasimulation.emf.commands.AddCommand<T> copy(T object, int injectionIndex, boolean copyReferences) Returns a command that adds a copy of object to the same container.<C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject>
com.amalgamasimulation.emf.commands.AddCommand<T> <C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject>
com.amalgamasimulation.emf.commands.AddCommand<T> Returns a command that adds a new object to container.<C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject>
com.amalgamasimulation.emf.commands.AddCommand<T> Returns a command that adds a new object to container.org.eclipse.emf.ecore.util.ECrossReferenceAdapterReturns the adapter that the factory adds to the objects it creates and that remove uses to find references.protected StringReturns the separator between the name base and number in generated IDs; empty by default.<T extends org.eclipse.emf.ecore.EObject>
org.eclipse.emf.common.command.CompoundCommandremove(T object) Returns a command that removes object from its container and clears references to it from other objects, found through the factory's ECrossReferenceAdapter.voidsetCrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter crossReferenceAdapter) Replaces the adapter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.appelements.commands.ICommandFactory
removeAll
-
Constructor Details
-
CommandFactory
public CommandFactory()
-
-
Method Details
-
create
public <C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject> com.amalgamasimulation.emf.commands.AddCommand<T> create(C container, String patternId, Supplier<T> creator) Description copied from interface:ICommandFactoryReturns a command that adds a new object to container. creator is called when this method is called, not when the command is executed. If the object type has a string ID attribute, it gets a unique identifier built from patternId: the next number among the objects of the same list in container (UniqueNameGenerator). If the type has a string name attribute, it gets the same value. Without these attributes the object stays as creator returned it. The object is added to the end of the list; if the container reference is single, the object is set to it.- Specified by:
createin interfaceICommandFactory- Type Parameters:
C- the type of the containerT- the type of the new object- Parameters:
container- the object whose containment reference receives the new objectpatternId- the identifier pattern, with or without a trailing numbercreator- creates the new object- Returns:
- the add command; getObject() returns the new object
-
create
public <C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject> com.amalgamasimulation.emf.commands.AddCommand<T> create(C container, Supplier<T> creator) Description copied from interface:ICommandFactoryReturns a command that adds a new object to container. Unlike the method with patternId, ID and name are not set: the object is added as creator returned it.- Specified by:
createin interfaceICommandFactory- Type Parameters:
C- the type of the containerT- the type of the new object- Parameters:
container- the object whose containment reference receives the new objectcreator- creates the new object- Returns:
- the add command; getObject() returns the new object
-
create
public <C extends org.eclipse.emf.ecore.EObject,T extends org.eclipse.emf.ecore.EObject> com.amalgamasimulation.emf.commands.AddCommand<T> create(C container, int injectionIndex, Supplier<T> creator) -
remove
public <T extends org.eclipse.emf.ecore.EObject> org.eclipse.emf.common.command.CompoundCommand remove(T object) Description copied from interface:ICommandFactoryReturns a command that removes object from its container and clears references to it from other objects, found through the factory's ECrossReferenceAdapter. These references are found only if the adapter target is set to the scenario (setTarget).- Specified by:
removein interfaceICommandFactory- Type Parameters:
T- the type of the removed object- Parameters:
object- the object to remove- Returns:
- the remove command
-
copy
public <T extends org.eclipse.emf.ecore.EObject> com.amalgamasimulation.emf.commands.AddCommand<T> copy(T object, int injectionIndex, boolean copyReferences) Description copied from interface:ICommandFactoryReturns a command that adds a copy of object to the same container. The copy is created when this method is called and enters the model when the command is executed. The ID attribute of the copy gets the next free number based on the ID of the original; other attributes are copied as they are, so name does not change. Contained objects are always copied.With copyReferences set to true, plain (non-containment) references are copied too. A reference to an object inside the copy points to that object's copy. A reference to an object outside the copy points to the same object. If the reference has an opposite list, the copy is added to that list by the same command, so undo removes it from there. If the opposite reference is single, the reference is not copied, because otherwise the copy would take the objects away from the original. With copyReferences set to false, plain references are not copied, including references inside the copy.
- Specified by:
copyin interfaceICommandFactory- Type Parameters:
T- the type of the copied object- Parameters:
object- the object to copy; it must be in a containerinjectionIndex- the position of the copy in the container list; -1 adds it to the endcopyReferences- whether plain references are copied- Returns:
- the add command; getObject() returns the copy
-
getCrossReferenceAdapter
public org.eclipse.emf.ecore.util.ECrossReferenceAdapter getCrossReferenceAdapter()Description copied from interface:ICommandFactoryReturns the adapter that the factory adds to the objects it creates and that remove uses to find references.- Specified by:
getCrossReferenceAdapterin interfaceICommandFactory- Returns:
- the cross reference adapter
-
setCrossReferenceAdapter
public void setCrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter crossReferenceAdapter) Description copied from interface:ICommandFactoryReplaces the adapter. Objects created earlier keep the old adapter; the new one needs the scenario as its target (setTarget).- Specified by:
setCrossReferenceAdapterin interfaceICommandFactory- Parameters:
crossReferenceAdapter- the new adapter
-
getNameSeparator
Returns the separator between the name base and number in generated IDs; empty by default.
-