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

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(220)

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

Tree.setSelection介绍

[英]Sets the receiver's selection to the given item. The current selection is cleared before the new item is selected, and if necessary the receiver is scrolled to make the new selection visible.

If the item is not in the receiver, then it is ignored.
[中]将接收者的选择设置为给定项目。在选择新项目之前,清除当前选择,如有必要,滚动接收器,使新选择可见。
如果该项不在接收器中,则忽略该项。

代码示例

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TreeItem[] items = tree.getSelection();
    if (items[0] != rootRedisServers) {
      history.add(items[0].getParentItem());
      btnBackward.setEnabled(true);
      btnForward.setEnabled(false);
      tree.setSelection(items[0].getParentItem());
      treeItemSelected(false);
    }
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TreeItem item = history.backward();
    if (!item.isDisposed()) {
      tree.setSelection(item);
      treeItemSelected(false);
      if (!history.canBackward())
        btnBackward.setEnabled(false);
      btnForward.setEnabled(true);
    } else {
      MessageDialog.openInformation(shell,
          i18nFile.getText(I18nFile.ERROR),
          i18nFile.getText(I18nFile.OBJECTDELETE));
    }
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TreeItem item = history.forward();
    btnBackward.setEnabled(true);
    if (!item.isDisposed()) {
      tree.setSelection(item);
      treeItemSelected(false);
      if (!history.canForward())
        btnForward.setEnabled(false);
    } else {
      MessageDialog.openInformation(shell,
          i18nFile.getText(I18nFile.ERROR),
          i18nFile.getText(I18nFile.OBJECTDELETE));
    }
  }
});

代码示例来源:origin: pentaho/pentaho-kettle

@Override
 public void treeExpanded( TreeEvent treeEvent ) {
  if ( props.getAutoCollapseCoreObjectsTree() ) {
   TreeItem treeItem = (TreeItem) treeEvent.item;
   /*
    * Trick for WSWT on Windows systems: a SelectionEvent is called after the TreeEvent if setSelection() is not
    * used here. Otherwise the first item in the list is selected as default and collapsed again but wrong, see
    * PDI-1480
    */
   coreObjectsTree.setSelection( treeItem );
   // expand the selected tree item, collapse the rest
   //
   for ( TreeItem item : coreObjectsTree.getItems() ) {
    if ( item != treeItem ) {
     item.setExpanded( false );
    } else {
     treeItem.setExpanded( true );
    }
   }
  }
 }
} );

代码示例来源:origin: caoxinyu/RedisClient

