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.ReverseFigureChildrenIteratorNested classes/interfaces inherited from interface org.eclipse.draw2d.IFigure
org.eclipse.draw2d.IFigure.NoInsetsNested 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_TOGGLEFields inherited from class org.eclipse.draw2d.Figure
bgColor, border, bounds, fgColor, flags, font, maxSize, minSize, NO_MANAGER, prefSize, toolTipFields inherited from interface org.eclipse.draw2d.IFigure
MAX_DIMENSION, MIN_DIMENSION, NO_INSETS -
Constructor Summary
ConstructorsConstructorDescriptionContextButton(String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad) Creates a new ContextButton. -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(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.PathcreatePath(int shrinkLines) Creates and returns the path, which defines the outer lines and filling area of the context button.final ContextButtonPadReturns theContextButtonPadwhich is used to access the environment (editor, ...).final DiagramBehaviorReturns theIDiagramContainerUIfor which the context button is displayed.final org.eclipse.gef.EditPartReturns theEditPartfor which the context button is displayed.final ContextButtonEntrygetEntry()Returns theContextButtonEntrywhich contains the logical and identifying information for the context button (command, name, image, ...).final PositionedContextButtonReturns thePositionedContextButtonwhich contains the visual information for the context button (colors, position, size, opacity, ...)final doubleReturns the zoom-level for which the context-button shall be painted.voidhandleMouseEntered(org.eclipse.draw2d.MouseEvent event) Changes the opacity of the context button.voidhandleMouseExited(org.eclipse.draw2d.MouseEvent event) Changes the opacity of the context button.voidhandleMousePressed(org.eclipse.draw2d.MouseEvent event) Changes the opacity of the context button.voidhandleMouseReleased(org.eclipse.draw2d.MouseEvent event) Changes the opacity of the context button.voidmouseDragged(org.eclipse.draw2d.MouseEvent me) Creates a connection with the connection-tool when dragging the context button.voidmouseEntered(org.eclipse.draw2d.MouseEvent me) voidmouseExited(org.eclipse.draw2d.MouseEvent me) voidmouseHover(org.eclipse.draw2d.MouseEvent me) voidmouseMoved(org.eclipse.draw2d.MouseEvent me) protected voidpaintFigure(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, unhookEventHandlerMethods 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
-
Constructor Details
-
ContextButton
public ContextButton(String providerId, PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad) Creates a new ContextButton.- Parameters:
providerId-positionedContextButton- ThePositionedContextButtoncontains the visual information for the context button (colors, position, size, opacity, ...). It also provides access to theContextButtonEntry.contextButtonPad- TheContextButtonPadis used to access the environment (editor, ...).
-
-
Method Details
-
getPositionedContextButton
Returns thePositionedContextButtonwhich contains the visual information for the context button (colors, position, size, opacity, ...)- Returns:
- The
PositionedContextButtonwhich contains the visual information for the context button (colors, position, size, opacity, ...)
-
getEntry
Returns theContextButtonEntrywhich contains the logical and identifying information for the context button (command, name, image, ...). It is set in the constructor.- Returns:
- The
ContextButtonEntrywhich contains the logical and identifying information for the context button (command, name, image, ...). It is set in the constructor.
-
getContextButtonPad
Returns theContextButtonPadwhich is used to access the environment (editor, ...).- Returns:
- The
ContextButtonPadwhich 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
Returns theIDiagramContainerUIfor which the context button is displayed.- Returns:
- The
IDiagramContainerUIfor which the context button is displayed.
-
getEditPart
public final org.eclipse.gef.EditPart getEditPart()Returns theEditPartfor which the context button is displayed.- Returns:
- The
EditPartfor which the context button is displayed.
-
paintFigure
protected void paintFigure(org.eclipse.draw2d.Graphics graphics) Paints the context button (lines, filling, image, ...).- Overrides:
paintFigurein 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:
handleMouseEnteredin interfaceorg.eclipse.draw2d.IFigure- Overrides:
handleMouseEnteredin classorg.eclipse.draw2d.Figure
-
handleMouseExited
public void handleMouseExited(org.eclipse.draw2d.MouseEvent event) Changes the opacity of the context button.- Specified by:
handleMouseExitedin interfaceorg.eclipse.draw2d.IFigure- Overrides:
handleMouseExitedin 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:
handleMousePressedin interfaceorg.eclipse.draw2d.IFigure- Overrides:
handleMousePressedin 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:
handleMouseReleasedin interfaceorg.eclipse.draw2d.IFigure- Overrides:
handleMouseReleasedin 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:
mouseDraggedin interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseEntered
public void mouseEntered(org.eclipse.draw2d.MouseEvent me) - Specified by:
mouseEnteredin interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseExited
public void mouseExited(org.eclipse.draw2d.MouseEvent me) - Specified by:
mouseExitedin interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseHover
public void mouseHover(org.eclipse.draw2d.MouseEvent me) - Specified by:
mouseHoverin interfaceorg.eclipse.draw2d.MouseMotionListener
-
mouseMoved
public void mouseMoved(org.eclipse.draw2d.MouseEvent me) - Specified by:
mouseMovedin 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:
actionPerformedin interfaceorg.eclipse.draw2d.ActionListener
-