handles the selection and deselects item if multiSelect is disabled

@param position the global position
166963
private void handleSelection(@Nullable View view, Item item, int position) {
        //if this item is not selectable don't continue
        if (!item.isSelectable()) {
            return;
        }

        //if we have disabled deselection via click don't continue
        if (item.isSelected() && !mAllowDeselection) {
            return;
        }

        boolean selected = item.isSelected();

        if (mSelectWithItemUpdate || view == null) {
            if (!mMultiSelect) {
                deselect();
            }
            if (selected) {
                deselect(position);
            } else {
                select(position);
            }
        } else {
            if (!mMultiSelect) {
                //we have to separately handle deselection here because if we toggle the current item we do not want to deselect this first!
                Set<Item> selections = getSelectedItems();
                selections.remove(item);
                deselectByItems(selections);
            }

            //we toggle the state of the view
            item.withSetSelected(!selected);
            view.setSelected(!selected);

            //notify that the selection changed
            if (mSelectionListener != null)
                mSelectionListener.onSelectionChanged(item, !selected);
        }
    }
1292392
public void toggleExpandable(int position) {
        Item item = mFastAdapter.getItem(position);
        if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
            collapse(position);
        } else {
            expand(position);
        }
    }
1334741
@UiHandler("navTree")
  final void menuItemSelected(final SelectionEvent<TreeItem> pselectionEvent) {
    if (selectedItem != null && !selectedItem.equals(pselectionEvent.getSelectedItem())) {
      // workaround, revert selection, it's triggered by the selected page
      pselectionEvent.getSelectedItem().setSelected(false);
      selectedItem.setSelected(true);
    }
  }
500525
public void deselectAll() {
        getDispatcher().beforeDeselect(this);
        
        new Select(getElement()).deselectAll();
        if (Config.getBoolConfigProperty(ConfigProperty.ENABLE_GUI_LOGGING)) {
            logUIActions(UIActions.CLEARED, "all");
        }
        
        getDispatcher().afterDeselect(this);
    }
913988
function () {
      if (!selection.isSelected()) {
        return;
      }
      highlight.off();
      priv.currentBorder.disappear();
      if (autofill.handle) {
        autofill.hideHandle();
      }
      selection.end(false);
      editproxy.destroy();
      self.rootElement.triggerHandler('deselect.handsontable');
    }
143870
function(selected, multiple){
      var selection = this.contextSelection;

      selected = !!resolveValue(this, this.setSelected, selected, 'selectedRA_');

      // special case, when node selected and has selection context check only
      // resolve adapter influence on selected if exists, and restore selection
      // influence when no resolve adapter
      if (this.selected && selection)
      {
        if (this.selectedRA_)
        {
          if (selection.has(this))
          {
            this.selected = false;
            selection.remove(this);
            this.selected = true;
          }
        }
        else
        {
          if (!selection.has(this))
            selection.add(this);
        }
      }

      if (selected !== this.selected)
      {
        if (this.selectedRA_) // when resolveValue using ignore selection
        {
          this.selected = selected;
          if (selected)
            this.emit_select();
          else
            this.emit_unselect();
        }
        else
        {
          if (selected) // this.selected = false -> true
          {
            if (selection)
            {
              if (multiple)
                selection.add(this);
              else
                selection.set(this);
            }
            else
            {
              this.selected = true;
              this.emit_select();
            }
          }
          else // this.selected = true -> false
          {
            if (selection)
            {
              selection.remove(this);
            }
            else
            {
              this.selected = false;
              this.emit_unselect();
            }
          }
        }

        return true;
      }
      else
      {
        if (!this.selectedRA_ && selected && selection)  // this.selected = true -> true
        {
          if (multiple)
            selection.remove(this);
          else
            selection.set(this);
        }
      }

      return false;
    }
564568
public void onItemBind(int position, T item) {
        if (onItemBind != null) {
            variableId = VAR_INVALID;
            layoutRes = LAYOUT_NONE;
            onItemBind.onItemBind(this, position, item);
            if (variableId == VAR_INVALID) {
                throw new IllegalStateException("variableId not set in onItemBind()");
            }
            if (layoutRes == LAYOUT_NONE) {
                throw new IllegalStateException("layoutRes not set in onItemBind()");
            }
        }
    }
