1 11 12 package org.eclipse.ui.internal.cheatsheets.composite.parser; 13 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.ui.internal.cheatsheets.Messages; 17 import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; 18 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask; 19 import org.eclipse.ui.internal.provisional.cheatsheets.ITaskGroup; 20 import org.w3c.dom.Node ; 21 22 public class TaskGroupParseStrategy implements ITaskParseStrategy { 23 24 25 public TaskGroupParseStrategy() { 26 } 27 28 public void init() { 29 } 30 31 public boolean parseElementNode(Node childNode, Node parentNode, 32 AbstractTask parentTask, IStatusContainer status) 33 { 34 return false; 36 } 37 38 public void parsingComplete(AbstractTask parentTask, IStatusContainer status) { 39 String kind = parentTask.getKind(); 40 if (ITaskGroup.SEQUENCE.equals(kind)) { 41 ICompositeCheatSheetTask[] children = parentTask.getSubtasks(); 43 AbstractTask previous = null; 44 AbstractTask next = null; 45 for (int i = 0; i < children.length; i++) { 46 previous = next; 47 next = (AbstractTask)children[i]; 48 if (previous != null) { 49 next.addRequiredTask(previous); 50 } 51 } 52 checkForChildren(parentTask, status); 53 } else if (ITaskGroup.SET.equals(kind)) { 54 checkForChildren(parentTask, status); 55 } else if (ITaskGroup.CHOICE.equals(kind)) { 56 checkForChildren(parentTask, status); 57 } else { 58 String message = NLS.bind( 59 Messages.ERROR_PARSING_TASK_INVALID_KIND, 60 (new Object [] { parentTask.getKind(), ICompositeCheatsheetTags.TASK_GROUP, parentTask.getName()})); 61 status.addStatus(IStatus.ERROR, message, null); 62 } 63 } 64 65 private void checkForChildren(AbstractTask parentTask, IStatusContainer status) { 66 if (parentTask.getSubtasks().length < 1) { 67 String message = NLS.bind( 68 Messages.ERROR_PARSING_CHILDLESS_TASK_GROUP, 69 (new Object [] { parentTask.getName()})); 70 status.addStatus(IStatus.ERROR, message, null); 71 } 72 } 73 74 75 } 76 | Popular Tags |