diff -r e8e63152f320 -r 2a9601315dfc javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/TreeItem.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/TreeItem.java Mon May 03 12:27:20 2010 +0300 @@ -0,0 +1,1203 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * Portion Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + * 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: + * IBM Corporation - initial API and implementation + * Nokia Corporation - Qt implementation + *******************************************************************************/ +package org.eclipse.swt.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Internal_GfxPackageSupport; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.qt.OS; + +/** + * Instances of this class represent a selectable user interface object that + * represents a hierarchy of tree items in a tree widget. + * + *
+ * IMPORTANT: This class is not intended to be subclassed. + *
+ */ + +public class TreeItem extends Item { + static Tree checkNull(Tree control) { + if (control == null) + SWT.error(SWT.ERROR_NULL_ARGUMENT); + return control; + } + static TreeItem checkNull(TreeItem item) { + if (item == null) + SWT.error(SWT.ERROR_NULL_ARGUMENT); + return item; + } + + Tree tree; + int itemHandle; + TreeItem parentItem; + TreeItem[] childrenItems; + + int childrenItemCount; + int[] childrenItemsHandle; + Font font; + + Color background; + Color foreground; + boolean grayed; + // Tells if the item has all the data fetched (can be false only in + // SWT.VIRTUAL style Tree) + boolean cached; + + int checkedState; + + boolean selection; + + /** + * Constructs a new instance of this class given its parent (which must be a + *Tree
or a TreeItem
) 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.
+ *
Tree
or a TreeItem
), a style value describing
+ * its behavior and appearance, and the index at which to place it in 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.
+ *
Tree
or a TreeItem
) 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.
+ *
Tree
or a TreeItem
), a style value describing
+ * its behavior and appearance, and the index at which to place it in 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.
+ *
true
if the receiver is checked, and false
+ * otherwise. When the parent does not have the
+ * CHECK style, return false.
+ *
+ *
+ * @return the checked 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
+ *
+ */
+ public boolean getChecked() {
+ checkWidget();
+ if(cached){
+ if (!tree.checkData(this, getParentItem()))
+ error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if ((tree.style & SWT.CHECK) == 0)
+ return false;
+ return OS.QTreeWidgetItem_checkState(internal_itemHandle()) == OS.QT_CHECKED;
+ } else {
+ if(checkedState == OS.QT_CHECKED) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Gets the index of an item.
+ *
+ * -1 is returned if the item is not found from children.
+ *
+ * @param time
+ * the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException
+ *
+ * - ERROR_NULL_ARGUMENT - if the item 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
+ *
+ */
+ int getChildItemIndex(TreeItem item) {
+ if (item == null)
+ error(SWT.ERROR_NULL_ARGUMENT);
+ if (childrenItemCount == 0 || childrenItems == null
+ || item.getParent() != tree)
+ return -1;
+
+ return OS.QTreeWidgetItem_indexOfChild(internal_itemHandle(), item.internal_itemHandle());
+ }
+
+ /**
+ * Returns true
if the receiver is expanded, and false
+ * otherwise.
+ *
+ *
+ * @return the expanded 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
+ *
+ */
+ public boolean getExpanded() {
+ checkWidget();
+ if(cached){
+ if (!tree.checkData(this, getParentItem()))
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ return OS.QTreeWidgetItem_isExpanded(internal_itemHandle());
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the font that the receiver will use to paint textual information
+ * for this item.
+ *
+ * @return the receiver's font
+ *
+ * @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 3.0
+ */
+ public Font getFont() {
+ checkWidget();
+ if(cached){
+ if (!tree.checkData(this, getParentItem()))
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return (this.font == null) ? getParent().getFont() : this.font;
+ }
+
+ /**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @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 2.0
+ *
+ */
+ public Color getForeground() {
+ checkWidget();
+ if(cached){
+ if (!tree.checkData(this, getParentItem()))
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+
+ if (foreground != null)
+ return Internal_GfxPackageSupport.newColor(display, foreground.handle);
+
+ return tree.getForeground();
+ }
+
+ /**
+ * Returns true
if the receiver is grayed, and false otherwise.
+ * When the parent does not have the CHECK style, return false.
+ *
+ *
+ * @return the grayed 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
+ *
+ */
+ public boolean getGrayed() {
+ checkWidget();
+ if(cached){
+ if (!tree.checkData(this, getParentItem()))
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ if ((tree.getStyle() & SWT.CHECK) == 0)
+ return false;
+
+ return grayed;
+ }
+
+
+ TreeItem getItem(int itemHandle) {
+ TreeItem item = null;
+ for (int i = 0; i < childrenItemCount; i++) {
+ if (childrenItemsHandle[i] == itemHandle) {
+ item = _getItem(i);
+ break;
+ } else {
+ item = _getItem(i).getItem(itemHandle);
+ if (item != null)
+ break;
+ }
+ }
+ return item;
+ }
+
+ /**
+ * Returns the number of items contained in the receiver that are direct
+ * item children of the receiver.
+ *
+ * @return the number of items
+ *
+ * @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
+ *
+ */
+ public int getItemCount() {
+ checkWidget();
+ return childrenItemCount;
+ }
+
+ /**
+ * Returns a (possibly empty) array of TreeItem
s which are the
+ * direct item children of the receiver.
+ *
+ * Note: This is not the actual structure used by the receiver to maintain
+ * its list of items, so modifying the array will not affect the receiver.
+ *
+ *
+ * @return the receiver's items
+ *
+ * @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
+ *
+ */
+ public TreeItem[] getItems() {
+ checkWidget();
+ if (childrenItemCount == 0)
+ return new TreeItem[0];
+ TreeItem[] items = new TreeItem[childrenItemCount];
+ if ((tree.getStyle() & SWT.VIRTUAL) != 0) {
+ for (int i = 0; i < childrenItemCount; i++) {
+ items[i] = _getItem(i);
+ tree.checkData(items[i], i);
+ }
+ } else {
+ System.arraycopy(childrenItems, 0, items, 0, childrenItemCount);
+ }
+ return items;
+ }
+
+ /**
+ * Returns the receiver's parent, which must be a Tree
.
+ *
+ * @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
+ *
+ */
+ public Tree getParent() {
+ checkWidget();
+ return tree;
+ }
+
+ /**
+ * Returns the receiver's parent item, which must be a TreeItem
+ * or null when the receiver is a root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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
+ *
+ */
+ public TreeItem getParentItem() {
+ checkWidget();
+ if(parentItem!=null){
+ return parentItem;
+ } else {
+ return null;
+ }
+ }
+
+ void increaseChildrenArraySize(){
+ if (childrenItems == null) {
+ childrenItems = new TreeItem[4];
+ }
+ if (childrenItemCount+1 == childrenItems.length) {
+ int length = Math.max (4, childrenItems.length * 3 / 2);
+ TreeItem [] newItems = new TreeItem [length];
+ System.arraycopy (childrenItems, 0, newItems, 0, childrenItems.length);
+ childrenItems = newItems;
+ }
+
+ if (childrenItemsHandle == null) {
+ childrenItemsHandle = new int[4];
+ }
+ if (childrenItemCount+1 == childrenItemsHandle.length) {
+ int length = Math.max (4, childrenItemsHandle.length * 3 / 2);
+ int [] handles = new int[length];
+ System.arraycopy (childrenItemsHandle, 0, handles, 0,
+ childrenItemsHandle.length);
+ childrenItemsHandle = handles;
+ }
+ }
+
+ public int indexOf(TreeItem item){
+ checkWidget();
+ return getChildItemIndex(item);
+ }
+
+ public int internal_itemHandle() {
+ return itemHandle;
+ }
+
+ public boolean isDisposed() {
+ if (tree != null && (tree.style & SWT.VIRTUAL) == 0) {
+ if (itemHandle == 0)
+ return true;
+ }
+ return super.isDisposed();
+ }
+
+ boolean isLastItemOfLastChild(){
+ boolean traverse = false;
+ if(parentItem != null ){
+ if ((parentItem.childrenItems[parentItem.childrenItemCount-1]== this)){
+ traverse = parentItem.isLastItemOfLastChild();
+ }
+ } else {
+ if (tree.topLevelItems[tree.topLevelItemCount-1] == this){
+ traverse = true;
+ } else {
+ traverse = false;
+ }
+ }
+ return traverse;
+ }
+
+ void releaseChildren_pp(boolean destroy) {
+ if (childrenItems != null) {
+ for (int i = childrenItemCount-1; i >= 0; i--) {
+ TreeItem item = _getItem(i);
+
+ if (item != null && !item.isDisposed()) {
+ item.release(destroy);
+ }
+ }
+ }
+ }
+
+ void releaseHandle_pp() {
+
+ if(tree !=null){
+ int newItemHandle = internal_itemHandle();
+ if((tree.getStyle() & SWT.VIRTUAL)!=0 && !cached){
+ newItemHandle = _getItemHandle();
+ }
+
+ if(cached || ((tree.getStyle() & SWT.VIRTUAL)!=0 && !cached)){
+ if(getParentItem() != null){
+ int index = OS.QTreeWidgetItem_indexOfChild(parentItem.internal_itemHandle(),
+ newItemHandle);
+
+ OS.QTreeWidgetItem_removeChild(parentItem.internal_itemHandle(), newItemHandle);
+
+ int[] newHandles = new int[parentItem.childrenItemsHandle.length - 1];
+ System.arraycopy (parentItem.childrenItemsHandle, 0, newHandles, 0, index);
+ System.arraycopy (parentItem.childrenItemsHandle, index + 1, newHandles,
+ index, newHandles.length - index);
+ parentItem.childrenItemsHandle = newHandles;
+
+ TreeItem[] newItems = new TreeItem [parentItem.childrenItems.length - 1];
+ System.arraycopy (parentItem.childrenItems, 0, newItems, 0, index);
+ System.arraycopy (parentItem.childrenItems, index + 1, newItems, index,
+ newItems.length - index);
+
+ parentItem.childrenItems = newItems;
+ parentItem.childrenItemCount--;
+ } else {
+ int index = OS.QTreeWidget_indexOfTopLevelItem(tree.topHandle,
+ newItemHandle);
+
+ OS.QTreeWidget_takeTopLevelItem(tree.topHandle, index);
+
+ int[] newHandles = new int[tree.topLevelItemsHandle.length - 1];
+ System.arraycopy (tree.topLevelItemsHandle, 0, newHandles, 0, index);
+ System.arraycopy (tree.topLevelItemsHandle, index + 1, newHandles,
+ index, newHandles.length - index);
+ tree.topLevelItemsHandle = newHandles;
+
+ TreeItem[] newItems = new TreeItem [tree.topLevelItems.length - 1];
+ System.arraycopy (tree.topLevelItems, 0, newItems, 0, index);
+ System.arraycopy (tree.topLevelItems, index + 1, newItems,
+ index, newItems.length - index);
+
+ tree.topLevelItems = newItems;
+ tree.topLevelItemCount--;
+ }
+ }
+ }
+ childrenItemCount = 0;
+ childrenItems = null;
+ childrenItemsHandle = null;
+ itemHandle = 0;
+ parentItem = null;
+ tree = null;
+ cached = false;
+ super.releaseHandle_pp();
+ }
+
+ void releaseWidget_pp() {
+ super.releaseWidget_pp();
+ font = null;
+ background = null;
+ foreground = null;
+ checkedState = OS.QT_UNCHECKED;
+ selection = false;
+ }
+
+ void remove (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ if (!(0 <= start && start <= end && end < childrenItemCount)) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+
+ int index = end;
+ while (index >= start) {
+ TreeItem item = _getItem(index);
+ if (item != null && !item.isDisposed ()) {
+ item.release(false);
+ }
+ index--;
+ }
+ }
+
+ /**
+ * Sets the receiver's background color to the color specified by the
+ * argument, or to the default system color for the item if the argument is
+ * null.
+ *
+ * @param color
+ * the new color (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ * - ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
+ * @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 2.0
+ *
+ */
+ public void setBackground(Color color) {
+ checkWidget();
+ if (color != null && color.isDisposed()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if(color == null) {
+ background = null;
+ } else {
+ // Store a copy
+ background = Internal_GfxPackageSupport.newColor(display, color.handle);
+ }
+
+ if(cached){
+ Color itemBg = getBackground();
+ boolean restore = (itemBg == null);
+ int red = itemBg != null ? itemBg.getRed() : 0;
+ int green = itemBg != null ? itemBg.getGreen() : 0;
+ int blue = itemBg != null ? itemBg.getBlue() : 0;
+ OS.QTreeWidgetItem_swt_setBackground(internal_itemHandle(), red, green, blue, restore);
+ }
+ }
+
+ /**
+ * Sets the checked state of the receiver.
+ *
+ *
+ * @param checked
+ * the new checked 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
+ *
+ */
+ public void setChecked(boolean checked) {
+ checkWidget();
+ if ((tree.getStyle() & SWT.CHECK) == 0)
+ return;
+ checkedState = checked ? OS.QT_CHECKED : OS.QT_UNCHECKED;
+ if(cached){
+ OS.QTreeWidgetItem_setCheckState(internal_itemHandle(), checkedState);
+ }
+ }
+
+ /**
+ * Sets the expanded state of the receiver.
+ *
+ *
+ * @param expanded
+ * the new expanded 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
+ *
+ */
+ public void setExpanded(boolean expanded) {
+ checkWidget();
+ if(cached){
+ if (childrenItemCount == 0)
+ return;
+ tree.ignoreExpandEvent = true;
+ OS.QTreeWidgetItem_setExpanded(internal_itemHandle(), expanded);
+ tree.ignoreExpandEvent = false;
+ }
+ }
+
+ /**
+ * Sets the font that the receiver will use to paint textual information for
+ * this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font
+ * the new font (or null)
+ *
+ * @exception IllegalArgumentException
+ *
+ * - ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
+ * @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 3.0
+ */
+ public void setFont(Font font) {
+ checkWidget();
+ if (font != null && font.isDisposed())
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ Font oldFont = this.font;
+ if (oldFont == font)
+ return;
+ this.font = font;
+ if (oldFont != null && oldFont.equals(font))
+ return;
+
+ int fontHandle = font != null ? font.handle : 0;
+ if(cached){
+ OS.QTreeWidgetItem_swt_setFont(internal_itemHandle(), fontHandle);
+ tree.updateColumnWidth();
+ }
+ }
+
+ /**
+ * Sets the receiver's foreground color to the color specified by the
+ * argument, or to the default system color for the item if the argument is
+ * null.
+ *
+ * @param color
+ * the new color (or null)
+ *
+ * @since 2.0
+ *
+ * @exception IllegalArgumentException
+ *
+ * - ERROR_INVALID_ARGUMENT - if the argument has been
+ * disposed
+ *
+ * @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 2.0
+ *
+ */
+ public void setForeground(Color color) {
+ checkWidget();
+ if (color != null && color.isDisposed()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if(color == null) {
+ foreground = null;
+ } else {
+ // Store a copy
+ foreground = Internal_GfxPackageSupport.newColor(display, color.handle);
+ }
+
+ if(cached){
+ Color itemFg = getForeground();
+ boolean restore = (itemFg == null);
+ int red = itemFg != null ? itemFg.getRed() : 0;
+ int green = itemFg != null ? itemFg.getGreen() : 0;
+ int blue = itemFg != null ? itemFg.getBlue() : 0;
+ OS.QTreeWidgetItem_swt_setForeground(internal_itemHandle(), red, green, blue, restore);
+ }
+ }
+
+ /**
+ * Sets the grayed state of the receiver.
+ *
+ *
+ * @param grayed
+ * the new grayed 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
+ *
+ */
+ public void setGrayed(boolean grayed) {
+ checkWidget();
+ if ((tree.getStyle() & SWT.CHECK) == 0)
+ return;
+ this.grayed = grayed;
+ }
+
+ /**
+ * Sets the receiver's image.
+ *
+ * @param image
+ * the new image
+ *
+ * @exception IllegalArgumentException
+ *
+ * - ERROR_INVALID_ARGUMENT - if the image has been
+ * disposed
+ *
+ * @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 3.1
+ */
+ public void setImage(Image image) {
+ checkWidget();
+ if(cached){
+ if (image != null && image.isDisposed())
+ error(SWT.ERROR_INVALID_ARGUMENT);
+ if (image != null) {
+ OS.QTreeWidgetItem_setIcon(internal_itemHandle(),
+ Internal_GfxPackageSupport.getIconHandle(image));
+ } else {
+ OS.QTreeWidgetItem_setIcon(internal_itemHandle(),
+ Internal_GfxPackageSupport.getNullIconHandle());
+ }
+ }
+ super.setImage(image);
+ }
+
+ /**
+ * Sets the number of items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @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 3.0
+ */
+ public void setItemCount (int count) {
+ checkWidget ();
+ count = Math.max (0, count);
+ if (count == childrenItemCount) return;
+ boolean isVirtual = (tree.style & SWT.VIRTUAL) != 0;
+ if (!isVirtual) tree.setRedraw (false);
+ int oldItemCount = childrenItemCount;
+ remove (count, childrenItemCount - 1);
+ int length = Math.max (4, (count + 3) / 4 * 4);
+ TreeItem [] newItems = new TreeItem [length];
+ if(childrenItems == null){
+ childrenItems = new TreeItem[count];
+ }
+ System.arraycopy (childrenItems, 0, newItems, 0, childrenItemCount);
+ childrenItems = newItems;
+ if (isVirtual) {
+ if(oldItemCount
+ * ERROR_NULL_ARGUMENT - if the text 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
+ *
+ *
+ * @since 3.1
+ */
+ public void setText(String string) {
+ checkWidget();
+ if (string == null)
+ error(SWT.ERROR_NULL_ARGUMENT);
+ if (string.equals(text))
+ return;
+ super.setText(string);
+ if(cached) {
+ OS.QTreeWidgetItem_setText(this.itemHandle, string);
+ tree.updateColumnWidth();
+ }
+ }
+}