/** Updates the check states of process tree viewer. */ private void updateCheckedStates() { ITreeContentProvider cp = (ITreeContentProvider) processViewer.getContentProvider(); if (config != null) { Object[] plugins = null; if (ConfigFreeProcessPublishUtil.getInstance().isSameMethodConfiguration(config)) { // For config free process publish plugins = cp.getChildren(LibraryService.getInstance().getCurrentMethodLibrary()); } else { plugins = cp.getChildren(config); } for (int i = 0; i < plugins.length; i++) { Object[] uiFolders = cp.getChildren(plugins[i]); int totalUIFolders = uiFolders.length; int checkedUIFolders = 0; for (int j = 0; j < uiFolders.length; j++) { Object[] processes = cp.getChildren(uiFolders[j]); int totalProcesses = processes.length; int checkedProcesses = 0; for (int k = 0; k < processes.length; k++) { if (processViewer.getChecked(processes[k])) { checkedProcesses++; } } if (checkedProcesses == 0) { processViewer.setGrayChecked(uiFolders[j], false); } else if (checkedProcesses == totalProcesses) { processViewer.setGrayed(uiFolders[j], false); processViewer.setChecked(uiFolders[j], true); } else { processViewer.setGrayChecked(uiFolders[j], true); } if (processViewer.getChecked(uiFolders[j])) { checkedUIFolders++; } } if (checkedUIFolders == totalUIFolders) { processViewer.setGrayed(plugins[i], false); processViewer.setChecked(plugins[i], true); } else if (checkedUIFolders == 0) { processViewer.setGrayChecked(plugins[i], false); } else { processViewer.setGrayChecked(plugins[i], true); } } } }
public void testSetGrayChecked() { CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer; TestElement[] children = fRootElement.getChildren(); ctv.setGrayChecked(children[0], true); ctv.setGrayChecked(children[1], false); assertTrue( "an item invoked with setGrayChecked(true) should be checked", ctv.getChecked(children[0])); assertTrue( "an item invoked with setGrayChecked(true) should be grayed", ctv.getGrayed(children[0])); assertFalse( "an item invoked with setGrayChecked(false) should be unchecked", ctv.getChecked(children[1])); assertFalse( "an item invoked with setGrayChecked(false) should not be grayed", ctv.getGrayed(children[1])); }
private void setSubtreeChecked(Object parent, boolean state, boolean checkExpandedState) { if (!(parent instanceof IAdaptable)) return; IContainer container = (IContainer) ((IAdaptable) parent).getAdapter(IContainer.class); if ((!fTree.getExpandedState(parent) && checkExpandedState) || (container != null && !container.isAccessible())) return; Object[] children = fTreeContentProvider.getChildren(parent); for (int i = children.length - 1; i >= 0; i--) { Object element = children[i]; if (state) { fTree.setChecked(element, true); fTree.setGrayed(element, false); } else fTree.setGrayChecked(element, false); if (isExpandable(element)) setSubtreeChecked(element, state, true); } }
private void checkGray(ArrayList<ETItem> all, Set<Integer> grey) { boolean isGrey = false; Event test = null; for (int i = 0; i < all.size(); i++) { test = (Event) all.get(i); isGrey = (!test.checked) && grey.contains(new Integer(test.index)); if (isGrey) { treeV.setGrayChecked(test, true); // grey.contains(new // Integer(((Event)all.get(i)).index))); } else { treeV.setGrayed(test, false); if (!test.checked) { treeV.setChecked(test, false); } } // if(isGrey)treeV.setChecked(all.get(i),isGrey); } }