if (link.isVisible()) if (link.isRight()) rightFields--; else leftFields--;
private void synchronizePortLinkFields(){	Object[] objs = new Object[getSubObjectsV().size()];	getSubObjectsV().copyInto(objs);	// add ports	Enumeration e = templateData.getTemplate().getPortsV().elements();	while (e.hasMoreElements())	{		VDBPort port = (VDBPort)e.nextElement();		Object obj = getSubObject(port.getName());		if (obj==null)		{			TemplateEPICSPort tep = null;			for (int i=0; i<objs.length; i++)				if (objs[i] instanceof TemplateEPICSPort)				{					TemplateEPICSPort t = (TemplateEPICSPort)objs[i];					if (t.getFieldData().getName().equals(port.getName()))					{						tep = t;						break;					}				}								// renamed			if (tep!=null)			{				Object key = null;				Enumeration e2 = getSubObjects().keys();				while (e2.hasMoreElements())				{					Object key2 = e2.nextElement();					Object val = getSubObjects().get(key2);					if (val instanceof TemplateEPICSPort && val==tep)					{						key = key2;						break;					}				}								if (key!=null)					removeObject(key.toString());				else					System.out.println("Internal error...");									addSubObject(tep.getFieldData().getName(), tep);				// update lookup table and fix source links 				tep.fixTemplateLink();												//System.out.println("!! renamed !! "+port.getName());			}			else			{				//System.out.println("!! added !!"+port.getName());				// add port				VDBTemplatePort tf = new VDBTemplatePort(getTemplateData(), port);				EPICSLink link = createLinkField(tf);				if (link!=null)					addSubObject(tf.getName(), link);			}		}		else		{			// fix port if necessary (result of add+remove action)			VDBTemplatePort tpd = ((VDBTemplatePort)((TemplateEPICSPort)obj).getFieldData());			if (tpd.getPort()!=port)			{				//System.out.println("!! fixing port !!"+port.getName());				tpd.setPort(port);			}		}	}	// remove ports	for (int i=0; i<objs.length; i++)	{		if (objs[i] instanceof TemplateEPICSPort)		{			TemplateEPICSPort link = (TemplateEPICSPort)objs[i];			if (!templateData.getTemplate().getPorts().containsKey(link.getFieldData().getName()))			{				//System.out.println("!! removed !! "+link.getFieldData().getName());				// remove port				link.destroyAndRemove();					fields--;				removeObject(link.getFieldData().getName());			}		}	}		// save ports ID	portsID = getTemplateData().getTemplate().getPortsGeneratedID();	//com.cosylab.vdct.graphics.DrawingSurface.getInstance().setModified(true);}