Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Item


            i += delta;
        }

        if (i > -1 && i < resourceNameTable.getItemCount())
        {
            Item item = resourceNameTable.getItem(i);
            resourceNameTable.select(i);
            selected = new Object[] { item.getData() };
            ISelection selection = new SingletonSelection(selected);
            selectionChanged(new SelectionChangedEvent(viewer, selection));
            viewer.reveal(selected);
        }
    }
View Full Code Here


                fLastItem = (TreeItem) o;
                tree.setSelection(new TreeItem[] { fLastItem });
            } else if (e.y < tree.getItemHeight() / 4) {
                // Scroll up
                final Point p = tree.toDisplay(e.x, e.y);
                final Item item = fTreeViewer.scrollUp(p.x, p.y);
                if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] { fLastItem });
                }
            } else if (e.y > tree.getBounds().height - tree.getItemHeight() / 4) {
                // Scroll down
                final Point p = tree.toDisplay(e.x, e.y);
                final Item item = fTreeViewer.scrollDown(p.x, p.y);
                if (item instanceof TreeItem) {
                    fLastItem = (TreeItem) item;
                    tree.setSelection(new TreeItem[] { fLastItem });
                }
            }
View Full Code Here

   */
  protected Widget doFindItem(Object element) {

    Item[] children = doGetItems();
    for (int i = 0; i < children.length; i++) {
      Item item = children[i];
      Object data = item.getData();
      if (data != null && equals(data, element)) {
        return item;
      }
    }

View Full Code Here

  protected void doUpdateItem(Widget widget, Object element, boolean fullMap) {
    boolean oldBusy = isBusy();
    setBusy(true);
    try {
      if (widget instanceof Item) {
        final Item item = (Item) widget;

        // remember element we are showing
        if (fullMap) {
          associate(element, item);
        } else {
          Object data = item.getData();
          if (data != null) {
            unmapElement(data, item);
          }
          item.setData(element);
          mapElement(element, item);
        }

        int columnCount = doGetColumnCount();
        if (columnCount == 0)
          columnCount = 1;// If there are no columns do the first one

        ViewerRow viewerRowFromItem = getViewerRowFromItem(item);

        boolean isVirtual = (getControl().getStyle() & SWT.VIRTUAL) != 0;

        // If the control is virtual, we cannot use the cached viewer row object. See bug 188663.
        if (isVirtual) {
          viewerRowFromItem = (ViewerRow) viewerRowFromItem.clone();
        }

        // Also enter loop if no columns added. See 1G9WWGZ: JFUIF:WINNT -
        // TableViewer with 0 columns does not work
        for (int column = 0; column < columnCount || column == 0; column++) {
          ViewerColumn columnViewer = getViewerColumn(column);
          ViewerCell cellToUpdate = updateCell(viewerRowFromItem,
              column, element);

          // If the control is virtual, we cannot use the cached cell object. See bug 188663.
          if (isVirtual) {
            cellToUpdate = new ViewerCell(cellToUpdate.getViewerRow(), cellToUpdate.getColumnIndex(), element);
          }

          columnViewer.refresh(cellToUpdate);

          // clear cell (see bug 201280)
          updateCell(null, 0, null);

          // As it is possible for user code to run the event
          // loop check here.
          if (item.isDisposed()) {
            unmapElement(element, item);
            return;
          }

        }
View Full Code Here

   * @return the element at the given index, or <code>null</code> if the
   *         index is out of range
   */
  public Object getElementAt(int index) {
    if (index >= 0 && index < doGetItemCount()) {
      Item i = doGetItem(index);
      if (i != null) {
        return i.getData();
      }
    }
    return null;
  }
View Full Code Here

        if (selectionIndex < virtualManager.cachedElements.length) {
          element = virtualManager.cachedElements[selectionIndex];
        }
        if (element == null) {
          // Not cached so try the item's data
          Item item = doGetItem(selectionIndex);
          element = item.getData();
        }
        if (element != null) {
          result.add(element);
        }
      }
View Full Code Here

    Object[] children = getSortedChildren(getRoot());
    Item[] items = doGetItems();
    int min = Math.min(children.length, items.length);
    for (int i = 0; i < min; ++i) {

      Item item = items[i];

      // if the element is unchanged, update its label if appropriate
      if (equals(children[i], item.getData())) {
        if (updateLabels) {
          updateItem(item, children[i]);
        } else {
          // associate the new element, even if equal to the old
          // one,
          // to remove stale references (see bug 31314)
          associate(children[i], item);
        }
      } else {
        // updateItem does an associate(...), which can mess up
        // the associations if the order of elements has changed.
        // E.g. (a, b) -> (b, a) first replaces a->0 with b->0, then
        // replaces b->1 with a->1, but this actually removes b->0.
        // So, if the object associated with this item has changed,
        // just disassociate it for now, and update it below.
        // we also need to reset the item (set its text,images etc. to
        // default values) because the label decorators rely on this
        disassociate(item);
        doClear(i);
      }
    }
    // dispose of all items beyond the end of the current elements
    if (min < items.length) {
      for (int i = items.length; --i >= min;) {

        disassociate(items[i]);
      }
      if (virtualManager != null) {
        virtualManager.removeIndicesFromTo(min, items.length - 1);
      }
      doRemove(min, items.length - 1);
    }
    // Workaround for 1GDGN4Q: ITPUI:WIN2000 - TableViewer icons get
    // scrunched
    if (doGetItemCount() == 0) {
      doRemoveAll();
    }
    // Update items which were disassociated above
    for (int i = 0; i < min; ++i) {

      Item item = items[i];
      if (item.getData() == null) {
        updateItem(item, children[i]);
      }
    }
    // add any remaining elements
    for (int i = min; i < children.length; ++i) {
View Full Code Here

        int index = virtualManager.find(elements[i]);
        if (index != -1) {
          indices[count++] = index;
        }
      } else if (w instanceof Item) {
        Item item = (Item) w;
        disassociate(item);
        indices[count++] = doIndexOf(item);
      }
    }
    if (count < indices.length) {
View Full Code Here

      int count = 0;
      for (int i = 0; i < size; ++i) {
        Object o = list.get(i);
        Widget w = findItem(o);
        if (w instanceof Item) {
          Item item = (Item) w;
          items[count++] = item;
        }
      }
      if (count < size) {
        System.arraycopy(items, 0, items = new Item[count], 0, count);
View Full Code Here

   */
  private void virtualSetSelectionToWidget(List list, boolean reveal) {
    int size = list.size();
    int[] indices = new int[list.size()];

    Item firstItem = null;
    int count = 0;
    HashSet virtualElements = new HashSet();
    for (int i = 0; i < size; ++i) {
      Object o = list.get(i);
      Widget w = findItem(o);
      if (w instanceof Item) {
        Item item = (Item) w;
        indices[count++] = doIndexOf(item);
        if (firstItem == null) {
          firstItem = item;
        }
      } else {
        virtualElements.add(o);
      }
    }

    if (getContentProvider() instanceof ILazyContentProvider) {
      ILazyContentProvider provider = (ILazyContentProvider) getContentProvider();

      // Now go through it again until all is done or we are no longer
      // virtual
      // This may create all items so it is not a good
      // idea in general.
      // Use #setSelection (int [] indices,boolean reveal) instead
      for (int i = 0; virtualElements.size() > 0 && i < doGetItemCount(); i++) {
        provider.updateElement(i);
        Item item = doGetItem(i);
        if (virtualElements.contains(item.getData())) {
          indices[count++] = i;
          virtualElements.remove(item.getData());
          if (firstItem == null) {
            firstItem = item;
          }
        }
      }
    } else {

      if (count != list.size()) {// As this is expensive skip it if all
        // have been found
        // If it is not lazy we can use the cache
        for (int i = 0; i < virtualManager.cachedElements.length; i++) {
          Object element = virtualManager.cachedElements[i];
          if (virtualElements.contains(element)) {
            Item item = doGetItem(i);
            item.getText();// Be sure to fire the update
            indices[count++] = i;
            virtualElements.remove(element);
            if (firstItem == null) {
              firstItem = item;
            }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.