@Override public void notifyListeners (int eventType, Event event) { super.notifyListeners(eventType, event); if (eventType == SWT.Selection && event.detail != SWT.CHECK) getAccessible().selectionChanged(); } void onArrowDown (int stateMask) {
void deselectItem (CTableItem item) { int index = getSelectionIndex (item); if (index == -1) return; CTableItem[] newSelectedItems = new CTableItem [selectedItems.length - 1]; System.arraycopy (selectedItems, 0, newSelectedItems, 0, index); System.arraycopy ( selectedItems, index + 1, newSelectedItems, index, newSelectedItems.length - index); selectedItems = newSelectedItems; item.getAccessible(getAccessible(), 0).selectionChanged(); } void destroyItem (CTableColumn column) {
redraw(); getAccessible().setFocus(selectedItem); getAccessible().selectionChanged();
void selectItem (CTableItem item, boolean addToSelection) { CTableItem[] oldSelectedItems = selectedItems; if (!addToSelection || (getStyle () & SWT.SINGLE) != 0) { selectedItems = new CTableItem[] {item}; if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { for (CTableItem oldSelectedItem : oldSelectedItems) { if (oldSelectedItem != item) { redrawItem (oldSelectedItem.index, true); } } } for (CTableItem oldSelectedItem : oldSelectedItems) { oldSelectedItem.getAccessible(getAccessible(), 0).selectionChanged(); } } else { if (item.isSelected ()) return; selectedItems = new CTableItem [selectedItems.length + 1]; System.arraycopy (oldSelectedItems, 0, selectedItems, 0, oldSelectedItems.length); selectedItems [selectedItems.length - 1] = item; } item.getAccessible(getAccessible(), 0).selectionChanged(); getAccessible().selectionChanged(); } @Override
private void notifySelectionChanged() { Event event = new Event(); event.widget = this; event.display = this.getDisplay(); event.type = SWT.Selection; notifyListeners(SWT.Selection, event); // A listener could have caused the widget to be disposed if (!isDisposed()) { getAccessible().selectionChanged(); } }
private void notifySelectionChanged() { Event event = new Event(); event.widget = this; event.display = this.getDisplay(); event.type = SWT.Selection; notifyListeners(SWT.Selection, event); // A listener could have caused the widget to be disposed if (!isDisposed()) { getAccessible().selectionChanged(); } }
/** * Deselects all selected items in the receiver. * * @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 deselectAll () { checkWidget (); CTableItem[] oldSelection = selectedItems; selectedItems = new CTableItem [0]; if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { for (CTableItem element : oldSelection) { redrawItem (element.index, true); } } for (CTableItem element : oldSelection) { element.getAccessible(getAccessible(), 0).selectionChanged(); } if (oldSelection.length > 0) getAccessible().selectionChanged(); } void deselectItem (CTableItem item) {
/** * Selects all of the items in the receiver. * <p> * If the receiver is single-select, do nothing. * </p> * * @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 selectAll () { checkWidget (); if ((getStyle () & SWT.SINGLE) != 0) return; selectedItems = new CTableItem [itemsCount]; System.arraycopy (items, 0, selectedItems, 0, itemsCount); if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { redraw (); } for (CTableItem selectedItem : selectedItems) { selectedItem.getAccessible(getAccessible(), 0).selectionChanged(); } getAccessible().selectionChanged(); } void selectItem (CTableItem item, boolean addToSelection) {
/** * Deselects the item at the given zero-relative index in the receiver. * If the item at the index was already deselected, it remains * deselected. Indices that are out of range are ignored. * * @param index the index of the item to deselect * * @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 deselect (int index) { checkWidget (); if (!(0 <= index && index < itemsCount)) return; CTableItem item = items [index]; int selectIndex = getSelectionIndex (item); if (selectIndex == -1) return; CTableItem[] newSelectedItems = new CTableItem [selectedItems.length - 1]; System.arraycopy (selectedItems, 0, newSelectedItems, 0, selectIndex); System.arraycopy (selectedItems, selectIndex + 1, newSelectedItems, selectIndex, newSelectedItems.length - selectIndex); selectedItems = newSelectedItems; if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { redrawItem (item.index, false); } getAccessible().selectionChanged(); } /**
redrawItems (start, end, false); getAccessible().selectionChanged();
if (!oldSelection [i].isSelected ()) { redrawItem (oldSelection [i].index, true); oldSelection[i].getAccessible(getAccessible(), 0).selectionChanged(); tableSelectionChanged = true; selectedItem.getAccessible(getAccessible(), 0).selectionChanged(); tableSelectionChanged = true; if (tableSelectionChanged) getAccessible().selectionChanged();
/** * Selects the item at the given zero-relative index in the receiver. * If the item at the index was already selected, it remains * selected. Indices that are out of range are ignored. * * @param index the index of the item to select * * @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 select (int index) { checkWidget (); if (!(0 <= index && index < itemsCount)) return; selectItem (items [index], (getStyle () & SWT.MULTI) != 0); if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) { redrawItem (index, false); } getAccessible().selectionChanged(); } /**
/** * Selects the item at the given zero-relative index in the receiver. * The current selection is first cleared, then the new item is selected. * * @param index the index of the item to select * * @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> * * @see CTable#deselectAll() * @see CTable#select(int) */ public void setSelection (int index) { checkWidget (); deselectAll (); if (!(0 <= index && index < itemsCount)) return; selectItem (items [index], false); setFocusItem (items [index], true); redrawItem (index, true); showSelection (); getAccessible().selectionChanged(); } /**
getAccessible().selectionChanged();
redraw(); getAccessible().setFocus(item); getAccessible().selectionChanged();