private void WarnUserAboutMissingFiles(CyPhy.Component component) { Logger.WriteWarning(string.Format(@"Warning: copied component {0} contains resource children, but its path is empty or invalid; its backing files are likely missing and should be copied manually.", component.ToHyperLink())); }
/// <summary> /// Based on the selected objects, either adds connectors for ports/pins, or moves additional ports/pins into a connector. /// </summary> /// <param name="currentobj">The component model being modified.</param> /// <param name="selectedobjs">The selected ports/pins (and perhaps connector).</param> /// <seealso cref="https://metamorphsoftware.atlassian.net/browse/MOT-564"/> private void AddConnector(MgaFCO currentobj, MgaFCOs selectedobjs) { if (null == currentobj) { Logger.WriteError("The current object is null. Please select a Component object."); return; } if (currentobj.Meta.Name != "Component") { Logger.WriteError("AddConnector only works on Component objects."); Logger.WriteError("But, {1} is neither; it is a {0}.", currentobj.Meta.Name, currentobj.Name); return; } // The current object is a component. // Check for selected objects. if (selectedobjs.Count < 1) { Logger.WriteError("At least one pin or port must be selected."); return; } // Make three lists classifying all the selected objects as either ports, connectors, or other, // so we can tell how many of each type have been selected. List <MgaFCO> portList = new List <MgaFCO>(); List <CyPhy.Connector> connectorList = new List <CyPhy.Connector>(); List <MgaFCO> otherList = new List <MgaFCO>(); foreach (MgaFCO selectedObj in selectedobjs) { if (selectedObj.MetaRole.Name == "Connector") { connectorList.Add(CyPhyClasses.Connector.Cast(selectedObj)); } else if (IsPort(selectedObj)) { Logger.WriteDebug("Found port {0}.", selectedObj.Name); portList.Add(selectedObj); } else { otherList.Add(selectedObj); } } if (otherList.Count > 0) { if (otherList.Count == 1) { Logger.WriteWarning("AddConnector only operates on pins, ports, and connectors; {0} was also selected but is being ignored.", otherList[0].MetaRole.Name); } else { Logger.WriteWarning("AddConnector only operates on pins, ports, and connectors; {0} objects of other types are being ignored.", otherList.Count); } } if (portList.Count == 0 && connectorList.Count < 2) { Logger.WriteError("At least one pin/port object or more than one connector must be selected."); return; } Logger.WriteInfo("Found {0} ports, and {1} connectors OK.", portList.Count, connectorList.Count); // Choose the mode of operation based on how many connectors were selected. See MOT-564. if (connectorList.Count == 0) { Logger.WriteInfo("About to create connectors for the selected ports."); HandleNoConnectorsSelected(currentobj, portList); } else if (connectorList.Count == 1) { Logger.WriteInfo("About to move selected ports into the selected connector."); HandleOneConnectorSelected(currentobj, portList, connectorList[0]); } else if (portList.Count == 0) { Logger.WriteInfo("About to combine selected connectors."); MergeMultipleConnectors(currentobj, connectorList); } else { Logger.WriteInfo("About to run in \"intelligent\" mode."); HandleMultipleConnectorsSelected(currentobj, portList, connectorList); } }