com.google.gwt.user.client.ui.Tree.getSelectedItem()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(198)

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

Tree.getSelectedItem介绍

[英]Gets the currently selected item.
[中]获取当前选定的项。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

void setTree(Tree newTree) {
 // Early out.
 if (tree == newTree) {
  return;
 }
 // Remove this item from existing tree.
 if (tree != null) {
  if (tree.getSelectedItem() == this) {
   tree.setSelectedItem(null);
  }
  if (widget != null) {
   tree.orphan(widget);
  }
 }
 tree = newTree;
 for (int i = 0, n = getChildCount(); i < n; ++i) {
  children.get(i).setTree(newTree);
 }
 updateState(false, true);
 if (newTree != null) {
  if (widget != null) {
   // Add my widget to the new tree.
   newTree.adopt(widget, this);
  }
 }
}

代码示例来源:origin: stackoverflow.com

Set<Treeitem> oldSelection;
...

@Command
public void select(@BindingParam("tree")Tree tree){
  // delete
  Set<Treeitem> unselected = oldSelected.removeAll(tree.getSelectedItems());
  for(Treeitem x : unselected){
    x.getTreerow().getLastChild().setParent(null);
  }
  // add
  tree.getSelectedItem().getTreerow().appendChild(getCombobox());
  oldSelection = tree.getSelectedItems()
}

代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client

public boolean isSelected() {
  return navTreeWidget.getSelectedItem() != null;
}

代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client

public CategoryItem getSelectedCategory() {
  if ( navTreeWidget.getSelectedItem() == null ) {
    return null;
  }
  return ( (CategoryItem) navTreeWidget.getSelectedItem().getUserObject() );
}

代码示例来源:origin: stackoverflow.com

TreeItem root = new TreeItem();
root.setText("root");

for(int i = 0; i < 10; i++) {
  MyTreeItemWidget item = new MyTreeItemWidget("Node " + Integer.toString(i), i);
  root.addItem(item);
}

final Tree tree = new Tree();
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
  @Override
  public void onSelection(SelectionEvent<TreeItem> event) {
    Window.alert("Selected value is " + Integer.toString(((MyTreeItemWidget) event.getSelectedItem()).getHiddenValue()));
    // -- or --
    Window.alert("Selected value is " + Integer.toString(((MyTreeItemWidget) tree.getSelectedItem()).getHiddenValue()));
  }
});

tree.addItem(root);
root.setState(true);

代码示例来源:origin: de.esoco/gewt

/***************************************
 * Returns the currently selected elements of this tree. The return value is
 * an array of all elements in the tree model that have been selected. If no
 * selection exists it will be empty.
 *
 * @return The selected model elements
 */
public Object[] getSelection()
{
  TreeItem rItem =
    ((com.google.gwt.user.client.ui.Tree) getWidget())
    .getSelectedItem();
  if (rItem != null)
  {
    return new Object[] { rItem.getUserObject() };
  }
  else
  {
    return new Object[] {};
  }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

collectElementChain(chain, getElement(), DOM.eventGetTarget(event));
TreeItem item = findItemByChain(chain, 0, root);
if (item != getSelectedItem()) {
 setSelectedItem(item, true);

代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client

public void renameSelected( final String name ) {
  ( (CategoryItem) navTreeWidget.getSelectedItem().getUserObject() ).setName( name );
  navTreeWidget.getSelectedItem().setHTML( AbstractImagePrototype.create( ImageResources.INSTANCE.categorySmall() ).getHTML() + h( name ) );
}

代码示例来源:origin: org.jboss.errai/errai-widgets

public void onMouseDown(MouseDownEvent event) {
  long elapsed = System.currentTimeMillis() - last;
  if (!getUserAgent().contains("msie")) {
   last = System.currentTimeMillis();
   TreeItem fti = tree.getSelectedItem();
   if (fti != null && fti.equals(lastItem) && elapsed < threshold) {
    if (fti.getChildCount() > 0) {
     if (!fti.getState()) {
      fti.setState(true, true);
     }
     else {
      fti.setState(false, false);
     }
    }
    else {
     clickListeners.get(fti).onClick(null);
    }
    last = 0;
   }
  }
 }
});

代码示例来源:origin: org.jboss.errai/errai-widgets

public void onMouseUp(MouseUpEvent event) {
  long elapsed = System.currentTimeMillis() - last;
  TreeItem fti = tree.getSelectedItem();
  if (getUserAgent().contains("msie")) {
   last = System.currentTimeMillis();
   if (fti != null && elapsed < threshold && lastItem != null
     && fti.hashCode() == lastItem.hashCode()) {
    if (fti.getChildCount() > 0) {
     if (!fti.getState()) {
      fti.setState(true, true);
     }
     else {
      fti.setState(false, false);
     }
    }
    else {
     clickListeners.get(fti).onClick(null);
    }
    lastItem = null;
   }
   else {
    lastItem = fti;
   }
  }
  else {
   lastItem = fti;
  }
 }
});

代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client

public void removeSelected() {
  final CategoryItem parent = ( (CategoryItem) navTreeWidget.getSelectedItem().getUserObject() ).getParent();
  if ( parent != null ) {
    parent.removeChildren( getSelectedCategory().getName() );
  } else {
    categories.removeChildren( getSelectedCategory().getName() );
  }
  navTreeWidget.getSelectedItem().remove();
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

void setTree(Tree newTree) {
 // Early out.
 if (tree == newTree) {
  return;
 }
 // Remove this item from existing tree.
 if (tree != null) {
  if (tree.getSelectedItem() == this) {
   tree.setSelectedItem(null);
  }
  if (widget != null) {
   tree.orphan(widget);
  }
 }
 tree = newTree;
 for (int i = 0, n = getChildCount(); i < n; ++i) {
  children.get(i).setTree(newTree);
 }
 updateState(false, true);
 if (newTree != null) {
  if (widget != null) {
   // Add my widget to the new tree.
   newTree.adopt(widget, this);
  }
 }
}

代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client

public void addChildren( final CategoryItem parent,
             final String name,
             final String description ) {
  final CategoryItem child = parent.addChildren( name, description );
  final TreeItem parentTree;
  if ( getSelectedCategory() == null ) {
    parentTree = navTreeWidget.getItem( 0 );
  } else {
    parentTree = navTreeWidget.getSelectedItem();
  }
  final TreeItem ct = buildTreeItem( child );
  parentTree.addItem( ct );
  parentTree.setState( true );
}

代码示例来源:origin: net.wetheinter/gwt-user

void setTree(Tree newTree) {
 // Early out.
 if (tree == newTree) {
  return;
 }
 // Remove this item from existing tree.
 if (tree != null) {
  if (tree.getSelectedItem() == this) {
   tree.setSelectedItem(null);
  }
  if (widget != null) {
   tree.orphan(widget);
  }
 }
 tree = newTree;
 for (int i = 0, n = getChildCount(); i < n; ++i) {
  children.get(i).setTree(newTree);
 }
 updateState(false, true);
 if (newTree != null) {
  if (widget != null) {
   // Add my widget to the new tree.
   newTree.adopt(widget, this);
  }
 }
}

代码示例来源:origin: net.wetheinter/gwt-user

collectElementChain(chain, getElement(), DOM.eventGetTarget(event));
TreeItem item = findItemByChain(chain, 0, root);
if (item != getSelectedItem()) {
 setSelectedItem(item, true);

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

collectElementChain(chain, getElement(), DOM.eventGetTarget(event));
TreeItem item = findItemByChain(chain, 0, root);
if (item != getSelectedItem()) {
 setSelectedItem(item, true);

相关文章