/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.internal.wpf.*; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; /** * Instances of this class represent a selectable user interface object * that represents a hierarchy of tree items in a tree widget. * *
*
Styles:
*
(none)
*
Events:
*
(none)
*
*

* IMPORTANT: This class is not intended to be subclassed. *

*/ public class TreeItem extends Item { Tree parent; Image [] images; int itemCount; int stringList, imageList, foregroundList, backgroundList, fontList, checkState; boolean checked, grayed, cached, ignoreNotify; /** * 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. *

* * @param parent a tree control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentException * @exception SWTException * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TreeItem (Tree parent, int style) { this (checkNull (parent), null, style, parent.itemCount, 0); } /** * Constructs a new instance of this class given its parent * (which must be a 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. *

* * @param parent a tree control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * @param index the zero-relative index to store the receiver in its parent * * @exception IllegalArgumentException * @exception SWTException * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TreeItem (Tree parent, int style, int index) { this (checkNull (parent), null, style, index, 0); } /** * 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. *

* * @param parentItem a tree control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentException * @exception SWTException * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TreeItem (TreeItem parentItem, int style) { this (checkNull (parentItem).parent, parentItem, style, parentItem.itemCount, 0); } /** * Constructs a new instance of this class given its parent * (which must be a 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. *

* * @param parentItem a tree control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * @param index the zero-relative index to store the receiver in its parent * * @exception IllegalArgumentException * @exception SWTException * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TreeItem (TreeItem parentItem, int style, int index) { this (checkNull (parentItem).parent, parentItem, style, index, 0); } TreeItem (Tree parent, TreeItem parentItem, int style, int index, int handle) { super (parent, style); this.parent = parent; this.handle = handle; if (handle == 0) { parent.createItem (this, parentItem, index); } else { createWidget (); } } static Tree checkNull (Tree tree) { if (tree == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return tree; } static TreeItem checkNull (TreeItem item) { if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return item; } protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } void clear () { text = ""; image = null; images = null; checked = grayed = false; updateCheckState (false); if (stringList != 0) OS.GCHandle_Free (stringList); stringList = 0; if (imageList != 0) OS.GCHandle_Free (imageList); imageList = 0; // background = foreground = font = -1; // cellBackground = cellForeground = cellFont = null; if ((parent.style & SWT.VIRTUAL) != 0) cached = false; if (ignoreNotify) return; int row; if (parent.columnCount == 0) { row = OS.HeaderedItemsControl_Header (handle); } else { int header = OS.HeaderedItemsControl_Header (handle); row = OS.GridViewRowPresenter_Content (header); OS.GCHandle_Free (header); } OS.SWTRow_NotifyPropertyChanged (row, Tree.TEXT_NOTIFY); OS.SWTRow_NotifyPropertyChanged (row, Tree.IMAGE_NOTIFY); OS.GCHandle_Free (row); } /** * Clears the item at the given zero-relative index in the receiver. * The text, icon and other attributes of the item are set to the default * value. If the tree was created with the SWT.VIRTUAL style, * these attributes are requested again as needed. * * @param index the index of the item to clear * @param all true if all child items of the indexed item should be * cleared recursively, and false otherwise * * @exception IllegalArgumentException * @exception SWTException * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.2 */ public void clear (int index, boolean all) { checkWidget (); if (index < 0 || index >= itemCount) SWT.error (SWT.ERROR_INVALID_RANGE); parent.clear (handle, index, all); } /** * Clears all the items in the receiver. The text, icon and other * attributes of the items are set to their default values. If the * tree was created with the SWT.VIRTUAL style, these * attributes are requested again as needed. * * @param all true if all child items should be cleared * recursively, and false otherwise * * @exception SWTException * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.2 */ public void clearAll (boolean all) { checkWidget (); parent.clearAll (this, all); } void columnAdded (int index) { if (parent.columnCount == 0) { int headerTemplate = OS.HeaderedItemsControl_HeaderTemplateProperty (); OS.DependencyObject_ClearValue (handle, headerTemplate); OS.GCHandle_Free (headerTemplate); int row = OS.HeaderedItemsControl_Header (handle); int header = OS.gcnew_SWTTreeViewRowPresenter (parent.handle); if (header == 0) error (SWT.ERROR_NO_HANDLES); OS.GridViewRowPresenterBase_Columns (header, parent.columns); OS.HeaderedItemsControl_Header (handle, header); OS.GridViewRowPresenter_Content (header, row); OS.GCHandle_Free (header); OS.GCHandle_Free (row); } else { int newLength = parent.columnCount + 1; if (images != null) { Image [] temp = new Image [newLength]; System.arraycopy (images, 0, temp, 0, index); System.arraycopy (images, index, temp, index + 1, parent.columnCount - index); images = temp; } OS.ArrayList_Insert (stringList, index, 0); if (imageList != 0) OS.ArrayList_Insert (imageList, index, 0); } int items = OS.ItemsControl_Items (handle); for (int i=0; i *
  • 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 getBackground () { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getBackground (); } /** * Returns the background color at the given column index in the receiver. * * @param index the column index * @return the background color * * @exception SWTException * * @since 3.1 */ public Color getBackground (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getBackground (); } /** * Returns a rectangle describing the receiver's size and location * relative to its parent. * * @return the receiver's bounding rectangle * * @exception SWTException */ public Rectangle getBounds () { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); //BUG? if (!OS.UIElement_IsVisible(handle)) return new Rectangle (0, 0, 0, 0); int point = OS.gcnew_Point (0, 0); int location = OS.UIElement_TranslatePoint (handle, point, parent.handle); int x = (int) OS.Point_X (location); int y = (int) OS.Point_Y (location); OS.GCHandle_Free (point); OS.GCHandle_Free (location); int width = (int) OS.FrameworkElement_ActualWidth (handle); int height = (int) OS.FrameworkElement_ActualHeight (handle); return new Rectangle (x, y, width, height); } /** * Returns a rectangle describing the receiver's size and location * relative to its parent at a column in the tree. * * @param index the index that specifies the column * @return the receiver's bounding column rectangle * * @exception SWTException * * @since 3.1 */ public Rectangle getBounds (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0); if (!OS.UIElement_IsVisible (handle)) return new Rectangle (0, 0, 0, 0); updateLayout (handle); int point = OS.gcnew_Point (0, 0); int contentPresenter = findContentPresenter (handle, index); int location = OS.UIElement_TranslatePoint (contentPresenter, point, parent.handle); int x = (int) OS.Point_X (location); int y = (int) OS.Point_Y (location); int width = (int) OS.FrameworkElement_ActualWidth (contentPresenter); int height = (int) OS.FrameworkElement_ActualHeight (contentPresenter); OS.GCHandle_Free (point); OS.GCHandle_Free (location); OS.GCHandle_Free (contentPresenter); return new Rectangle (x, y, width, height); } /** * Returns 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

    */ public boolean getChecked () { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if ((parent.style & SWT.CHECK) == 0) return false; return checked; } /** * Returns true if the receiver is expanded, * and false otherwise. *

    * * @return the expanded state * * @exception SWTException

    */ public boolean getExpanded () { checkWidget (); return OS.TreeViewItem_IsExpanded (handle); } /** * Returns the font that the receiver will use to paint textual information for this item. * * @return the receiver's font * * @exception SWTException * * @since 3.0 */ public Font getFont () { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getFont (); } /** * Returns the font that the receiver will use to paint textual information * for the specified cell in this item. * * @param index the column index * @return the receiver's font * * @exception SWTException * * @since 3.1 */ public Font getFont (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getFont (); } /** * Returns the foreground color that the receiver will use to draw. * * @return the receiver's foreground color * * @exception SWTException * * @since 2.0 * */ public Color getForeground () { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getForeground (); } /** * * Returns the foreground color at the given column index in the receiver. * * @param index the column index * @return the foreground color * * @exception SWTException * * @since 3.1 */ public Color getForeground (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return parent.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 of the checkbox * * @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 (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if ((parent.style & SWT.CHECK) == 0) return false; return false; } /** * Returns the item at the given, zero-relative index in the * receiver. Throws an exception if the index is out of range. * * @param index the index of the item to return * @return the item at the given index * * @exception IllegalArgumentException
      *
    • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
    • *
    * @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 TreeItem getItem (int index) { checkWidget (); if (index < 0 || index >= itemCount) error (SWT.ERROR_INVALID_RANGE); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); int items = OS.ItemsControl_Items (handle); TreeItem item = parent.getItem (items, index, true); OS.GCHandle_Free (items); 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 (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); return itemCount; } /** * Returns a (possibly empty) array of TreeItems 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 (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); int items = OS.ItemsControl_Items (handle); TreeItem [] result = new TreeItem [itemCount]; for (int i = 0; i < result.length; i++) { result [i] = parent.getItem (items, i, true); } OS.GCHandle_Free (items); return result; } public Image getImage () { checkWidget (); return getImage (0); } /** * Returns the image stored at the given column index in the receiver, * or null if the image has not been set or if the column does not exist. * * @param index the column index * @return the image stored at the given column index in the receiver * * @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 Image getImage (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if (images != null) { if (0 <= index && index < images.length) return images [index]; } return null; } /** * Returns a rectangle describing the size and location * relative to its parent of an image at a column in the * tree. * * @param index the index that specifies the column * @return the receiver's bounding image rectangle * * @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 Rectangle getImageBounds (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0); int parentHandle = parent.topHandle (); int part = findPart (index, Tree.IMAGE_PART_NAME); int point = OS.gcnew_Point (0, 0); if (point == 0) error (SWT.ERROR_NO_HANDLES); int location = OS.UIElement_TranslatePoint (part, point, parentHandle); int x = (int) OS.Point_X (location); int y = (int) OS.Point_Y (location); OS.GCHandle_Free (point); OS.GCHandle_Free (location); int width = (int) OS.FrameworkElement_ActualWidth (part); int height = (int) OS.FrameworkElement_ActualHeight (part); OS.GCHandle_Free (part); return new Rectangle (x, y, width, height); } /** * 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 parent; } /** * 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 (); int parentItem = OS.FrameworkElement_Parent (handle); TreeItem result = null; if (!OS.Object_Equals (parentItem, parent.handle)) { result = (TreeItem) display.getWidget (parentItem); } OS.GCHandle_Free (parentItem); return result; } public Rectangle getTextBounds (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0); int parentHandle = parent.topHandle (); int part = findPart (index, Tree.TEXT_PART_NAME); int point = OS.gcnew_Point (0, 0); if (point == 0) error (SWT.ERROR_NO_HANDLES); int location = OS.UIElement_TranslatePoint (part, point, parentHandle); int x = (int) OS.Point_X (location); int y = (int) OS.Point_Y (location); OS.GCHandle_Free (point); OS.GCHandle_Free (location); int width = (int) OS.FrameworkElement_ActualWidth (part); int height = (int) OS.FrameworkElement_ActualHeight (part); OS.GCHandle_Free (part); return new Rectangle (x, y, width, height); } public String getText () { checkWidget (); return getText (0); } /** * Returns the text stored at the given column index in the receiver, * or empty string if the text has not been set. * * @param index the column index * @return the text stored at the given column index in the receiver * * @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 String getText (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); if (stringList != 0) { if (0 <= index && index < OS.ArrayList_Count (stringList)) { int ptr = OS.ArrayList_default (stringList, index); String result = createJavaString (ptr); OS.GCHandle_Free (ptr); return result; } } return ""; } Control getWidgetControl () { return parent; } /** * Searches the receiver's list starting at the first item * (index 0) until an item is found that is equal to the * argument, and returns the index of that item. If no item * is found, returns -1. * * @param item the search item * @return the index of the item * * @exception IllegalArgumentException
      *
    • ERROR_NULL_ARGUMENT - if the tool item is null
    • *
    • ERROR_INVALID_ARGUMENT - if the tool item 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 int indexOf (TreeItem item) { checkWidget (); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); int items = OS.ItemsControl_Items (handle); int index = OS.ItemCollection_IndexOf(items, item.handle); OS.GCHandle_Free (items); return index; } void register () { display.addWidget (handle, this); } void releaseChildren (boolean destroy) { int items = OS.ItemsControl_Items (handle); for (int i=0; i * @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 removeAll () { checkWidget (); int items = OS.ItemsControl_Items (handle); for (int i = 0; i < itemCount; i++) { TreeItem item = parent.getItem (items, i, false); if (item != null && !item.isDisposed ()) item.release (false); } parent.ignoreSelection = true; OS.ItemCollection_Clear (items); parent.ignoreSelection = false; OS.GCHandle_Free (items); } /** * 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); } //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * Sets the background color at the given column index in the receiver * to the color specified by the argument, or to the default system color for the item * if the argument is null. * * @param index the column index * @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 3.1 * */ public void setBackground (int index, Color color) { checkWidget (); if (color != null && color.isDisposed ()) { SWT.error (SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max (1, parent.getColumnCount ()); if (0 > index || index > count - 1) return; //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * 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 ((parent.style & SWT.CHECK) == 0) return; if (this.checked == checked) return; this.checked = checked; if ((parent.style & SWT.VIRTUAL) != 0) cached = true; updateCheckState (true); } /** * 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 (); OS.TreeViewItem_IsExpanded (handle, expanded); } /** * 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); } //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * Sets the font that the receiver will use to paint textual information * for the specified cell in 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 index the column index * @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.1 */ public void setFont (int index, Font font) { checkWidget (); if (font != null && font.isDisposed ()) { SWT.error (SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max (1, parent.getColumnCount ()); if (0 > index || index > count - 1) return; //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * 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); } //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * Sets the foreground color at the given column index in the receiver * to the color specified by the argument, or to the default system color for the item * if the argument is null. * * @param index the column index * @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 3.1 * */ public void setForeground (int index, Color color){ checkWidget (); if (color != null && color.isDisposed ()) { SWT.error (SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max (1, parent.getColumnCount ()); if (0 > index || index > count - 1) return; //TODO if ((parent.style & SWT.VIRTUAL) != 0) cached = true; } /** * Sets the grayed state of the checkbox for this item. This state change * only applies if the Tree was created with the SWT.CHECK style. * * @param grayed the new grayed state of the checkbox * * @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 ((parent.style & SWT.CHECK) == 0) return; if (this.grayed == grayed) return; this.grayed = grayed; if ((parent.style & SWT.VIRTUAL) != 0) cached = true; updateCheckState (true); } /** * Sets the image for multiple columns in the tree. * * @param images the array of new images * * @exception IllegalArgumentException
      *
    • ERROR_NULL_ARGUMENT - if the array of images is null
    • *
    • ERROR_INVALID_ARGUMENT - if one of the images 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 [] images) { checkWidget (); if (images == null) error (SWT.ERROR_NULL_ARGUMENT); for (int i=0; i *
  • 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 (int index, Image image) { checkWidget(); if (image != null && image.isDisposed ()) { error(SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max (1, parent.getColumnCount ()); if (0 > index || index > count - 1) return; if (images == null) { images = new Image [count]; } images [index] = image; if ((parent.style & SWT.VIRTUAL) != 0) cached = true; if (imageList == 0) { imageList = OS.gcnew_ArrayList (count); for (int i = 0; i < count; i++) { OS.ArrayList_Insert (imageList, i, 0); } } int imageHandle = image != null ? image.handle : 0; OS.ArrayList_default (imageList, index, imageHandle); if (ignoreNotify) return; int row; if (parent.columnCount != 0) { int header = OS.HeaderedItemsControl_Header (handle); row = OS.GridViewRowPresenter_Content (header); OS.GCHandle_Free (header); } else { row = OS.HeaderedItemsControl_Header (handle); } OS.SWTRow_NotifyPropertyChanged (row, Tree.IMAGE_NOTIFY); OS.GCHandle_Free (row); } public void setImage (Image image) { checkWidget (); setImage (0, image); } /** * Sets the number of child 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.2 */ public void setItemCount (int count) { checkWidget (); parent.setItemCount (this, count); } /** * Sets the text for multiple columns in the tree. * * @param strings the array of new strings * * @exception IllegalArgumentException
      *
    • 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 [] strings) { checkWidget (); if (strings == null) error (SWT.ERROR_NULL_ARGUMENT); for (int i=0; i *
  • 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 (int index, String string) { checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); int count = Math.max(1, parent.getColumnCount ()); if (0 > index || index > count - 1) return; if ((parent.style & SWT.VIRTUAL) != 0) cached = true; if (stringList == 0) { stringList = OS.gcnew_ArrayList (count); for (int i = 0; i < count; i++) { OS.ArrayList_Insert (stringList, i, 0); } } int str = createDotNetString (string, false); OS.ArrayList_default (stringList, index, str); OS.GCHandle_Free (str); if (ignoreNotify) return; int row; if (parent.columnCount != 0) { int header = OS.HeaderedItemsControl_Header (handle); row = OS.GridViewRowPresenter_Content (header); OS.GCHandle_Free (header); } else { row = OS.HeaderedItemsControl_Header (handle); } OS.SWTRow_NotifyPropertyChanged (row, Tree.TEXT_NOTIFY); OS.GCHandle_Free (row); } public void setText (String string) { checkWidget (); setText (0, string); } void updateCheckState (boolean notify) { if ((parent.style & SWT.CHECK) == 0) return; if (checkState != 0) OS.GCHandle_Free (checkState); if (checked) { checkState = grayed ? OS.gcnew_IntPtr (2) : OS.gcnew_IntPtr (1); } else { checkState = OS.gcnew_IntPtr (0); } if (notify) { int row; if (parent.columnCount != 0) { int header = OS.HeaderedItemsControl_Header (handle); row = OS.GridViewRowPresenter_Content (header); OS.GCHandle_Free (header); } else { row = OS.HeaderedItemsControl_Header (handle); } parent.ignoreSelection = true; OS.SWTRow_NotifyPropertyChanged (row, Table.CHECK_NOTIFY); parent.ignoreSelection = false; OS.GCHandle_Free (row); } } }