com.dlsc.flexgantt.command.layer

## Class DefaultCreateConstraintCommand

- java.lang.Object
- - com.dlsc.flexgantt.command.AbstractCommand
  - - com.dlsc.flexgantt.command.layer.DefaultCreateConstraintCommand

- All Implemented Interfaces:
    ICommand, Serializable

      public class DefaultCreateConstraintCommand
      extends AbstractCommand

  A command that will add a constraint to the Gantt chart model.
  Since:
    2.1
  Author:
    Dirk Lemmermann
  See Also:
    `IRelationshipPolicy.getCreateRelationshipCommand(TimelineObjectPath, TimelineObjectPath, RelationshipType, com.dlsc.flexgantt.model.gantt.IGanttChartModel)`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultCreateConstraintCommand(TimelineObjectPath sourcePath, TimelineObjectPath targetPath, RelationshipType type, DefaultGanttChartModel model)` Constructs a new command.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected IConstraint` | `createConstraint(TimelineObjectPath sourcePath, TimelineObjectPath targetPath)` Creates the constraint object, which stores the source and the target path.
    `void` | `executeCommand(IProgressMonitor monitor)` Executes the command.
    `IConstraint` | `getConstraint()` The constraint that was created by the command.
    `DefaultGanttChartModel` | `getModel()` Returns the model for which the command creates / created a new constraint object.
    `RelationshipType` | `getRelationshipType()` Returns the type of constraint that the user wants to create (S-E, E-S, S-S, E-E).
    `TimelineObjectPath` | `getSourcePath()` The path to the timeline object that will be used as the source of the constraint.
    `TimelineObjectPath` | `getTargetPath()` The path to the timeline object that will be used as the target of the constraint.
    `void` | `undoCommand(IProgressMonitor monitor)` Undos the command.

    - ### Methods inherited from class com.dlsc.flexgantt.command.AbstractCommand

      `getName, isRedoable, isRelevant, isUndoable, redoCommand, setName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultCreateConstraintCommand

          public DefaultCreateConstraintCommand(TimelineObjectPath sourcePath,
                                                TimelineObjectPath targetPath,
                                                RelationshipType type,
                                                DefaultGanttChartModel model)

      Constructs a new command.
      Parameters:
        `sourcePath` - the path to the source timeline object
        `targetPath` - the path to the target timeline object
        `type` - the type of constraint that the user wants to create (start to end, end to start, start to start, end to end)
        `model` - the model for which to create the constraint object
      Since:
        2.1

  - ### Method Detail

    - #### executeCommand

          public void executeCommand(IProgressMonitor monitor)
                              throws CommandException

      Description copied from interface: `ICommand`
      Executes the command.
      Parameters:
        `monitor` - a progress monitor
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong

    - #### undoCommand

          public void undoCommand(IProgressMonitor monitor)
                           throws CommandException

      Description copied from interface: `ICommand`
      Undos the command.
      Parameters:
        `monitor` - a progress monitor
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong

    - #### getModel

          public DefaultGanttChartModel getModel()

      Returns the model for which the command creates / created a new constraint object.
      Returns:
        the model for which a constraint object was created
      Since:
        2.1

    - #### getConstraint

          public IConstraint getConstraint()

      The constraint that was created by the command.
      Returns:
        the new constraint object
      Since:
        2.1

    - #### getRelationshipType

          public RelationshipType getRelationshipType()

      Returns the type of constraint that the user wants to create (S-E, E-S, S-S, E-E).
      Returns:
        the type of constraint (S-E, E-S, S-S, E-E)
      Since:
        2.1

    - #### getSourcePath

          public TimelineObjectPath getSourcePath()

      The path to the timeline object that will be used as the source of the constraint.
      Returns:
        the path to the source timeline object
      Since:
        2.1

    - #### getTargetPath

          public TimelineObjectPath getTargetPath()

      The path to the timeline object that will be used as the target of the constraint.
      Returns:
        the path to the target timeline object
      Since:
        2.1

    - #### createConstraint

          protected IConstraint createConstraint(TimelineObjectPath sourcePath,
                                                 TimelineObjectPath targetPath)

      Creates the constraint object, which stores the source and the target path. By default the command always creates instances of `DefaultRelationship`. Subclasses can override this method to create relationships of their own types.
      Parameters:
        `sourcePath` - the path to the source timeline object
        `targetPath` - the path to the target timeline object
      Returns:
        a constraint object
      Since:
        2.1

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.