Class ContextButton
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.draw2d.Clickable
-
- org.eclipse.graphiti.ui.internal.contextbuttons.ContextButton
-
- All Implemented Interfaces:
org.eclipse.draw2d.ActionListener
,org.eclipse.draw2d.IFigure
,org.eclipse.draw2d.MouseMotionListener
public class ContextButton extends org.eclipse.draw2d.Clickable implements org.eclipse.draw2d.MouseMotionListener, org.eclipse.draw2d.ActionListener
A context button, which is used for example in the context button pad. It does not extend button, but is an implementation from scratch, because it has a quite specific look and behavior.
-
-
Constructor Summary
Constructors Constructor Description ContextButton(java.lang.String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad)
Creates a new ContextButton.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(org.eclipse.draw2d.ActionEvent event)
Performs the command of the context button or opens a context-menu with a selection of multiple commands to perform.protected org.eclipse.swt.graphics.Path
createPath(int shrinkLines)
Creates and returns the path, which defines the outer lines and filling area of the context button.ContextButtonPad
getContextButtonPad()
Returns theContextButtonPad
which is used to access the environment (editor, ...).DiagramBehavior
getDiagramBehavior()
Returns theIDiagramContainerUI
for which the context button is displayed.org.eclipse.gef.EditPart
getEditPart()
Returns theEditPart
for which the context button is displayed.ContextButtonEntry
getEntry()
Returns theContextButtonEntry
which contains the logical and identifying information for the context button (command, name, image, ...).PositionedContextButton
getPositionedContextButton()
Returns thePositionedContextButton
which contains the visual information for the context button (colors, position, size, opacity, ...)double
getZoomLevel()
Returns the zoom-level for which the context-button shall be painted.void
handleMouseEntered(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.void
handleMouseExited(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.void
handleMousePressed(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.void
handleMouseReleased(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.void
mouseDragged(org.eclipse.draw2d.MouseEvent me)
Creates a connection with the connection-tool when dragging the context button.void
mouseEntered(org.eclipse.draw2d.MouseEvent me)
void
mouseExited(org.eclipse.draw2d.MouseEvent me)
void
mouseHover(org.eclipse.draw2d.MouseEvent me)
void
mouseMoved(org.eclipse.draw2d.MouseEvent me)
protected void
paintFigure(org.eclipse.draw2d.Graphics graphics)
Paints the context button (lines, filling, image, ...).-
Methods inherited from class org.eclipse.draw2d.Clickable
addActionListener, addChangeListener, createDefaultModel, createEventHandler, createModelObserver, doClick, fireActionPerformed, fireStateChanged, getModel, hookEventHandler, init, isRolloverEnabled, isSelected, isStyle, paintBorder, paintClientArea, removeActionListener, removeChangeListener, setContents, setEnabled, setEventHandler, setFiringMethod, setModel, setRolloverEnabled, setSelected, setStyle, unhookEventHandler
-
Methods inherited from class org.eclipse.draw2d.Figure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseHover, handleMouseMoved, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintChildren, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
-
-
-
-
Constructor Detail
-
ContextButton
public ContextButton(java.lang.String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad)
Creates a new ContextButton.- Parameters:
providerId
-positionedContextButton
- ThePositionedContextButton
contains the visual information for the context button (colors, position, size, opacity, ...). It also provides access to theContextButtonEntry
.contextButtonPad
- TheContextButtonPad
is used to access the environment (editor, ...).
-
-
Method Detail
-
getPositionedContextButton
public final PositionedContextButton getPositionedContextButton()
Returns thePositionedContextButton
which contains the visual information for the context button (colors, position, size, opacity, ...)- Returns:
- The
PositionedContextButton
which contains the visual information for the context button (colors, position, size, opacity, ...)
-
getEntry
public final ContextButtonEntry getEntry()
Returns theContextButtonEntry
which contains the logical and identifying information for the context button (command, name, image, ...). It is set in the constructor.- Returns:
- The
ContextButtonEntry
which contains the logical and identifying information for the context button (command, name, image, ...). It is set in the constructor.
-
getContextButtonPad
public final ContextButtonPad getContextButtonPad()
Returns theContextButtonPad
which is used to access the environment (editor, ...).- Returns:
- The
ContextButtonPad
which is used to access the environment (editor, ...).
-
getZoomLevel
public final double getZoomLevel()
Returns the zoom-level for which the context-button shall be painted.- Returns:
- The zoom-level for which the context-button shall be painted.
-
getDiagramBehavior
public final DiagramBehavior getDiagramBehavior()
Returns theIDiagramContainerUI
for which the context button is displayed.- Returns:
- The
IDiagramContainerUI
for which the context button is displayed.
-
getEditPart
public final org.eclipse.gef.EditPart getEditPart()
Returns theEditPart
for which the context button is displayed.- Returns:
- The
EditPart
for which the context button is displayed.
-
paintFigure
protected void paintFigure(org.eclipse.draw2d.Graphics graphics)
Paints the context button (lines, filling, image, ...).- Overrides:
paintFigure
in classorg.eclipse.draw2d.Figure
-
createPath
protected org.eclipse.swt.graphics.Path createPath(int shrinkLines)
Creates and returns the path, which defines the outer lines and filling area of the context button.- Parameters:
shrinkLines
- The number of lines, by which the path shall be shrinked. This allows to use this method to create the outer line, middle line and inner line of the context button.- Returns:
- The path, which defines the outer lines and filling area of the context button.
-
handleMouseEntered
public void handleMouseEntered(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.- Specified by:
handleMouseEntered
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
handleMouseEntered
in classorg.eclipse.draw2d.Figure
-
handleMouseExited
public void handleMouseExited(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.- Specified by:
handleMouseExited
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
handleMouseExited
in classorg.eclipse.draw2d.Figure
-
handleMousePressed
public void handleMousePressed(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.Additionally it disables the tooltip. Especially in the middle of the drag & drop procedure no tooltip shall appear.
- Specified by:
handleMousePressed
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
handleMousePressed
in classorg.eclipse.draw2d.Figure
-
handleMouseReleased
public void handleMouseReleased(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.Additionally it enables the tooltip again.
- Specified by:
handleMouseReleased
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
handleMouseReleased
in classorg.eclipse.draw2d.Figure
-
mouseDragged
public void mouseDragged(org.eclipse.draw2d.MouseEvent me)
Creates a connection with the connection-tool when dragging the context button.- Specified by:
mouseDragged
in interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseEntered
public void mouseEntered(org.eclipse.draw2d.MouseEvent me)
- Specified by:
mouseEntered
in interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseExited
public void mouseExited(org.eclipse.draw2d.MouseEvent me)
- Specified by:
mouseExited
in interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseHover
public void mouseHover(org.eclipse.draw2d.MouseEvent me)
- Specified by:
mouseHover
in interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseMoved
public void mouseMoved(org.eclipse.draw2d.MouseEvent me)
- Specified by:
mouseMoved
in interfaceorg.eclipse.draw2d.MouseMotionListener
-
actionPerformed
public void actionPerformed(org.eclipse.draw2d.ActionEvent event)
Performs the command of the context button or opens a context-menu with a selection of multiple commands to perform.- Specified by:
actionPerformed
in interfaceorg.eclipse.draw2d.ActionListener
-
-