for (TreeItem dataItem : dataItems) {
    if (dataItem.getText().equals(containers[i])) {
      tree.setSelection(dataItem);
      tree.setFocus();
      dbContainerTreeItemSelected(dataItem, refresh);
  for (TreeItem dataItem : dataItems) {
    if (dataItem.getText().equals(containers[i])) {
      tree.setSelection(dataItem);
      dbContainerTreeItemSelected(dataItem, false);
      dataItems = dataItem.getItems();
for (TreeItem dataItem : dataItems) {
  if (dataItem.getText().equals(container)) {
    tree.setSelection(dataItem);
    tree.setFocus();
    dbContainerTreeItemSelected(dataItem, refresh);
      .getContainerOnly();
  if (dataItem.getText().equals(containerOnly)) {
    tree.setSelection(dataItem);
    dbContainerTreeItemSelected(dataItem, false);
    dataItems = dataItem.getItems();

代码示例来源:origin: pentaho/pentaho-kettle

protected void refreshViewAndLog() {
 String[] selectionPath = null;
 TreeItem selectedItem;
 TreeEntry treeEntry = null;
 if ( wTree.getSelectionCount() == 1 ) {
  selectedItem = wTree.getSelection()[ 0 ];
  treeEntry = new TreeEntry( selectedItem );
  selectionPath = ConstUI.getTreeStrings( selectedItem );
 }
 refreshView();
 if ( treeEntry != null ) { // Select the same one again
  TreeItem treeItem = treeEntry.getTreeItem( wTree );
  if ( treeItem == null ) {
   treeItem = TreeUtil.findTreeItem( wTree, selectionPath );
  }
  if ( treeItem != null ) {
   wTree.setSelection( treeItem );
   if ( treeEntry.length < 3 ) {
    wTree.showItem( treeItem );
    treeItemSelected( treeItem );
    treeItem.setExpanded( true );
   }
  }
 }
 showLog();
}

代码示例来源:origin: caoxinyu/RedisClient

private void rootTreeItemSelected(boolean refresh) {
  itemsSelected = new Item[] { rootRedisServers };
  tree.setSelection(rootRedisServers);
  text.setText("");
  table.removeAll();
  rootItemSelected();
  if (rootRedisServers.getData(ITEM_OPENED) == null
      || ((Boolean) (rootRedisServers.getData(ITEM_OPENED)) == false)) {
    rootRedisServers.removeAll();
    initServers();
  } else if (refresh) {
  }
  java.util.List<Server> servers = service1.listAll();
  for (Server server : servers) {
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(new String[] { server.getName(),
        NodeType.SERVER.toString() });
    item.setImage(redisImage);
    item.setData(NODE_ID, server.getId());
    item.setData(NODE_TYPE, NodeType.SERVER);
  }
  mainTabItem.setImage(redisImage);
}

代码示例来源:origin: pentaho/pentaho-kettle

rep.renameRepositoryDirectory( dir.getObjectId(), dir.getParent(), newName );
 ti.setText( newName );
 wTree.setSelection( ti );
} catch ( Exception exception ) {
 new ErrorDialog(

代码示例来源:origin: caoxinyu/RedisClient

private void serverTreeItemSelected(TreeItem selectedItem, boolean refresh) {
  itemsSelected = new Item[] { selectedItem };
  tree.setSelection(selectedItem);
  text.setText(selectedItem.getText() + ":");
  table.removeAll();

代码示例来源:origin: caoxinyu/RedisClient

private void dbContainerTreeItemSelected(TreeItem itemSelected,
    boolean refresh) {
  itemsSelected = new Item[] { itemSelected };
  tree.setSelection(itemSelected);
  ContainerKeyInfo info = new ContainerKeyInfo();
  parseContainer(itemSelected, info);

代码示例来源:origin: pentaho/pentaho-kettle

tiNew.setText( newdir );
 tiNew.setImage( GUIResource.getInstance().getImageFolder() );
 wTree.setSelection( new TreeItem[] { tiNew } );
} catch ( Exception exception ) {
 new ErrorDialog( shell, BaseMessages.getString(

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

@Override
  public void clearSelectionQuiet() {
    getTree().setSelection(new TreeItem[0]);
  }
}

代码示例来源:origin: org.apache.uima/uimaj-ep-cas-editor

@Override
 public void mouseMove(MouseEvent e) {
  Tree tree = (Tree) typeTree.getControl();
  TreeItem item = tree.getItem(new Point(e.x, e.y));
  if (item != null) {
   tree.setSelection(item);
  }
 }
});

代码示例来源:origin: org.codehaus.openxma/xmartserver

/**
 * Visibly marks the named MenuItem as selected.
 * @param menuId the name of the MenuItem to mark as selected.
 */
public void markMenu(String menuId) {
  if(menuW==null) return;
  TreeItem node = (TreeItem) getMenu(menuId).getAttached();
  menuW.setSelection(new TreeItem[]{node});
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

/**
 * Visibly marks the named MenuItem as selected.
 * @param menuId the name of the MenuItem to mark as selected.
 */
public void markMenu(String menuId) {
  if(menuW==null) return;
  TreeItem node = (TreeItem) getMenu(menuId).getAttached();
  menuW.setSelection(new TreeItem[]{node});
}

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

private void updateSelection() {
 TreeItem[] selection = parent.getSelection();
 List<TreeItem> selectedItems = new ArrayList<>( Arrays.asList( selection ) );
 if( deselectChildren( selectedItems ) ) {
  if( ( parent.getStyle() & SWT.SINGLE ) != 0 ) {
   selectedItems.add( this );
  }
  parent.setSelection( selectedItems.toArray( new TreeItem[ 0 ] ) );
  Event event = new Event();
  event.item = this;
  parent.notifyListeners( SWT.Selection, event );
 }
}

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

@Override
protected void setSelection(List items) {
  Item[] current = getSelection(getTree());
  // Don't bother resetting the same selection
  if (isSameSelection(items, current)) {
    return;
  }
  TreeItem[] newItems = new TreeItem[items.size()];
  items.toArray(newItems);
  getTree().setSelection(newItems);
}

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

@Override
protected void setSelection(List<Item> items) {
  Item[] current = getSelection(getTree());
  // Don't bother resetting the same selection
  if (isSameSelection(items, current)) {
    return;
  }
  TreeItem[] newItems = new TreeItem[items.size()];
  items.toArray(newItems);
  getTree().setSelection(newItems);
}

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

protected void setSelection(List items) {
  Item[] current = getSelection(getTree());
  // Don't bother resetting the same selection
  if (isSameSelection(items, current)) {
    return;
  }
  TreeItem[] newItems = new TreeItem[items.size()];
  items.toArray(newItems);
  getTree().setSelection(newItems);
}

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

protected void doNavigate(String text) {
  checkTree();
  if (rootItems == null) return;
  int index = searchPattern(text);
  if (index != -1 && index != currentIndex) {
    indexTree.setSelection(new TreeItem[] { indexTree.getItem(index) });
    currentIndex = index;
  }
}

相关文章

Tree类方法