Package org.eclipse.graphiti.ui.internal.contextbuttons

# 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.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.draw2d.Figure

`org.eclipse.draw2d.Figure.FigureIterator, org.eclipse.draw2d.Figure.IdentitySearch, org.eclipse.draw2d.Figure.ReverseFigureChildrenIterator`

## Nested classes/interfaces inherited from interface org.eclipse.draw2d.IFigure

`org.eclipse.draw2d.IFigure.NoInsets`

## Nested classes/interfaces inherited from interface org.eclipse.draw2d.MouseMotionListener

`org.eclipse.draw2d.MouseMotionListener.Stub`

## Field Summary

### Fields inherited from class org.eclipse.draw2d.Clickable

`DEFAULT_FIRING, MAX_FLAG, REPEAT_FIRING, STYLE_BUTTON, STYLE_TOGGLE`

### Fields inherited from class org.eclipse.draw2d.Figure

`bgColor, border, bounds, fgColor, flags, font, maxSize, minSize, NO_MANAGER, prefSize, toolTip`

### Fields inherited from interface org.eclipse.draw2d.IFigure

`MAX_DIMENSION, MIN_DIMENSION, NO_INSETS`

## Constructor Summary

Constructors
Constructor
Description
`ContextButton(String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad)`
Creates a new ContextButton.

## Method Summary

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.
`final ContextButtonPad`
`getContextButtonPad()`
Returns the `ContextButtonPad` which is used to access the environment (editor, ...).
`final DiagramBehavior`
`getDiagramBehavior()`
Returns the `IDiagramContainerUI` for which the context button is displayed.
`final org.eclipse.gef.EditPart`
`getEditPart()`
Returns the `EditPart` for which the context button is displayed.
`final ContextButtonEntry`
`getEntry()`
Returns the `ContextButtonEntry` which contains the logical and identifying information for the context button (command, name, image, ...).
`final PositionedContextButton`
`getPositionedContextButton()`
Returns the `PositionedContextButton` which contains the visual information for the context button (colors, position, size, opacity, ...)
`final 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, getChildrenRevIterable, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getListenersIterable, 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, optimizeClip, 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ContextButton

public ContextButton(String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad)
Creates a new ContextButton.

Parameters:
  `providerId` -
  `positionedContextButton` - The `PositionedContextButton` contains the visual information for the context button (colors, position, size, opacity, ...). It also provides access to the `ContextButtonEntry`.
  `contextButtonPad` - The `ContextButtonPad` is used to access the environment (editor, ...).

## Method Details

### getPositionedContextButton

public final PositionedContextButton getPositionedContextButton()
Returns the `PositionedContextButton` 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 the `ContextButtonEntry` 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 the `ContextButtonPad` 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 the `IDiagramContainerUI` 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 the `EditPart` 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 class `org.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 interface `org.eclipse.draw2d.IFigure`
Overrides:
  `handleMouseEntered` in class `org.eclipse.draw2d.Figure`

### handleMouseExited

public void handleMouseExited(org.eclipse.draw2d.MouseEvent event)
Changes the opacity of the context button.

Specified by:
  `handleMouseExited` in interface `org.eclipse.draw2d.IFigure`
Overrides:
  `handleMouseExited` in class `org.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 interface `org.eclipse.draw2d.IFigure`
Overrides:
  `handleMousePressed` in class `org.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 interface `org.eclipse.draw2d.IFigure`
Overrides:
  `handleMouseReleased` in class `org.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 interface `org.eclipse.draw2d.MouseMotionListener`

### mouseEntered

public void mouseEntered(org.eclipse.draw2d.MouseEvent me)

Specified by:
  `mouseEntered` in interface `org.eclipse.draw2d.MouseMotionListener`

### mouseExited

public void mouseExited(org.eclipse.draw2d.MouseEvent me)

Specified by:
  `mouseExited` in interface `org.eclipse.draw2d.MouseMotionListener`

### mouseHover

public void mouseHover(org.eclipse.draw2d.MouseEvent me)

Specified by:
  `mouseHover` in interface `org.eclipse.draw2d.MouseMotionListener`

### mouseMoved

public void mouseMoved(org.eclipse.draw2d.MouseEvent me)

Specified by:
  `mouseMoved` in interface `org.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 interface `org.eclipse.draw2d.ActionListener`