1 11 12 package org.eclipse.ui.internal.cheatsheets.composite.model; 13 14 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask; 15 16 public class TaskChoiceCompletionStrategy implements TaskGroup.CompletionStrategy { 17 18 25 public int computeState(TaskGroup taskGroup) { 26 boolean noChildrenStarted = true; 27 boolean atLeastOneChildCompleted = false; 28 ICompositeCheatSheetTask[] children = taskGroup.getSubtasks(); 29 for (int i = 0; i < children.length; i++) { 30 switch(children[i].getState()) { 31 case ICompositeCheatSheetTask.NOT_STARTED: 32 break; 33 case ICompositeCheatSheetTask.IN_PROGRESS: 34 noChildrenStarted = false; 35 break; 36 case ICompositeCheatSheetTask.SKIPPED: 37 case ICompositeCheatSheetTask.COMPLETED: 38 noChildrenStarted = false; 39 atLeastOneChildCompleted = true; 40 break; 41 } 42 } 43 if (atLeastOneChildCompleted || children.length == 0) { 44 return ICompositeCheatSheetTask.COMPLETED; 45 } 46 if (taskGroup.getState() == ICompositeCheatSheetTask.SKIPPED) { 47 return ICompositeCheatSheetTask.SKIPPED; 48 } 49 if (noChildrenStarted) { 50 return ICompositeCheatSheetTask.NOT_STARTED; 51 } 52 return ICompositeCheatSheetTask.IN_PROGRESS; 53 } 54 } 55 | Popular Tags |