Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.pde.internal.ua.ui.editor.cheatsheet.comp;
 
 
CompCSTreeValidator
 
 public class CompCSGroupValidator {
 
 	private Form fForm;
 
 	private HashSet fGroups;
 
 	private String fErrorCategory;
 
 	// TODO: MP: LOW: CompCS: Can augment the model to have isValid() methods to simplify validation
 
 
 	public CompCSGroupValidator(ICompCS cheatsheetForm formString errorCategory) {
 		 = form;
 		 = errorCategory;
 
 		 = new HashSet();
 		populateGroups(cheatsheet);
 	}

Parameters:
cheatsheet
 
 	private void populateGroups(ICompCS cheatsheet) {
 		// Register all existing groups in the present workspace model to be
 		// validated
 		}
 	}

Parameters:
group
 
 	public void addGroup(ICompCSTaskGroup group) {
 		.add(group);
 		// Check to see if the group has any children
 		if (group.hasFieldTaskObjects() == false) {
 			return;
 		}
 		// Recursively add any sub-groups
 		ICompCSTaskObject[] taskObjects = group.getFieldTaskObjects();
 		for (int i = 0; i < taskObjects.lengthi++) {
 			if (taskObjects[i].getType() == .) {
 				addGroup((ICompCSTaskGrouptaskObjects[i]);
 			}
 		}
 	}

Parameters:
group
 
 	public void removeGroup(ICompCSTaskGroup group) {
 		.remove(group);
 		// Check to see if the group has any children
 		if (group.hasFieldTaskObjects() == false) {
 			return;
 		}
 		// Recursively remove any sub-groups
 		ICompCSTaskObject[] taskObjects = group.getFieldTaskObjects();
 		for (int i = 0; i < taskObjects.lengthi++) {
 			if (taskObjects[i].getType() == .) {
 				removeGroup((ICompCSTaskGrouptaskObjects[i]);
 			}
 		}
 	}

Returns:
 
	public boolean validate() {
		// Check to see if there is anything to validate
		if (.isEmpty()) {
			return true;
		}
		Iterator iterator = .iterator();
		// Validate all registered groups
		while (iterator.hasNext()) {
			ICompCSTaskGroup group = (ICompCSTaskGroupiterator.next();
			if (validate(group) == false) {
				return false;
			}
		}
		return true;
	}

Parameters:
group
Returns:
	private boolean validate(ICompCSTaskGroup group) {
		if (group.getFieldTaskObjectCount() == 0) {
			String message = '[' +  + ']' + ' ' + PDETextHelper.translateReadText(group.getFieldName()) + ':' + ' ' + .;
			return false;
		}
		return true;
	}
New to GrepCode? Check out our FAQ X