org.eclipse.swt.widgets.TrayItem Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2010, 2012 EclipseSource and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* EclipseSource - initial API and implementation
******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
/**
* Instances of this class represent icons that can be placed on the system tray
* or task bar status area.
*
*
* - Styles:
* - (none)
* - Events:
* - DefaultSelection, MenuDetect, Selection
*
*
*
* IMPORTANT: This class is not intended to be subclassed.
*
*
* @since 1.4
*/
public class TrayItem extends Item {
private Tray parent;
/**
* Constructs a new instance of this class given its parent (which must be a
* Tray
) 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
* SWT
which is applicable to instances of this class, or must be
* built by bitwise OR'ing together (that is, using the
* int
"|" operator) two or more of those SWT
style
* constants. The class description lists the style constants that are
* applicable to the class. Style bits are also inherited from superclasses.
*
*
* @param parent a composite control which will be the parent of the new
* instance (cannot be null)
* @param style the style of control to construct
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the parent is null
*
* @exception 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 SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
* @since 1.4
*/
public TrayItem( Tray parent, int style ) {
super( parent, style );
if( parent == null ) {
SWT.error( SWT.ERROR_NULL_ARGUMENT );
}
this.parent = parent;
checkWidget();
}
/**
* Returns the receiver's parent, which must be a Tray
.
*
* @return the receiver's parent
*
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
* @since 1.4
*/
public Tray getParent() {
checkWidget ();
return parent;
}
/**
* Adds the listener to the collection of listeners who will be notified when
* the receiver is selected by the user, by sending it one of the messages
* defined in the SelectionListener
interface.
*
* widgetSelected
is called when the receiver is selected
* widgetDefaultSelected
is called when the receiver is
* double-clicked
*
*
* @param listener the listener which should be notified when the receiver is
* selected by the user
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
*
* @exception 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 SelectionListener
* @see #removeSelectionListener
* @see SelectionEvent
* @since 1.4
*/
public void addSelectionListener( SelectionListener listener ) {
checkWidget();
if( listener == null ) {
SWT.error( SWT.ERROR_NULL_ARGUMENT );
}
}
/**
* Returns the receiver's tool tip text, or null if it has not been set.
*
* @return the receiver's tool tip text
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver
*
* @since 1.4
*/
public String getToolTipText() {
checkWidget();
return null;
}
/**
* Returns true
if the receiver is visible and false
* otherwise.
*
* @return the receiver's visibility
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver
*
* @since 1.4
*/
public boolean getVisible() {
checkWidget();
return true;
}
/**
* Removes the listener from the collection of listeners who will be notified
* when the receiver is selected by the user.
*
* @param listener the listener which should no longer be notified
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
*
* @exception 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 SelectionListener
* @see #addSelectionListener
* @since 1.4
*/
public void removeSelectionListener( SelectionListener listener ) {
checkWidget();
if( listener == null ) {
error( SWT.ERROR_NULL_ARGUMENT );
}
}
/**
* Sets the receiver's tool tip text to the argument, which may be null
* indicating that no tool tip text should be shown.
*
* @param value the new tool tip text (or null)
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver
*
* @since 1.4
*/
public void setToolTipText( String value ) {
checkWidget();
}
/**
* Makes the receiver visible if the argument is true
, and makes
* it invisible otherwise.
*
* @param visible the new visibility state
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver
*
* @since 1.4
*/
public void setVisible( boolean visible ) {
checkWidget();
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the platform-specific context menu trigger
* has occurred, by sending it one of the messages defined in
* the MenuDetectListener
interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
*
* @exception 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 MenuDetectListener
* @see #removeMenuDetectListener
*
* @since 1.4
*/
public void addMenuDetectListener( MenuDetectListener listener ) {
checkWidget();
if( listener == null ) {
error( SWT.ERROR_NULL_ARGUMENT );
}
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the platform-specific context menu trigger has
* occurred.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException
* - ERROR_NULL_ARGUMENT - if the listener is null
*
* @exception 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 MenuDetectListener
* @see #addMenuDetectListener
*
* @since 1.4
*/
public void removeMenuDetectListener( MenuDetectListener listener ) {
checkWidget();
if( listener == null ) {
error( SWT.ERROR_NULL_ARGUMENT );
}
}
/**
* Sets the receiver's tool tip to the argument, which
* may be null indicating that no tool tip should be shown.
*
* @param toolTip the new tool tip (or null)
*
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
* @since 1.4
*/
public void setToolTip( ToolTip toolTip ) {
checkWidget();
}
/**
* Returns the receiver's tool tip, or null if it has
* not been set.
*
* @return the receiver's tool tip text
*
* @exception SWTException
* - ERROR_WIDGET_DISPOSED - if the receiver has been disposed
* - ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*
* @since 1.4
*/
public ToolTip getToolTip() {
checkWidget();
return null;
}
}