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`

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

`org.eclipse.draw2d.MouseMotionListener.Stub`

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

`org.eclipse.draw2d.IFigure.NoInsets`

### Field Summary

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

`DEFAULT_FIRING, REPEAT_FIRING, STYLE_BUTTON, STYLE_TOGGLE`

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

`MAX_DIMENSION, MIN_DIMENSION, NO_INSETS`

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`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.
`ContextButtonPad` `getContextButtonPad()` Returns the `ContextButtonPad` which is used to access the environment (editor, ...).
`DiagramBehavior` `getDiagramBehavior()` Returns the `IDiagramContainerUI` for which the context button is displayed.
`org.eclipse.gef.EditPart` `getEditPart()` Returns the `EditPart` for which the context button is displayed.
`ContextButtonEntry` `getEntry()` Returns the `ContextButtonEntry` which contains the logical and identifying information for the context button (command, name, image, ...).
`PositionedContextButton` `getPositionedContextButton()` Returns the `PositionedContextButton` 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)`

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

`addActionListener, addChangeListener, doClick, getModel, isRolloverEnabled, isSelected, isStyle, removeActionListener, removeChangeListener, setEnabled, setEventHandler, setFiringMethod, setModel, setRolloverEnabled, setSelected, setStyle`

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

`add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFont, getForegroundColor, getInsets, getLayoutManager, getLocalBackgroundColor, 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, isOpaque, isRequestFocusEnabled, isShowing, isVisible, paint, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setClippingStrategy, setConstraint, setCursor, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate`

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

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

### Constructor Detail

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

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

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