Package org.eclipse.gef.ui.actions
Class PasteTemplateAction
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.jface.action.AbstractAction
-
- org.eclipse.jface.action.Action
-
- org.eclipse.gef.ui.actions.WorkbenchPartAction
-
- org.eclipse.gef.ui.actions.SelectionAction
-
- 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
Constructors Constructor Description PasteTemplateAction(IWorkbenchPart editor)
Constructor for PasteTemplateAction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
calculateEnabled()
Calculates and returns the enabled state of this action.protected Command
createPasteCommand()
Creates and returns a command (which may benull
) 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 org.eclipse.draw2d.geometry.Point
getPasteLocation(GraphicalEditPart container)
protected void
init()
Initializes this action.void
run()
Executes the command returned bycreatePasteCommand()
.-
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
-
-
-
-
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 classWorkbenchPartAction
- Returns:
true
ifcreatePasteCommand()
returns an executable command- See Also:
WorkbenchPartAction.calculateEnabled()
-
createPasteCommand
protected Command createPasteCommand()
Creates and returns a command (which may benull
) 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 returnnull
.- Parameters:
template
- the template Object; it will never benull
- Returns:
- a Factory
-
getPasteLocation
protected org.eclipse.draw2d.geometry.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 classWorkbenchPartAction
- See Also:
WorkbenchPartAction.init()
-
run
public void run()
Executes the command returned bycreatePasteCommand()
.
-
-