org.eclipse.swt.widgets.List.setTopIndex()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.eclipse.swt.widgets.List.setTopIndex()方法的一些代码示例,展示了List.setTopIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.setTopIndex()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.List
类名称:List
方法名:setTopIndex

List.setTopIndex介绍

[英]Sets the zero-relative index of the item which is currently at the top of the receiver. This index can change when items are scrolled or new items are added and removed.
[中]

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
protected void listSetTopIndex(int index) {
  list.setTopIndex(index);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
protected void listSetTopIndex(int index) {
  list.setTopIndex(index);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

protected void listSetTopIndex(int index) {
  list.setTopIndex(index);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

private static void readTopIndex( final List list ) {
 String value = WidgetLCAUtil.readPropertyValue( list, "topIndex" );
 if( value != null ) {
  list.setTopIndex( NumberFormatUtil.parseInt( value ) );
 }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

public void handleSetTopIndex( List list, JsonObject properties ) {
 JsonValue value = properties.get( PROP_TOP_INDEX );
 if( value != null ) {
  list.setTopIndex( value.asInt() );
 }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

/**
 * Shows the selection.  If the selection is already showing in the receiver,
 * this method simply returns.  Otherwise, the items are scrolled until
 * the selection is visible.
 *
 * @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>
 *
 * @since 1.3
 */
public void showSelection() {
 checkWidget();
 int index = getSelectionIndex();
 if( index != -1 ) {
  int itemCount = getVisibleItemCount();
  if( index < topIndex ) {
   // Show item as top item
   setTopIndex( index );
  } else if( itemCount > 0 && index >= topIndex + itemCount ) {
   // Show item as last item
   setTopIndex( index - itemCount + 1 );
  }
 }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

public void reveal(Object element) {
  Assert.isNotNull(element);
  int index = getElementIndex(element);
  if (index == -1) {
    return;
  }
  // algorithm patterned after List.showSelection()
  int count = list.getItemCount();
  if (count == 0) {
    return;
  }
  int height = list.getItemHeight();
  Rectangle rect = list.getClientArea();
  int topIndex = list.getTopIndex();
  int visibleCount = Math.max(rect.height / height, 1);
  int bottomIndex = Math.min(topIndex + visibleCount, count) - 1;
  if ((topIndex <= index) && (index <= bottomIndex)) {
    return;
  }
  int newTop = Math.min(Math.max(index - (visibleCount / 2), 0),
      count - 1);
  list.setTopIndex(newTop);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
public void reveal(Object element) {
  Assert.isNotNull(element);
  int index = getElementIndex(element);
  if (index == -1) {
    return;
  }
  // algorithm patterned after List.showSelection()
  int count = list.getItemCount();
  if (count == 0) {
    return;
  }
  int height = list.getItemHeight();
  Rectangle rect = list.getClientArea();
  int topIndex = list.getTopIndex();
  int visibleCount = Math.max(rect.height / height, 1);
  int bottomIndex = Math.min(topIndex + visibleCount, count) - 1;
  if ((topIndex <= index) && (index <= bottomIndex)) {
    return;
  }
  int newTop = Math.min(Math.max(index - (visibleCount / 2), 0),
      count - 1);
  list.setTopIndex(newTop);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
public void reveal(Object element) {
  Assert.isNotNull(element);
  int index = getElementIndex(element);
  if (index == -1) {
    return;
  }
  // algorithm patterned after List.showSelection()
  int count = list.getItemCount();
  if (count == 0) {
    return;
  }
  int height = list.getItemHeight();
  Rectangle rect = list.getClientArea();
  int topIndex = list.getTopIndex();
  int visibleCount = Math.max(rect.height / height, 1);
  int bottomIndex = Math.min(topIndex + visibleCount, count) - 1;
  if ((topIndex <= index) && (index <= bottomIndex)) {
    return;
  }
  int newTop = Math.min(Math.max(index - (visibleCount / 2), 0),
      count - 1);
  list.setTopIndex(newTop);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

/**
 * Sets the text of the item in the receiver's list at the given
 * zero-relative index to the string argument.
 *
 * @param index the index for the item
 * @param string the new text for the item
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
 *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
 * </ul>
 * @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 setItem (int index, String string) {
  checkWidget ();
  if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
  int topIndex = getTopIndex ();
  boolean isSelected = isSelected (index);
  remove (index);
  add (string, index);
  if (isSelected) select (index, false);
  setTopIndex (topIndex);
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui

if (index != -1) list.setTopIndex (index);
Display display = getDisplay ();
Rectangle listRect = list.getBounds ();

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

if (index != -1) list.setTopIndex (index);
Rectangle listRect = list.getBounds ();
Rectangle parentRect = display.map (getParent (), null, getBounds ());

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

if (index != -1) list.setTopIndex (index);
Rectangle listRect = list.getBounds ();
Rectangle parentRect = display.map (getParent (), null, getBounds ());

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

if (index != -1) list.setTopIndex (index);
Rectangle listRect = list.getBounds ();
Rectangle parentRect = display.map (getParent (), null, getBounds ());

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

if (index != -1) list.setTopIndex (index);
Rectangle listRect = list.getBounds ();
Rectangle parentRect = display.map (getParent (), null, getBounds ());

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

if (index != -1) list.setTopIndex (index);
Rectangle listRect = list.getBounds ();
Rectangle parentRect = display.map (getParent (), null, getBounds ());

相关文章

微信公众号

最新文章

更多

List类方法