Class PasteTemplateAction

All Implemented Interfaces:
Disposable, UpdateAction, IAction

public class PasteTemplateAction extends SelectionAction
If the current object on the clipboard is a valid template, this action will paste the template to the viewer.
Since:
3.8
See Also:
  • Constructor Details

    • PasteTemplateAction

      public PasteTemplateAction(IWorkbenchPart editor)
      Constructor for PasteTemplateAction.
      Parameters:
      editor -
  • Method Details

    • calculateEnabled

      protected boolean calculateEnabled()
      Description copied from class: WorkbenchPartAction
      Calculates and returns the enabled state of this action.
      Specified by:
      calculateEnabled in class WorkbenchPartAction
      Returns:
      true if createPasteCommand() returns an executable command
      See Also:
    • createPasteCommand

      protected Command createPasteCommand()
      Creates and returns a command (which may be null) to create a new EditPart based on the template on the clipboard.
      Returns:
      the paste command
    • getClipboardContents

      protected Object getClipboardContents()
      Returns the template on the clipboard, if there is one. Note that the template on the clipboard might be from a palette from another type of editor.
      Returns:
      the clipboard's contents
    • getFactory

      protected CreationFactory getFactory(Object template)
      Returns the appropriate Factory object to be used for the specified template. This Factory is used on the CreateRequest that is sent to the target EditPart. Note that the given template might be from a palette for a different GEF-based editor. In that case, this method can return null.
      Parameters:
      template - the template Object; it will never be null
      Returns:
      a Factory
    • getPasteLocation

      protected Point getPasteLocation(GraphicalEditPart container)
      Parameters:
      container - the parent of the new part that is being pasted
      Returns:
      the location at which to insert
    • init

      protected void init()
      Description copied from class: WorkbenchPartAction
      Initializes this action.
      Overrides:
      init in class WorkbenchPartAction
      See Also:
    • run

      public void run()
      Executes the command returned by createPasteCommand().
      Specified by:
      run in interface IAction
      Overrides:
      run in class Action