751835
public void setValueSelected(T value, boolean selected) {
        int idx = getIndex(value);
        if (idx >= 0) {
            setItemSelectedInternal(idx, selected);
        }
    }
1268789
def __restore_selection(self, start_pos, end_pos):
        """"""
        cursor = self.textCursor()
        cursor.setPosition(start_pos)
        cursor.setPosition(end_pos, QTextCursor.KeepAnchor)
        self.setTextCursor(cursor)
799407
public void onSelectionChanged(SelectionEvent event) {
		Record record = event.getRecord();
		String featureId = record.getAttribute(FIELD_NAME_FEATURE_ID);

		// Check if selection and deselection are really necessary, to avoid useless events.
		if (event.getState()) {
			// Only select a feature if it is not yet selected:
			if (!layer.isFeatureSelected(featureId)) {
				layer.getFeatureStore().getFeature(featureId, GeomajasConstant.FEATURE_INCLUDE_ALL,
						new LazyLoadCallback() {

							public void execute(List<Feature> response) {
								layer.selectFeature(response.get(0));
							}
						});
			}
		} else {
			// Only deselect a feature if it is not yet deselected:
			if (layer.isFeatureSelected(featureId)) {
				layer.getFeatureStore().getFeature(featureId, GeomajasConstant.FEATURE_INCLUDE_ALL,
						new LazyLoadCallback() {

							public void execute(List<Feature> response) {
								layer.deselectFeature(response.get(0));
							}
						});
			}
		}
	}
887420
def onselection(self, widget):
        """"""
        self._selected_key = None
        for k in self.children:
            if self.children[k] == widget:  # widget is the selected ListItem
                self._selected_key = k
                if (self._selected_item is not None) and self._selectable:
                    self._selected_item.attributes['selected'] = False
                self._selected_item = self.children[self._selected_key]
                if self._selectable:
                    self._selected_item.attributes['selected'] = True
                break
        return (self._selected_key,)
824097
private void handleSelectionRequest(final Request request) {
		String[] paramValue = request.getParameterValues(getId() + ".selected");

		if (paramValue == null) {
			paramValue = new String[0];
		}

		Map<List<Integer>, Object> pageRowKeys = getCurrentRowIndexAndKeys();

		String[] selectedRows = removeEmptyStrings(paramValue);
		Set<?> oldSelections = getSelectedRows();
		Set<Object> newSelections;

		boolean singleSelect = getSelectMode() == SelectMode.SINGLE;

		if (getTableModel().getRowCount() == 0) {
			newSelections = new HashSet<>();
			selectedRows = new String[0];
		} else if (getPaginationMode() == PaginationMode.NONE || getPaginationMode() == PaginationMode.CLIENT
				|| oldSelections == null || !isPaginated()) {
			newSelections = new HashSet<>(selectedRows.length);
		} else if (singleSelect && selectedRows.length > 0) {
			// For single-select, we need to remove the old entries
			newSelections = new HashSet<>(1);
		} else {
			// For multi-select, we need the entries for the current page only
			newSelections = (Set<Object>) new HashSet<>(oldSelections);
			newSelections.removeAll(pageRowKeys.values());
		}

		for (String selectedRow : selectedRows) {
			List<Integer> rowIndex = TableUtil.rowIndexStringToList(selectedRow);
			Object key = pageRowKeys.get(rowIndex);
			if (key == null) {
				continue;
			}
			newSelections.add(key);
			if (singleSelect) {
				break;
			}
		}

		setSelectedRows(newSelections);

		// If there is a selection change action specified, it may need to be fired
		Action selectionChangeAction = getSelectionChangeAction();

		if (selectionChangeAction != null && !newSelections.equals(oldSelections)) {
			selectionChangeAction.execute(new ActionEvent(this, SELECTION_ACTION_COMMAND));
		}
	}
615013
@Override
    public void removeComponent(int position) {
        if (mData != null && position >= 0 && position < mData.size()) {
            removeComponent(mData.get(position));
        }
    }
