package org.eclipse.swt.widgets; | |
/* | |
* (c) Copyright IBM Corp. 2000, 2001. | |
* All Rights Reserved | |
*/ | |
import org.eclipse.swt.*; | |
import org.eclipse.swt.graphics.*; | |
/** | |
* This class is the abstract superclass of all non-windowed | |
* user interface objects that occur within specific | |
* controls. For example, a tree will contain tree | |
* items. | |
*/ | |
public abstract class Item extends Widget { | |
String text; | |
Image image; | |
public Item (Widget parent, int style) { | |
super (parent, style); | |
text = ""; | |
} | |
public Item (Widget parent, int style, int index) { | |
this (parent, style); | |
} | |
protected void checkSubclass () { | |
/* Do Nothing - Subclassing is allowed */ | |
} | |
/** | |
* Returns the receiver's image if it has one, or null | |
* if it does not. | |
* | |
* @return the receiver's image | |
* | |
* @exception SWTException <ul> | |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
* </ul> | |
*/ | |
public Image getImage () { | |
checkWidget (); | |
return image; | |
} | |
String getNameText () { | |
return getText (); | |
} | |
/** | |
* Returns the receiver's text, which will be an empty | |
* string if it has never been set. | |
* | |
* @return the receiver's text | |
* | |
* @exception SWTException <ul> | |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
* </ul> | |
*/ | |
public String getText () { | |
checkWidget(); | |
return text; | |
} | |
void releaseWidget () { | |
super.releaseWidget (); | |
text = null; | |
image = null; | |
} | |
/** | |
* Sets the receiver's image to the argument, which may be | |
* null indicating that no image should be displayed. | |
* | |
* @param image the image to display on the receiver (may be null) | |
* | |
* @exception SWTException <ul> | |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
* </ul> | |
*/ | |
public void setImage (Image image) { | |
checkWidget (); | |
this.image = image; | |
} | |
/** | |
* Sets the receiver's text. | |
* | |
* @param string the new text | |
* | |
* @exception IllegalArgumentException <ul> | |
* <li>ERROR_NULL_ARGUMENT - if the text is null</li> | |
* </ul> | |
* @exception SWTException <ul> | |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
* </ul> | |
*/ | |
public void setText (String string) { | |
checkWidget (); | |
text = string; | |
} | |
} |