當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。