Class BreadcrumbItem
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Item
-
- org.eclipse.nebula.widgets.opal.breadcrumb.BreadcrumbItem
-
public class BreadcrumbItem extends org.eclipse.swt.widgets.ItemInstances of this class represent a selectable user interface object that represents an item of a breadcrumb.- Styles:
- TOGGLE,PUSH,NONE
- Events:
- Selection
-
-
Field Summary
Fields Modifier and Type Field Description private intalignmentprivate org.eclipse.swt.graphics.Rectangleboundsprivate org.eclipse.swt.graphics.ImagedisabledImageprivate booleanenabledprivate org.eclipse.swt.graphics.GCgcprivate intheightprivate booleanisLastItemOfTheBreadCrumbprivate static intMARGINprivate static intMIN_WIDTHprivate BreadcrumbparentBreadcrumbprivate static org.eclipse.swt.graphics.ColorSELECTED_COLORprivate booleanselectionprivate org.eclipse.swt.graphics.ImageselectionImageprivate java.util.List<org.eclipse.swt.events.SelectionListener>selectionListenersprivate org.eclipse.swt.graphics.ColortextColorprivate org.eclipse.swt.graphics.ColortextColorSelectedprivate inttoolbarHeightprivate java.lang.StringtooltipTextprivate intwidth
-
Constructor Summary
Constructors Constructor Description BreadcrumbItem(Breadcrumb parent)Constructs a new instance of this class given its parent (which must be aBreadcrumb) and a style value describing its behavior and appearance.BreadcrumbItem(Breadcrumb parent, int style)Constructs a new instance of this class given its parent (which must be aBreadcrumb) and a style value describing its behavior and appearance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSelectionListener(org.eclipse.swt.events.SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListenerinterface.private static intcheckBits(int style, int int0, int int1, int int2)private static intcheckStyle(int style)private org.eclipse.swt.graphics.PointcomputeDefaultSize()private intcomputeGap()private org.eclipse.swt.graphics.PointcomputeMaxWidthAndHeightForImages(org.eclipse.swt.graphics.Image... images)private org.eclipse.swt.graphics.PointcomputeSizeOfTextAndImages()voiddispose()private voiddrawBackgroundAtPosition(int x)(package private) voiddrawButtonAtPosition(int x)private org.eclipse.swt.graphics.ImagedrawImageAtPosition(int xPosition)private voiddrawTextAtPosition(int xPosition)private voiddrawTriangleAtPosition(int x)private voiddrawTrianglesAtPosition(int x)(package private) voidfireSelectionEvent()intgetAlignment()Returns a value which describes the position of the text in the receiver.org.eclipse.swt.graphics.RectanglegetBounds()Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell.org.eclipse.swt.graphics.ImagegetDisabledImage()booleangetEnabled()Returnstrueif the receiver is enabled, andfalseotherwise.intgetHeight()Returns the whole height of the item.BreadcrumbgetParent()Returns the receiver's parent, which must be aBreadcrumb.booleangetSelection()Returnstrueif the receiver is selected, and false otherwise.org.eclipse.swt.graphics.ImagegetSelectionImage()org.eclipse.swt.graphics.ColorgetTextColor()Returns the color of the text when the button is enabled and not selected.org.eclipse.swt.graphics.ColorgetTextColorSelected()Returns the color of the text when the button is not selected.java.lang.StringgetTooltipText()Returns the receiver's tool tip text, or null if it has not been set.intgetWidth()Returns the whole width of the item.booleanisEnabled()Returnstrueif the receiver is enabled, andfalseotherwise.voidremoveSelectionListener(org.eclipse.swt.events.SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the control is selected by the user.voidsetAlignment(int alignment)Controls how text will be displayed in the receiver.voidsetBounds(org.eclipse.swt.graphics.Rectangle rectangle)Sets the receiver's size and location to the rectangular area specified by the argument.voidsetDisabledImage(org.eclipse.swt.graphics.Image image)Sets the receiver's image to the argument when this is one is disabled, which may be null indicating that no image should be displayed.voidsetEnabled(boolean enabled)Enables the receiver if the argument istrue, and disables it otherwise.(package private) BreadcrumbItemsetGc(org.eclipse.swt.graphics.GC gc)voidsetHeight(int height)Sets the height of the receiver.(package private) BreadcrumbItemsetIsLastItemOfTheBreadCrumb(boolean isLastItemOfTheBreadCrumb)voidsetSelection(boolean selected)Sets the selection state of the receiver.voidsetSelectionImage(org.eclipse.swt.graphics.Image image)Sets the receiver's image to the argument when this one is selected, which may be null indicating that no image should be displayed.voidsetTextColor(org.eclipse.swt.graphics.Color textColor)Sets the receiver's text color to the argument, which may be null indicating that no image should be displayed.voidsetTextColorSelected(org.eclipse.swt.graphics.Color textColor)Sets the receiver's text color to the argument when this one is selected, which may be null indicating that no image should be displayed.(package private) BreadcrumbItemsetToolbarHeight(int toolbarHeight)voidsetTooltipText(java.lang.String string)Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.voidsetWidth(int width)Sets the width of the receiver.-
Methods inherited from class org.eclipse.swt.widgets.Item
checkSubclass, getImage, getText, setImage, setText
-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
-
-
-
-
Field Detail
-
MIN_WIDTH
private static final int MIN_WIDTH
- See Also:
- Constant Field Values
-
MARGIN
private static final int MARGIN
- See Also:
- Constant Field Values
-
SELECTED_COLOR
private static org.eclipse.swt.graphics.Color SELECTED_COLOR
-
parentBreadcrumb
private final Breadcrumb parentBreadcrumb
-
selectionListeners
private final java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners
-
bounds
private org.eclipse.swt.graphics.Rectangle bounds
-
enabled
private boolean enabled
-
selection
private boolean selection
-
width
private int width
-
height
private int height
-
disabledImage
private org.eclipse.swt.graphics.Image disabledImage
-
selectionImage
private org.eclipse.swt.graphics.Image selectionImage
-
alignment
private int alignment
-
textColorSelected
private org.eclipse.swt.graphics.Color textColorSelected
-
textColor
private org.eclipse.swt.graphics.Color textColor
-
tooltipText
private java.lang.String tooltipText
-
gc
private org.eclipse.swt.graphics.GC gc
-
toolbarHeight
private int toolbarHeight
-
isLastItemOfTheBreadCrumb
private boolean isLastItemOfTheBreadCrumb
-
-
Constructor Detail
-
BreadcrumbItem
public BreadcrumbItem(Breadcrumb parent)
Constructs a new instance of this class given its parent (which must be aBreadcrumb) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.The style value is either one of the style constants defined in class
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent- a composite control which will be the parent of the new instance (cannot be null)- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
Widget.getStyle()
-
BreadcrumbItem
public BreadcrumbItem(Breadcrumb parent, int style)
Constructs a new instance of this class given its parent (which must be aBreadcrumb) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.The style value is either one of the style constants defined in class
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent- a composite control which will be the parent of the new instance (cannot be null)style- the style of control to construct- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- See Also:
Widget.getStyle()
-
-
Method Detail
-
checkStyle
private static int checkStyle(int style)
-
checkBits
private static int checkBits(int style, int int0, int int1, int int2)
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in theSelectionListenerinterface.widgetDefaultSelectedis not called.- Parameters:
listener- the listener which should be notified when the control is selected by the user,- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener,removeSelectionListener(org.eclipse.swt.events.SelectionListener),SelectionEvent
-
dispose
public void dispose()
- Overrides:
disposein classorg.eclipse.swt.widgets.Widget- See Also:
Widget.dispose()
-
getAlignment
public int getAlignment()
Returns a value which describes the position of the text in the receiver. The value will be one ofLEFT,RIGHTorCENTER.- Returns:
- the alignment
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getBounds
public org.eclipse.swt.graphics.Rectangle getBounds()
Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell. In this case, the location is relative to the display.- Returns:
- the receiver's bounding rectangle
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getDisabledImage
public org.eclipse.swt.graphics.Image getDisabledImage()
- Returns:
- the image displayed when the button is disabled
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getEnabled
public boolean getEnabled()
Returnstrueif the receiver is enabled, andfalseotherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
isEnabled()
-
getHeight
public int getHeight()
Returns the whole height of the item.- Returns:
- the receiver's height
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
computeDefaultSize
private org.eclipse.swt.graphics.Point computeDefaultSize()
- Returns:
- the default size of the item
-
getParent
public Breadcrumb getParent()
Returns the receiver's parent, which must be aBreadcrumb.- Returns:
- the receiver's parent
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelection
public boolean getSelection()
Returnstrueif the receiver is selected, and false otherwise.- Returns:
- the selection state
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSelectionImage
public org.eclipse.swt.graphics.Image getSelectionImage()
- Returns:
- the image displayed when the button is selected
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTextColor
public org.eclipse.swt.graphics.Color getTextColor()
Returns the color of the text when the button is enabled and not selected.- Returns:
- the receiver's text color
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTextColorSelected
public org.eclipse.swt.graphics.Color getTextColorSelected()
Returns the color of the text when the button is not selected.- Returns:
- the receiver's text color
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getTooltipText
public java.lang.String getTooltipText()
Returns the receiver's tool tip text, or null if it has not been set.- Returns:
- the receiver's tool tip text
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getWidth
public int getWidth()
Returns the whole width of the item.- Returns:
- the receiver's height
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
isEnabled
public boolean isEnabled()
Returnstrueif the receiver is enabled, andfalseotherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Returns:
- the receiver's enabled state
- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
getEnabled()
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected by the user.- Parameters:
listener- the listener which should no longer be notified- Throws:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- See Also:
SelectionListener,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
setAlignment
public void setAlignment(int alignment)
Controls how text will be displayed in the receiver. The argument should be one ofLEFT,RIGHTorCENTER.- Parameters:
alignment- the new alignment- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setBounds
public void setBounds(org.eclipse.swt.graphics.Rectangle rectangle)
Sets the receiver's size and location to the rectangular area specified by the argument. Thexandyfields of the rectangle are relative to the receiver's parent (or its display if its parent is null).Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.
- Parameters:
rect- the new bounds for the receiver- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setDisabledImage
public void setDisabledImage(org.eclipse.swt.graphics.Image image)
Sets the receiver's image to the argument when this is one is disabled, which may be null indicating that no image should be displayed.- Parameters:
image- the image to display on the receiver (may be null)- Throws:
java.lang.IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the image has been disposed
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setEnabled
public void setEnabled(boolean enabled)
Enables the receiver if the argument istrue, and disables it otherwise.A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.
- Parameters:
enabled- the new enabled state- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setHeight
public void setHeight(int height)
Sets the height of the receiver.Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.
- Parameters:
height- the new width- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelection
public void setSelection(boolean selected)
Sets the selection state of the receiver.- Parameters:
selected- the new selection state- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSelectionImage
public void setSelectionImage(org.eclipse.swt.graphics.Image image)
Sets the receiver's image to the argument when this one is selected, which may be null indicating that no image should be displayed.- Parameters:
image- the image to display on the receiver (may be null)- Throws:
java.lang.IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the image has been disposed
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTextColor
public void setTextColor(org.eclipse.swt.graphics.Color textColor)
Sets the receiver's text color to the argument, which may be null indicating that no image should be displayed.- Parameters:
textColor- the text color to display on the receiver (may be null)- Throws:
java.lang.IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the image has been disposed
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTextColorSelected
public void setTextColorSelected(org.eclipse.swt.graphics.Color textColor)
Sets the receiver's text color to the argument when this one is selected, which may be null indicating that no image should be displayed.- Parameters:
textColor- the text color to display on the receiver (may be null)- Throws:
java.lang.IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the image has been disposed
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTooltipText
public void setTooltipText(java.lang.String string)
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.
- Parameters:
string- the new tool tip text (or null)- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setWidth
public void setWidth(int width)
Sets the width of the receiver.Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.
- Parameters:
width- the new width- Throws:
org.eclipse.swt.SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
fireSelectionEvent
void fireSelectionEvent()
-
drawButtonAtPosition
void drawButtonAtPosition(int x)
-
drawBackgroundAtPosition
private void drawBackgroundAtPosition(int x)
-
drawTrianglesAtPosition
private void drawTrianglesAtPosition(int x)
-
drawTriangleAtPosition
private void drawTriangleAtPosition(int x)
-
computeGap
private int computeGap()
-
computeSizeOfTextAndImages
private org.eclipse.swt.graphics.Point computeSizeOfTextAndImages()
-
computeMaxWidthAndHeightForImages
private org.eclipse.swt.graphics.Point computeMaxWidthAndHeightForImages(org.eclipse.swt.graphics.Image... images)
-
drawImageAtPosition
private org.eclipse.swt.graphics.Image drawImageAtPosition(int xPosition)
-
drawTextAtPosition
private void drawTextAtPosition(int xPosition)
-
setGc
BreadcrumbItem setGc(org.eclipse.swt.graphics.GC gc)
-
setToolbarHeight
BreadcrumbItem setToolbarHeight(int toolbarHeight)
-
setIsLastItemOfTheBreadCrumb
BreadcrumbItem setIsLastItemOfTheBreadCrumb(boolean isLastItemOfTheBreadCrumb)
-
-