java.lang.Object
com.amalgamasimulation.desktop.appelements.commands.CommandFactory
All Implemented Interfaces:
ICommandFactory

public class CommandFactory extends Object implements ICommandFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <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>
    create(C container, int injectionIndex, Supplier<T> creator)
     
    <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)
    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>
    create(C container, Supplier<T> creator)
    Returns a command that adds a new object to container.
    org.eclipse.emf.ecore.util.ECrossReferenceAdapter
    Returns the adapter that the factory adds to the objects it creates and that remove uses to find references.
    protected String
    Returns 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.CompoundCommand
    remove(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.
    void
    setCrossReferenceAdapter(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, wait

    Methods 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: ICommandFactory
      Returns 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:
      create in interface ICommandFactory
      Type Parameters:
      C - the type of the container
      T - the type of the new object
      Parameters:
      container - the object whose containment reference receives the new object
      patternId - the identifier pattern, with or without a trailing number
      creator - 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: ICommandFactory
      Returns 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:
      create in interface ICommandFactory
      Type Parameters:
      C - the type of the container
      T - the type of the new object
      Parameters:
      container - the object whose containment reference receives the new object
      creator - 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: ICommandFactory
      Returns 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:
      remove in interface ICommandFactory
      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: ICommandFactory
      Returns 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:
      copy in interface ICommandFactory
      Type Parameters:
      T - the type of the copied object
      Parameters:
      object - the object to copy; it must be in a container
      injectionIndex - the position of the copy in the container list; -1 adds it to the end
      copyReferences - 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: ICommandFactory
      Returns the adapter that the factory adds to the objects it creates and that remove uses to find references.
      Specified by:
      getCrossReferenceAdapter in interface ICommandFactory
      Returns:
      the cross reference adapter
    • setCrossReferenceAdapter

      public void setCrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter crossReferenceAdapter)
      Description copied from interface: ICommandFactory
      Replaces the adapter. Objects created earlier keep the old adapter; the new one needs the scenario as its target (setTarget).
      Specified by:
      setCrossReferenceAdapter in interface ICommandFactory
      Parameters:
      crossReferenceAdapter - the new adapter
    • getNameSeparator

      protected String getNameSeparator()
      Returns the separator between the name base and number in generated IDs; empty by default.