boolean cascade = engineParam instanceof ICascadingParameterGroup; ParameterGroupDefinition paramGroup = new ParameterGroupDefinition( engineParam.getName( ), engineParam.getDisplayName( ), null, cascade ); List contents = convertParametersInGroup( engineParam .getContents( ), paramGroup, task ); paramGroup.setParameters( contents );
ParameterGroupDefinition paramGroup = convertGroupParameter( engineParam, task );
	private static Collection convertEngineParameters( Collection params,			IGetParameterDefinitionTask task, boolean includeGroups )	{		if ( params == null )			return Collections.EMPTY_LIST;		List ret = new ArrayList( );		List groups = new ArrayList( );		for ( Iterator it = params.iterator( ); it.hasNext( ); )		{			Object o = it.next( );			if ( o instanceof IParameterGroupDefn )			{				// If we do not want to include groups, i.e. we want a flattened				// collection of parameters, find all group contents and add to				// result				if ( !includeGroups )				{					IParameterGroupDefn groupDef = ( IParameterGroupDefn ) o;					List contents = new ArrayList( convertEngineParameters(							groupDef.getContents( ), task, true ) );					ret.addAll( contents );				}				// Save all groups so we later can check if a parameter is				// contained in a group				groups.add( o );			}		}		for ( Iterator it = params.iterator( ); it.hasNext( ); )		{			Object o = it.next( );			if ( o instanceof IScalarParameterDefn )			{				IScalarParameterDefn engineParam = ( IScalarParameterDefn ) o;				ParameterGroupDefinition group = null;				// Find group in which current parameter is a part of				for ( Iterator groupIt = groups.iterator( ); groupIt.hasNext( ); )				{					IParameterGroupDefn tempGroup = ( IParameterGroupDefn ) groupIt							.next( );					boolean cascade = tempGroup instanceof ICascadingParameterGroup;					if ( tempGroup.getContents( ).contains( engineParam ) )					{						// Recursion should only be one level,						// since groups cannot contain groups						// TODO: Remove this recursion since it complicates						// things						List contents = new ArrayList( convertEngineParameters(								tempGroup.getContents( ), task, true ) );						group = new ParameterGroupDefinition( tempGroup								.getName( ), tempGroup.getDisplayName( ),								contents, cascade );						break;					}				}				ParameterDefinition param = convertScalarParameter(						engineParam, group, task );				ret.add( param );			} else if ( o instanceof IParameterGroupDefn && includeGroups )			{				// If this parameter is a group and we are including groups in				// the result...				IParameterGroupDefn engineParam = ( IParameterGroupDefn ) o;				// Need to convert contents.				boolean cascade = engineParam instanceof ICascadingParameterGroup;				ParameterGroupDefinition paramGroup = new ParameterGroupDefinition(						engineParam.getName( ), engineParam.getDisplayName( ),						null, cascade );				List contents = convertParametersInGroup( engineParam						.getContents( ), paramGroup, task );				paramGroup.setParameters( contents );				ret.add( paramGroup );			}		}		return ret;	}