759264
void handleFileItemClick(ItemClickEvent event) {

        if (isEditing()) {
            stopEdit();

        } else if (!event.isCtrlKey() && !event.isShiftKey()) {
            // don't interfere with multi-selection using control key
            String itemId = (String)event.getItemId();
            CmsUUID structureId = getUUIDFromItemID(itemId);
            boolean openedFolder = false;
            if (event.getButton().equals(MouseButton.RIGHT)) {
                handleSelection(itemId);
                openContextMenu(event);
            } else {
                if ((event.getPropertyId() == null)
                    || CmsResourceTableProperty.PROPERTY_TYPE_ICON.equals(event.getPropertyId())) {
                    handleSelection(itemId);
                    openContextMenu(event);
                } else {
                    if (m_actionColumnProperty.equals(event.getPropertyId())) {
                        Boolean isFolder = (Boolean)event.getItem().getItemProperty(
                            CmsResourceTableProperty.PROPERTY_IS_FOLDER).getValue();
                        if ((isFolder != null) && isFolder.booleanValue()) {
                            if (m_folderSelectHandler != null) {
                                m_folderSelectHandler.onFolderSelect(structureId);
                            }
                            openedFolder = true;
                        } else {
                            try {
                                CmsObject cms = A_CmsUI.getCmsObject();
                                CmsResource res = cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
                                m_currentResources = Collections.singletonList(res);
                                I_CmsDialogContext context = m_contextProvider.getDialogContext();
                                I_CmsDefaultAction action = OpenCms.getWorkplaceAppManager().getDefaultAction(
                                    context,
                                    m_menuBuilder);
                                if (action != null) {
                                    action.executeAction(context);
                                    return;
                                }
                            } catch (CmsVfsResourceNotFoundException e) {
                                LOG.info(e.getLocalizedMessage(), e);
                            } catch (CmsException e) {
                                LOG.error(e.getLocalizedMessage(), e);
                            }
                        }
                    } else {
                        I_CmsDialogContext context = m_contextProvider.getDialogContext();
                        if ((m_currentResources.size() == 1)
                            && m_currentResources.get(0).getStructureId().equals(structureId)
                            && (context instanceof I_CmsEditPropertyContext)
                            && ((I_CmsEditPropertyContext)context).isPropertyEditable(event.getPropertyId())) {

                            ((I_CmsEditPropertyContext)context).editProperty(event.getPropertyId());
                        }
                    }
                }
            }
            // update the item on click to show any available changes
            if (!openedFolder) {
                update(Collections.singletonList(structureId), false);
            }
        }
    }
1228820
private void setSelectPosition(int posX, int posY, int height, int width) {

        setSelectPositionX(posX, width);
        setSelectPositionY(posY, height);
    }
735261
protected void onSelectionChanged(int selStart, int selEnd) {
        if(mInputView == null)
            return;

        if(mInputView instanceof InternalEditText)
            ((InternalEditText)mInputView).superOnSelectionChanged(selStart, selEnd);
        else if(mInputView instanceof InternalAutoCompleteTextView)
            ((InternalAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
        else
            ((InternalMultiAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);

        if(mOnSelectionChangedListener != null)
            mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd);
    }
274478
public void selectTemporary(TwinTextItem item) {
        // if we just want to clear the selection:
        if(item == null) {
            setSelection(getLastItemPosition());
            // the call is passed on to the adapter in setSelection.
            return;
        }
        PickerSpinnerAdapter adapter = (PickerSpinnerAdapter) getAdapter();
        // pass on the call to the adapter (just stores the item):
        adapter.selectTemporary(item);
        final int tempItemPosition = adapter.getCount();
        if(getSelectedItemPosition() == tempItemPosition) {
            // this is quite a hack, first reset the position to 0 but intercept the callback,
            // then redo the selection:
            setSelectionQuietly(0);
        }
        super.setSelection(tempItemPosition);
        // during initialization the system might check our selected position and reset it,
        // thus we need to check after the message queue has been settled
        if (!restoreTemporarySelection) {
            restoreTemporarySelection = true;
            post(new Runnable() {
                @Override
                public void run() {
                    if (restoreTemporarySelection) {
                        restoreTemporarySelection = false;
                        reselectTemporaryItem = false;
                        final int tempItemPosition = getAdapter().getCount();
                        if (getSelectedItemPosition() != tempItemPosition)
                            superSetSelection(tempItemPosition);
                    }
                }
            });
        }
    }