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 TaskSetCompletionStrategy implements TaskGroup.CompletionStrategy { 17 18 25 public int computeState(TaskGroup taskGroup) { 26 boolean noChildrenStarted = true; 27 boolean allChildrenCompleted = true; 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 allChildrenCompleted = false; 33 break; 34 case ICompositeCheatSheetTask.IN_PROGRESS: 35 noChildrenStarted = false; 36 allChildrenCompleted = false; 37 break; 38 case ICompositeCheatSheetTask.COMPLETED: 39 case ICompositeCheatSheetTask.SKIPPED: 40 noChildrenStarted = false; 41 break; 42 } 43 } 44 if (allChildrenCompleted) { 45 return ICompositeCheatSheetTask.COMPLETED; 46 } 47 if (taskGroup.getState() == ICompositeCheatSheetTask.SKIPPED) { 48 return ICompositeCheatSheetTask.SKIPPED; 49 } 50 if (noChildrenStarted) { 51 return ICompositeCheatSheetTask.NOT_STARTED; 52 } 53 return ICompositeCheatSheetTask.IN_PROGRESS; 54 } 55 } 56 | Popular Tags |