Class CreateAnnotationViaApiCommand

All Implemented Interfaces:
Command

public abstract class CreateAnnotationViaApiCommand extends AbstractPageViewCommand
Creates an Annotation programmatically via Annotation API. In contrast: The standard way is to create an Annotation by user interaction on the UI.
  • Constructor Details

    • CreateAnnotationViaApiCommand

      public CreateAnnotationViaApiCommand()
  • Method Details

    • setProfileId

      public void setProfileId(String profileId)
      Sets the profileId.

      You must also call loadAnnotationProfile();

      Parameters:
      profileId - The profile ID as it is specified in the annotation profile XML file within the tag annotation-profile.
    • setAnnotationType

      public void setAnnotationType(String annotationType)
      Sets the annotationType.
      Parameters:
      annotationType - The Annotation type as it is defined within either the annotation-type or annotation-template tag in the annotation profile file.
    • loadAnnotationProfile

      public void loadAnnotationProfile()
      Loads an AnnotationProfile which is required to create a new Annotation.

      After the AnnotationProfile is completely loaded, set the field profile. A non-null profile indicates that the command can now be executed.

    • getPageForNewAnnotation

      public abstract Page getPageForNewAnnotation()
      Override this method to set the page onto which the new Annotation shall be placed.
      Returns:
      The page onto the Annotation shall be placed.
    • createAnnotation

      protected Annotation createAnnotation(AnnotationProfile profile, String annoType, com.levigo.jadice.web.shared.model.annotation.internal.AnnotationPageSegment aps)
      Creates an Annotation that is not yet attached to the Document structure.
      Parameters:
      profile - The profile id as it is set in the annotation profile xml file within the tag annotation-profile.
      annoType - The annotation type defining which specific subclass of Annotation to use.
      aps - The AnnotationPageSegment for the new anno.
      Returns:
      The new Annotation.
    • execute

      protected void execute()
      Executes the command to create an Annotation if the preconditions listed in the documentation of canExecute() are met. Additionally the following calls must have been made before calling execute:

      If you want to execute this Command without using a JadiceButtonBuilder, you need to call the InjectedCommand.execute(Collection) method, providing the used PageView as single member of the Collection param.

      Specified by:
      execute in class InjectedCommand
    • configure

      public abstract void configure(com.levigo.jadice.web.shared.model.annotation.internal.AnnotationPageSegment aps, Annotation annotation)
      Fine-tunes the newly created Annotation.

      Sets the still missing values like position and size of the Annotation, the text for a TextAnnotation, color values or line widths.

      Parameters:
      aps - The AnnotationPageSegment where the new Annotation shall be put on.
      annotation - The new Annotation.
    • canExecute

      protected boolean canExecute()

      Checks if the Command can be executed at the given time.


      Expected preconditions:
      Overrides:
      canExecute in class AbstractPageViewCommand
      Returns:
      True if the Command can be executed.