本文整理汇总了Java中com.google.gwt.user.client.ui.TreeItem.getParentItem方法的典型用法代码示例。如果您正苦于以下问题:Java TreeItem.getParentItem方法的具体用法?Java TreeItem.getParentItem怎么用?Java TreeItem.getParentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.TreeItem
的用法示例。
在下文中一共展示了TreeItem.getParentItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSelection
import com.google.gwt.user.client.ui.TreeItem; //导入方法依赖的package包/类
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem item = event.getSelectedItem();
currentlySelected = item;
TreeItem child = item.getChild(0);
if ( child != null && child.getText().equals(DatasetWidget.LOADING) ) {
CategorySerializable cat = (CategorySerializable) item.getUserObject();
Util.getRPCService().getCategories(cat.getID(), null, categoryCallback);
}
// Open the item. Work around double firing bug.
// http://code.google.com/p/google-web-toolkit/issues/detail?id=3660&q=Tree%20selection&colspec=ID%20Type%20Status%20Owner%20Milestone%20Summary%20Stars
TreeItem selItem = event.getSelectedItem();
TreeItem parent = selItem.getParentItem();
selItem.getTree().setSelectedItem(parent, false); // null is ok
if(parent != null)
parent.setSelected(false); // not compulsory
selItem.setState(!selItem.getState(), false);
}
示例2: checkParentState
import com.google.gwt.user.client.ui.TreeItem; //导入方法依赖的package包/类
private void checkParentState(TreeItem treeItem, Boolean value) {
TreeItem parentItem = treeItem.getParentItem();
if (parentItem == null) {
return;
}
if (!(parentItem.getWidget() instanceof FlowPanel)) {
return;
}
FlowPanel parentChangeContainer = (FlowPanel) parentItem.getWidget();
if (!(parentChangeContainer.getWidget(0) instanceof CheckBox)) {
return;
}
CheckBox parentCheckBox = (CheckBox) parentChangeContainer.getWidget(0);
if (value && !parentCheckBox.getValue()) {
parentCheckBox.setValue(true);
checkParentState(parentItem, true);
}
}
示例3: getBreadcrumbsText
import com.google.gwt.user.client.ui.TreeItem; //导入方法依赖的package包/类
/**
* @param treeItem
* @return bread crumb text after recursively walking the tree of
* treeItem
*/
String getBreadcrumbsText(TreeItem treeItem) {
String breadcrumbsText = "";
TreeItem parentItem = treeItem.getParentItem();
if ( parentItem != null ) {
breadcrumbsText = getBreadcrumbsText(parentItem).trim() + delimiter;
}
String treeItemText = treeItem.getText();
if ( treeItemText != null ) {
// TODO: Fix: If delimiter is whitespace, it will get trimmed
breadcrumbsText = breadcrumbsText.trim().concat(treeItemText.trim());
}
return breadcrumbsText;
}
示例4: onSelection
import com.google.gwt.user.client.ui.TreeItem; //导入方法依赖的package包/类
/**
* @see com.google.gwt.event.logical.shared.SelectionHandler#onSelection(com.google.gwt.event.logical.shared.SelectionEvent)
*/
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
if ( (view != null) && (event != null) ) {
Object source = event.getSource();
// Only proceed if the source was from the same panel
if ( (source != null) && (source instanceof HasName) ) {
String sourceName = ((HasName) source).getName();
if ( view.getName().equalsIgnoreCase(sourceName) ) {
TextBox breadcrumbs = view.getBreadcrumbs();
TreeItem selectedItem = event.getSelectedItem();
if ( selectedItem != null ) {
String selectedItemText = selectedItem.getText();
// Only bother to update the bread crumbs if the
// user
// has
// selected an item that has actually loaded
if ( !selectedItemText.equalsIgnoreCase(DatasetWidget.LOADING) ) {
// Update bread crumbs by walking the meta data
// categories GUI tree already in memory
TreeItem parentItem = selectedItem.getParentItem();
if ( parentItem != null ) {
// First clear bread crumbs so events fire
// even
// when there is no change in
// breadcrumbsText
// characters, but set boolean fireEvents to
// false to avoid unnecessary event firing.
breadcrumbs.setValue("", false);
String breadcrumbsText = getBreadcrumbsText(parentItem);
breadcrumbs.setValue(breadcrumbsText, true);
}
}
}
}
}
}
}
示例5: onSelection
import com.google.gwt.user.client.ui.TreeItem; //导入方法依赖的package包/类
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
if ( (view != null) && (event != null) ) {
Object source = event.getSource();
// Only proceed if the source was from the same panel or from
// the comparePanel
if ( (source != null) && (source instanceof HasName) ) {
String sourceName = ((HasName) source).getName();
String viewName = view.getName();
if ( ((viewName != null) && viewName.equalsIgnoreCase(sourceName)) || CONSTANTS.comparePanelName().equalsIgnoreCase(sourceName) ) { //$NON-NLS-1$
// Get variables from the tree
TreeItem selectedItem = event.getSelectedItem();
if ( selectedItem != null ) {
Object userObject = selectedItem.getUserObject();
if ( (userObject != null) && (userObject instanceof VariableSerializable) ) {
VariableSerializable selectedVariable = (VariableSerializable) userObject;
// Find all siblings if any
Vector<VariableSerializable> variables = new Vector<VariableSerializable>();
// Vector<TreeItem> children = new
// Vector<TreeItem>();
int selectedIndex = 0;
TreeItem parent = selectedItem.getParentItem();
if ( parent == null ) {
// There are no reachable siblings without a
// parent, so just use the selectedVariable
// and leave selectedIndex == 0
variables.add(selectedVariable);
// children.add(selectedItem);
} else {
for ( int i = 0; i < parent.getChildCount(); i++ ) {
TreeItem child = parent.getChild(i);
userObject = child.getUserObject();
if ( (userObject != null) && (userObject instanceof VariableSerializable) ) {
variables.add((VariableSerializable) userObject);
// children.add(child);
}
}
selectedIndex = variables.indexOf(selectedVariable);
}
// Add the variables to the view
view.setVariables(variables, selectedIndex);
}
}
}
}
}
}