当前位置: 首页>>代码示例>>Java>>正文


Java TreeItem.setGrayed方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.TreeItem.setGrayed方法的典型用法代码示例。如果您正苦于以下问题:Java TreeItem.setGrayed方法的具体用法?Java TreeItem.setGrayed怎么用?Java TreeItem.setGrayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.TreeItem的用法示例。


在下文中一共展示了TreeItem.setGrayed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateChildrenItems

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Updates the check state of all created children
 */
private void updateChildrenItems(TreeItem parent) {
    boolean state = parent.getChecked();
    
    // do not implicitly check children, only uncheck
    if(state) {
        return;
    }
    
    Item[] children = getChildren(parent);
    
    for (int i = 0; i < children.length; i++) {
        TreeItem curr = (TreeItem) children[i];
        if (curr.getData() != null
                && ((curr.getChecked() != state) || curr.getGrayed())) {
            curr.setChecked(state);
            curr.setGrayed(false);
            updateChildrenItems(curr);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:24,代码来源:CheckedTreeViewer.java

示例2: updateParentItems

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Updates the check / gray state of all parent items
 */
private void updateParentItems(TreeItem item) {
    if (item != null) {
        Item[] children = getChildren(item);
        boolean containsChecked = false;
        boolean containsUnchecked = false;
        for (int i = 0; i < children.length; i++) {
            TreeItem curr = (TreeItem) children[i];
            containsChecked |= curr.getChecked();
            containsUnchecked |= (!curr.getChecked() || curr.getGrayed());
        }
        item.setChecked(containsChecked);
        item.setGrayed(containsChecked && containsUnchecked);
        updateParentItems(item.getParentItem());
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:19,代码来源:CheckedTreeViewer.java

示例3: doCheckStateChanged

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
/**
 * Update element after a checkstate change.
 * @param element
 */
protected void doCheckStateChanged(Object element) {
    Widget item = findItem(element);
    if (item instanceof TreeItem) {
        TreeItem treeItem = (TreeItem) item;
        treeItem.setGrayed(false);
        updateChildrenItems(treeItem);
        updateParentItems(treeItem.getParentItem());
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:14,代码来源:CheckedTreeViewer.java

示例4: selectAllParentItems

import org.eclipse.swt.widgets.TreeItem; //导入方法依赖的package包/类
private void selectAllParentItems(TreeItem selectedTreeItem) {
	TreeItem parentTreeItem = selectedTreeItem.getParentItem();
	// 当有一个未被选中的时候,取消父节点的选择,当全部选中,则父节点选中
	if (parentTreeItem != null) {
		TreeItem[] parentSubItems = parentTreeItem.getItems();
		boolean allChecked = true;
		boolean isGrayed = false;
		for (int i = 0; i < parentSubItems.length; i++) {
			allChecked = parentSubItems[i].getChecked();
			if (!allChecked) {
				break;
			}
		}
		for (int i = 0; i < parentSubItems.length; i++) {
			if (parentSubItems[i].getChecked()) {
				isGrayed = true;
				break;
			}
		}

		if (isGrayed && allChecked) {
			parentTreeItem.setChecked(allChecked);
			parentTreeItem.setGrayed(!isGrayed);
		}
		if (!allChecked) {
			parentTreeItem.setChecked(isGrayed);
			parentTreeItem.setGrayed(isGrayed);
		}
		selectAllParentItems(parentTreeItem);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:32,代码来源:SelectClassPage.java


注:本文中的org.eclipse.swt.widgets.TreeItem.setGrayed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。