data.getPorts().isEmpty())
data.getPorts().isEmpty() && data.getMacros().isEmpty())
private static void writeTemplateData(DataOutputStream stream, NameManipulator namer) throws IOException{	final String nl = "\n";		final String comma = ", ";	final String quote = "\"";	final String ending = ")"+nl;	VDBTemplate data = Group.getEditingTemplateData();		// does not have template data (new template case)	if (data==null)		return; 	 	// write comment (even if not template definition is needed) 	if (data.getComment()!=null) 		stream.writeBytes(nl+data.getComment());	// template block not needed	if ((data.getRealDescription()==null || data.getRealDescription().length()==0) && 		  data.getPorts().isEmpty())		 //data.getInputs().isEmpty() && data.getOutputs().isEmpty())		return;		// template start	stream.writeBytes(nl+DBResolver.TEMPLATE+"(");		if (data.getRealDescription()!=null && data.getRealDescription().length()>0)		stream.writeBytes(quote + StringUtils.removeQuotes(data.getRealDescription()) + quote);		stream.writeBytes(") {"+nl);	final String portStart = "  "+DBResolver.PORT+"(";	Iterator i = data.getPortsV().iterator();	while (i.hasNext())	{		VDBPort port = (VDBPort)i.next();			if (port.getComment()!=null)			stream.writeBytes(port.getComment()+nl);		stream.writeBytes(portStart+			port.getName() +			comma + quote + StringUtils.removeQuotes(port.getTarget()) + quote);		if (port.getRealDescription()!=null && port.getRealDescription().length()>0)			stream.writeBytes(comma + quote + StringUtils.removeQuotes(port.getRealDescription()) + quote);		stream.writeBytes(ending);	}			boolean first = true;	final String portPrefix = "  #! ";	final String portPostfix = "(";	final String macroPrefix = "  #! ";	final String macroPostfix = "(";	final String NULL = "null";	final String justComma = ",";		//	// write port visual data	//	i = data.getPortsV().iterator();	while (i.hasNext())	{		VDBPort port = (VDBPort)i.next();			Port visiblePort = port.getVisibleObject();		if (visiblePort==null)			continue;					// separate visual data		if (first)		{			stream.writeBytes(nl); first = false;		}		switch (visiblePort.getMode())		{			case OutLink.CONSTANT_PORT_MODE:				stream.writeBytes(portPrefix);				stream.writeBytes(DBResolver.VDCT_CONSTANT_PORT);				break;			case OutLink.INPUT_PORT_MODE:				stream.writeBytes(portPrefix);				stream.writeBytes(DBResolver.VDCT_INPUT_PORT);				break;			case OutLink.OUTPUT_PORT_MODE:				stream.writeBytes(portPrefix);				stream.writeBytes(DBResolver.VDCT_OUTPUT_PORT);				break;			default:				// this should never happen				Console.getInstance().println("Warning: unknown port type for port '"+port.getName()+"'. Skipping visual definition...");				continue;		}		stream.writeBytes(portPostfix);				String target = NULL;		if (visiblePort.getInput()!=null)			target = namer.getResolvedName(visiblePort.getInput().getID());				stream.writeBytes(			visiblePort.getName() +			justComma + StringUtils.quoteIfMacro(target) +			justComma + visiblePort.getX() + justComma + visiblePort.getY() + 			justComma + StringUtils.color2string(visiblePort.getColor()) +			justComma + port.getVisibility());		stream.writeBytes(ending);	}		//	// write macro visual data	//	i = data.getMacrosV().iterator();	while (i.hasNext())	{		VDBMacro macro = (VDBMacro)i.next();			Macro visibleMacro = macro.getVisibleObject();		if (visibleMacro==null)			continue;					// separate visual data		if (first)		{			stream.writeBytes(nl); first = false;		}		switch (visibleMacro.getMode())		{			case InLink.INPUT_MACRO_MODE:				stream.writeBytes(macroPrefix);				stream.writeBytes(DBResolver.VDCT_INPUT_MACRO);				break;			case InLink.OUTPUT_MACRO_MODE:				stream.writeBytes(macroPrefix);				stream.writeBytes(DBResolver.VDCT_OUTPUT_MACRO);				break;			default:				// this should never happen				Console.getInstance().println("Warning: unknown macro type for macro '"+macro.getName()+"'. Skipping visual definition...");				continue;		}		stream.writeBytes(macroPostfix);				stream.writeBytes(			visibleMacro.getName() +			justComma + quote + StringUtils.removeQuotes(macro.getDescription()) + quote +			justComma + visibleMacro.getX() + justComma + visibleMacro.getY() + 			justComma + StringUtils.color2string(visibleMacro.getColor()) +			justComma + macro.getVisibility());		stream.writeBytes(ending);	}		// template end	stream.writeBytes("}"+nl);/*		// inputs	Enumeration e = data.getInputs().keys();	while (e.hasMoreElements())	{		String key = e.nextElement().toString();		VDBFieldData fdata = (VDBFieldData)data.getInputs().get(key);		stream.writeBytes("#! "+DBResolver.TEMPLATE_INPUT+"("+			quote + key + quote +			comma + quote + fdata.getFullName() + quote +			comma + quote + data.getInputComments().get(key).toString() + quote + ending);	}		if (!data.getInputs().isEmpty()) stream.writeBytes(nl);			// outputs	e = data.getOutputs().keys();	while (e.hasMoreElements())	{		String key = e.nextElement().toString();		VDBFieldData fdata = (VDBFieldData)data.getOutputs().get(key);		stream.writeBytes("#! "+DBResolver.TEMPLATE_OUTPUT+"("+			quote + key + quote +			comma + quote + fdata.getFullName() + quote +			comma + quote + data.getOutputComments().get(key).toString() + quote + ending);	}	if (!data.getOutputs().isEmpty()) stream.writeBytes(nl);	*/}