本文整理了Java中com.google.gwt.user.client.ui.Tree
类的一些代码示例,展示了Tree
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree
类的具体详情如下:
包路径:com.google.gwt.user.client.ui.Tree
类名称:Tree
[英]A standard hierarchical tree widget. The tree contains a hierarchy of com.google.gwt.user.client.ui.TreeItem that the user can open, close, and select.
.gwt-Tree the tree itself .gwt-Tree .gwt-TreeItem a tree item .gwt-Tree .gwt-TreeItem-selected a selected tree item
com.google.gwt.examples.TreeExample
[中]一个标准的层次树小部件。该树包含com的层次结构。谷歌。gwt。使用者客户用户界面。用户可以打开、关闭和选择的树项。
####CSS样式规则
.gwt Tree树本身。gwt树。gwt TreeItem是一个树项目。gwt树。gwt TreeItem选择了一个选定的树项
####范例
通用域名格式。谷歌。gwt。例子。树示例
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Adds the widget as a root tree item.
*
* @see com.google.gwt.user.client.ui.HasWidgets#add(com.google.gwt.user.client.ui.Widget)
* @param widget widget to add.
*/
@Override
public void add(Widget widget) {
addItem(widget);
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* @deprecated will be removed in GWT 2.0 along with the listener classes
*/
@Deprecated
public static void add(com.google.gwt.user.client.ui.Tree tree,
TreeListener listener) {
WrappedTreeListener t = new WrappedTreeListener(listener);
tree.addSelectionHandler(t);
tree.addCloseHandler(t);
tree.addOpenHandler(t);
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Removes all items from the root level of this tree.
*/
@Override
public void removeItems() {
while (getItemCount() > 0) {
removeItem(getItem(0));
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Overloaded version for IsWidget.
*
* @see #add(Widget)
*/
@Override
public void add(IsWidget w) {
this.add(asWidgetOrNull(w));
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Overloaded version for IsWidget.
*
* @see #addItem(Widget)
*/
@Override
public TreeItem addItem(IsWidget w) {
return this.addItem(asWidgetOrNull(w));
}
代码示例来源:origin: kiegroup/drools-wb
public void setDSLSentences( final List<DSLSentence> dslSentences ) {
if ( tree.getItem( 0 ) != null ) {
tree.clear();
}
if ( dslSentences != null ) {
for ( DSLSentence dslSentence : dslSentences ) {
final TreeItem it = new TreeItem();
it.setHTML( "<small>" + dslSentence.toString() + "</small>" );
it.setUserObject( dslSentence );
tree.addItem( it );
}
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
if (root.getChildCount() > 0) {
onSelection(root.getChild(0), true, true);
case Event.ONCLICK: {
Element e = DOM.eventGetTarget(event);
if (shouldTreeDelegateFocusToElement(e)) {
} else if ((curSelection != null) && curSelection.getContentElem().isOrHasChild(e)) {
setFocus(true);
if ((DOM.eventGetCurrentTarget(event) == getElement())
&& (event.getButton() == Event.BUTTON_LEFT)) {
elementClicked(DOM.eventGetTarget(event));
keyboardNavigation(event);
lastWasKeyDown = true;
break;
keyboardNavigation(event);
if (event.getKeyCode() == KeyCodes.KEY_TAB) {
ArrayList<Element> chain = new ArrayList<Element>();
collectElementChain(chain, getElement(), DOM.eventGetTarget(event));
TreeItem item = findItemByChain(chain, 0, root);
if (item != getSelectedItem()) {
setSelectedItem(item, true);
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
leftPanel.add(selectionPanel);
groupTree = new Tree();
groupTree.setStyleName(GROUP_TREE_STYLE);
selectionPanel.add(groupTree);
TreeItem groupItem = new TreeItem( new GroupWidget( group ) );
groupItem.setStyleName(GROUP_ITEM_STYLE);
groupUris = group.getInstitutionURIs();
TreeItem institutionItem = new TreeItem( iw );
institutionItem.setStyleName(INSTITUTION_ITEM_STYLE);
groupItem.addItem(institutionItem);
if ( groupItem.getChildCount() > 0) {
if ( !displayName.equals( GROUP_ALL ) ) {
groupTree.addItem(groupItem);
} else {
groupTree.addItem( allGroupItem );
代码示例来源:origin: org.kie.guvnor/guvnor-categories-editor-client
protected void buildTree( final Categories categories ) {
final TreeItem root = new TreeItem();
root.setHTML( AbstractImagePrototype.create( ImageResources.INSTANCE.desc() ).getHTML() );
navTreeWidget.addItem( root );
for ( final CategoryItem category : categories ) {
final TreeItem it = buildTreeItem( category );
root.addItem( it );
if ( category.hasChild() ) {
loadChildren( it, category );
}
}
root.setState( true );
}
代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-client
@Override
public void setTreeOfChanges(Map<String, PreviewNode> nodes) {
containerChanges.clear();
showDiffPanel(false);
final SelectionModel<PreviewNode> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(
event -> {
PreviewNode selectedNode =
(PreviewNode) ((SingleSelectionModel) selectionModel).getSelectedObject();
delegate.onSelectionChanged(selectedNode);
});
Tree tree = new Tree();
tree.getElement().setId("tree-of-changes");
for (PreviewNode parentChange : nodes.values()) {
TreeItem treeItem = new TreeItem();
containerChanges.put(treeItem, parentChange);
createTreeElement(treeItem, parentChange.getDescription(), parentChange.getChildren());
tree.addItem(treeItem);
}
tree.addSelectionHandler(
event -> {
if (selectedElement != null) {
selectedElement.getStyle().setProperty("background", "transparent");
}
selectedElement = event.getSelectedItem().getWidget().getElement();
selectedElement.getStyle().setProperty("background", getEditorSelectionColor());
});
treePanel.clear();
treePanel.add(tree);
}
代码示例来源:origin: com.google.gwt/gwt-servlet
private void init(ImageAdapter images, boolean useLeafImages) {
setImages(images, useLeafImages);
setElement(DOM.createDiv());
getElement().getStyle().setProperty("position", "relative");
// Fix rendering problem with relatively-positioned elements and their
// children by
// forcing the element that is positioned relatively to 'have layout'
getElement().getStyle().setProperty("zoom", "1");
focusable = FocusPanel.impl.createFocusable();
focusable.getStyle().setProperty("fontSize", "0");
focusable.getStyle().setProperty("position", "absolute");
// Hide focus outline in Mozilla/Webkit
focusable.getStyle().setProperty("outline", "0px");
// Hide focus outline in IE 6/7
focusable.setAttribute("hideFocus", "true");
DOM.setIntStyleAttribute(focusable, "zIndex", -1);
DOM.appendChild(getElement(), focusable);
sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS);
DOM.sinkEvents(focusable, Event.FOCUSEVENTS);
// The 'root' item is invisible and serves only as a container
// for all top-level items.
root = new TreeItem(true);
root.setTree(this);
setStyleName("gwt-Tree");
// Add a11y role "tree"
Roles.getTreeRole().set(focusable);
}
代码示例来源: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: org.uberfire/widgets-core-client
@Override
public void reset() {
rootTreeItem.setUserObject(REPOSITORY_ID);
rootTreeItem.addItem(LAZY_LOAD);
rootTreeItem.removeItems();
tree.addOpenHandler(new OpenHandler<TreeItem>() {
@Override
public void onOpen(final OpenEvent<TreeItem> event) {
if (needsLoading(event.getTarget()) && event.getTarget().getUserObject() instanceof Path) {
presenter.loadDirectoryContent(new FileExplorerItemImpl(event.getTarget()), (Path) event.getTarget().getUserObject());
}
}
});
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
final Object userObject = event.getSelectedItem().getUserObject();
if (userObject != null && userObject instanceof Path) {
final Path path = (Path) userObject;
presenter.redirect(path);
} else if (userObject != null && userObject instanceof Root) {
final Root root = (Root) userObject;
presenter.redirect(root);
} else if (event.getSelectedItem().getUserObject() instanceof String &&
(event.getSelectedItem().getUserObject()).equals(REPOSITORY_ID)) {
presenter.redirectRepositoryList();
}
}
});
}
代码示例来源: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: kiegroup/drools-wb
public FactTypeBrowserWidget( final ClickEvent ev ) {
this.tree = new Tree();
tree.setStyleName( DRLTextEditorResources.INSTANCE.CSS().categoryExplorerTree() );
tree.addSelectionHandler( new SelectionHandler<TreeItem>() {
public void onSelection( SelectionEvent<TreeItem> event ) {
Object o = event.getSelectedItem().getUserObject();
tree.addOpenHandler( new OpenHandler<TreeItem>() {
@Override
public void onOpen( final OpenEvent<TreeItem> event ) {
if ( fields != null ) {
for ( String field : fields ) {
final TreeItem fi = new TreeItem();
fi.setHTML( AbstractImagePrototype.create( DRLTextEditorResources.INSTANCE.images().fieldImage() ).getHTML()
+ "<small style=\"cursor: pointer\">"
tree.setVisible( true );
hpFactsAndHide.setVisible( true );
hpShow.setVisible( false );
代码示例来源:origin: oVirt/ovirt-engine
tree.clear();
rootItem.addItem(nodeHeader);
boolean isOpen = getItemOldState(rootItem.getUserObject());
if (isOpen) {
rootItem = oldRootItemsMap.get(rootItem.getUserObject());
} else {
if (getEmptyRoot() != null) {
tree.addItem(rootItem);
styleItem(rootItem, true);
代码示例来源: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: oVirt/ovirt-engine
protected void addRootNode(final TreeItem rootItem, final TreeItem leafItem) {
rootItem.getElement().getStyle().setBackgroundColor("#eff3ff"); //$NON-NLS-1$
rootItem.getElement().getStyle().setMarginBottom(1, Unit.PX);
rootItem.getElement().getStyle().setPadding(0, Unit.PX);
if (leafItem != null) {
rootItem.addItem(leafItem);
// Defer styling in order to override padding done in:
// com.google.gwt.user.client.ui.Tree -> showLeafImage
Scheduler.get().scheduleDeferred(() -> {
leafItem.getElement().getStyle().setBackgroundColor("#ffffff"); //$NON-NLS-1$
leafItem.getElement().getStyle().setMarginLeft(20, Unit.PX);
leafItem.getElement().getStyle().setPadding(0, Unit.PX);
Boolean isLeafEmpty = (Boolean) leafItem.getUserObject();
if (isLeafEmpty != null && isLeafEmpty.equals(Boolean.TRUE)) {
rootItem.getElement().getElementsByTagName("td").getItem(0).getStyle().setVisibility(Visibility.HIDDEN); //$NON-NLS-1$
}
rootItem.getElement().getElementsByTagName("td").getItem(1).getStyle().setWidth(100, Unit.PCT); //$NON-NLS-1$
});
}
tree.addItem(rootItem);
}
代码示例来源:origin: stackoverflow.com
Tree t = new Tree();
HorizontalPanel hc = new HorizontalPanel();
hc.add(new Label("some text"));
hc.add(new Image("http://tueffel.net/images/icons/icon13.gif"));
TreeItem ti = new TreeItem(hc);
HorizontalPanel hc2 = new HorizontalPanel();
hc2.add(new Label("some text"));
hc2.add(new Image("http://tueffel.net/images/icons/icon13.gif"));
ti.addItem(new TreeItem(hc2));
t.addItem(ti);
RootPanel.get().add(t);
代码示例来源: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;
}
}
}
});
内容来源于网络,如有侵权,请联系作者删除!