src/main/java/com/mxgraph/swing/mxGraphComponent.java
public String validateGraph(Object cell, Hashtable<Object, Object> context)
	{
		mxIGraphModel model = graph.getModel();
		mxGraphView view = graph.getView();
		boolean isValid = true;
		int childCount = model.getChildCount(cell);

		for (int i = 0; i < childCount; i++)
		{
			Object tmp = model.getChildAt(cell, i);
			Hashtable<Object, Object> ctx = context;

			if (graph.isValidRoot(tmp))
			{
				ctx = new Hashtable<Object, Object>();
			}

			String warn = validateGraph(tmp, ctx);

			if (warn != null)
			{
				String html = warn.replaceAll("\n", "<br>");
				int len = html.length();
				setCellWarning(tmp, html.substring(0, Math.max(0, len - 4)));
			}
			else
			{
				setCellWarning(tmp, null);
			}

			isValid = isValid && warn == null;
		}

		StringBuffer warning = new StringBuffer();

		// Adds error for invalid children if collapsed (children invisible)
		if (graph.isCellCollapsed(cell) && !isValid)
		{
			warning.append(mxResources.get("containsValidationErrors",
					"Contains Validation Errors") + "\n");
		}

		// Checks edges and cells using the defined multiplicities
		if (model.isEdge(cell))
		{
			String tmp = graph.getEdgeValidationError(cell,
					model.getTerminal(cell, true),
					model.getTerminal(cell, false));

			if (tmp != null)
			{
				warning.append(tmp);
			}
		}
		else
		{
			String tmp = graph.getCellValidationError(cell);

			if (tmp != null)
			{
				warning.append(tmp);
			}
		}

		// Checks custom validation rules
		String err = graph.validateCell(cell, context);

		if (err != null)
		{
			warning.append(err);
		}

		// Updates the display with the warning icons before any potential
		// alerts are displayed
		if (model.getParent(cell) == null)
		{
			view.validate();
		}

		return (warning.length() > 0 || !isValid) ? warning.toString() : null;
	}
/**
	 * Validates the graph by validating each descendant of the given cell or
	 * the root of the model. Context is an object that contains the validation
	 * state for the complete validation run. The validation errors are attached
	 * to their cells using <setWarning>. This function returns true if no
	 * validation errors exist in the graph.
	 * 
	 * @param cell
	 *            Cell to start the validation recursion.
	 * @param context
	 *            Object that represents the global validation state.
	 */
Validates the graph by validating each descendant of the given cell or
the root of the model. Context is an object that contains the validation
state for the complete validation run. The validation errors are attached
to their cells using . This function returns true if no
validation errors exist in the graph.

@param cell
Cell to start the validation recursion.
@param context
Object that represents the global validation state.
Validates the graph by validating each descendant of the given cell or the root of the model . Context is an object that contains the validation state for the complete validation run . The validation errors are attached to their cells using . This function returns true if no validation errors exist in the graph . @param cell Cell to start the validation recursion . @param context Object that represents the global validation state .
public String validateGraph(Object cell, Hashtable<Object, Object> context)
	{
		mxIGraphModel model = graph.getModel();
		mxGraphView view = graph.getView();
		boolean isValid = true;
		int childCount = model.getChildCount(cell);
		for (int i = 0; i < childCount; i++)
		{
			Object tmp = model.getChildAt(cell, i);
			Hashtable<Object, Object> ctx = context;
			if (graph.isValidRoot(tmp))
			{
				ctx = new Hashtable<Object, Object>();
			}
			String warn = validateGraph(tmp, ctx);
			if (warn != null)
			{
				String html = warn.replaceAll("\n", "<br>");
				int len = html.length();
				setCellWarning(tmp, html.substring(0, Math.max(0, len - 4)));
			}
			else
			{
				setCellWarning(tmp, null);
			}
			isValid = isValid && warn == null;
		}
		StringBuffer warning = new StringBuffer();
		if (graph.isCellCollapsed(cell) && !isValid)
		{
			warning.append(mxResources.get("containsValidationErrors",
					"Contains Validation Errors") + "\n");
		}
		if (model.isEdge(cell))
		{
			String tmp = graph.getEdgeValidationError(cell,
					model.getTerminal(cell, true),
					model.getTerminal(cell, false));
			if (tmp != null)
			{
				warning.append(tmp);
			}
		}
		else
		{
			String tmp = graph.getCellValidationError(cell);
			if (tmp != null)
			{
				warning.append(tmp);
			}
		}
		String err = graph.validateCell(cell, context);
		if (err != null)
		{
			warning.append(err);
		}
		if (model.getParent(cell) == null)
		{
			view.validate();
		}
		return (warning.length() > 0 || !isValid) ? warning.toString() : null;
	}
public String validateGraph ( Object cell , Hashtable < Object , Object > context ) { mxIGraphModel model = graph . getModel ( ) ; mxGraphView view = graph . getView ( ) ; boolean isValid = true ; int childCount = model . getChildCount ( cell ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Object tmp = model . getChildAt ( cell , i ) ; Hashtable < Object , Object > ctx = context ; if ( graph . isValidRoot ( tmp ) ) { ctx = new Hashtable < Object , Object > ( ) ; } String warn = validateGraph ( tmp , ctx ) ; if ( warn != null ) { String html = warn . replaceAll ( "\n" , "<br>" ) ; int len = html . length ( ) ; setCellWarning ( tmp , html . substring ( 0 , Math . max ( 0 , len - 4 ) ) ) ; } else { setCellWarning ( tmp , null ) ; } isValid = isValid && warn == null ; } StringBuffer warning = new StringBuffer ( ) ; if ( graph . isCellCollapsed ( cell ) && ! isValid ) { warning . append ( mxResources . get ( "containsValidationErrors" , "Contains Validation Errors" ) + "\n" ) ; } if ( model . isEdge ( cell ) ) { String tmp = graph . getEdgeValidationError ( cell , model . getTerminal ( cell , true ) , model . getTerminal ( cell , false ) ) ; if ( tmp != null ) { warning . append ( tmp ) ; } } else { String tmp = graph . getCellValidationError ( cell ) ; if ( tmp != null ) { warning . append ( tmp ) ; } } String err = graph . validateCell ( cell , context ) ; if ( err != null ) { warning . append ( err ) ; } if ( model . getParent ( cell ) == null ) { view . validate ( ) ; } return ( warning . length ( ) > 0 || ! isValid ) ? warning . toString ( ) : null ; }
Validates the graph by validating each descendant of the given cell or
 the root of the model.
Validates the graph by validating each descendant of the given cell or the root of the model .
// Adds error for invalid children if collapsed (children invisible) // Checks edges and cells using the defined multiplicities // Checks custom validation rules // Updates the display with the warning icons before any potential // alerts are displayed