GEF (MVC)
3.9.100.201405261516

org.eclipse.gef.ui.actions
Class PasteTemplateAction

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.jface.action.AbstractAction
          extended by org.eclipse.jface.action.Action
              extended by org.eclipse.gef.ui.actions.WorkbenchPartAction
                  extended by org.eclipse.gef.ui.actions.SelectionAction
                      extended by org.eclipse.gef.ui.actions.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:
CopyTemplateAction

Field Summary
 
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
PasteTemplateAction(IWorkbenchPart editor)
          Constructor for PasteTemplateAction.
 
Method Summary
protected  boolean calculateEnabled()
          Calculates and returns the enabled state of this action.
protected  Command createPasteCommand()
          Creates and returns a command (which may be null) to create a new EditPart based on the template on the clipboard.
protected  java.lang.Object getClipboardContents()
          Returns the template on the clipboard, if there is one.
protected  CreationFactory getFactory(java.lang.Object template)
          Returns the appropriate Factory object to be used for the specified template.
protected  Point getPasteLocation(GraphicalEditPart container)
           
protected  void init()
          Initializes this action.
 void run()
          Executes the command returned by createPasteCommand().
 
Methods inherited from class org.eclipse.gef.ui.actions.SelectionAction
dispose, getSelectedObjects, getSelection, handleSelectionChanged, setSelection, setSelectionProvider, update
 
Methods inherited from class org.eclipse.gef.ui.actions.WorkbenchPartAction
execute, getCommandStack, getWorkbenchPart, isEnabled, refresh, setLazyEnablementCalculation, setWorkbenchPart
 
Methods inherited from class org.eclipse.jface.action.Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class org.eclipse.jface.action.AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasteTemplateAction

public PasteTemplateAction(IWorkbenchPart editor)
Constructor for PasteTemplateAction.

Parameters:
editor -
Method Detail

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:
WorkbenchPartAction.calculateEnabled()

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 java.lang.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(java.lang.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:
WorkbenchPartAction.init()

run

public void run()
Executes the command returned by createPasteCommand().

Specified by:
run in interface IAction
Overrides:
run in class Action

GEF (MVC)
3.9.100.201405261516

Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.