public dlgUser(Repository rep) { _rep = rep; _sql = new UtilSql(rep); InitializeComponent(); if (rep.IsSecurityEnabled) { _isSecurityEnabled = true; // check if user has the rights to manage users if (_sql.UserHasPermission(rep.GetCurrentLoginUser(true))) { users = _sql.GetUsers(); txtStatus.Text = "Security is enabled: Choose user"; } else { txtStatus.Text = "Security is enabled: Only person with 'Manage User' are allowed to change users!"; MessageBox.Show("User has no 'Manage Users' right", "Insufficient user rights"); btnOk.Enabled = false; } } else { users = _sql.GetUsers(); txtStatus.Text = "Security isn't enabled: Choose or enter your desired author name!"; } cmbUser.Text = _user; cmbUser.DataSource = users; }
public void ConnectPortsOf2Classes(Element srcEl, Element trgtEl) { foreach (Element srcPort in srcEl.EmbeddedElements) { foreach (Element trgtPort in trgtEl.EmbeddedElements) { // don't connect to itself if (srcPort.Name == trgtPort.Name && srcPort.ElementID != trgtPort.ElementID) { //if (srcPort.Stereotype != trgtEl.Stereotype) //{ // // only connect: // // sender to receiver // // client to server // // check if connection already exists // if (srcPort.Stereotype == "Sender") // if (trgtPort.Stereotype != "Receiver") continue; // if (srcPort.Stereotype == "Receiver") // if (trgtPort.Stereotype != "Sender") continue; // if (srcPort.Stereotype == "Client") // if (trgtPort.Stereotype != "Server") continue; // if (srcPort.Stereotype == "Server") // if (trgtPort.Stereotype != "Client") continue; var sql = new UtilSql(_rep); if (sql.IsConnectionAvailable(srcPort, trgtPort) == false) { // direction of connector if (srcPort.Stereotype == "Sender" | srcPort.Stereotype == "Client") { var con = (Connector)srcPort.Connectors.AddNew("", "Connector"); srcPort.Connectors.Refresh(); con.SupplierID = trgtPort.ElementID; con.Update(); _count += 1; } else { var con = (Connector)trgtPort.Connectors.AddNew("", "Connector"); trgtPort.Connectors.Refresh(); con.SupplierID = srcPort.ElementID; con.Update(); _count += 1; } } //} } } } }
public static void ShowEmbeddedElementsGui( Repository rep, string embeddedElementType = "Port Pin Parameter", bool isOptimizePortLayout = false) { var dia = rep.GetCurrentDiagram(); if (dia == null) return; rep.SaveDiagram(dia.DiagramID); var sqlUtil = new UtilSql(rep); // over all selected elements foreach (DiagramObject diaObj in dia.SelectedObjects) { var elSource = rep.GetElementByID(diaObj.ElementID); if (!"Class Component Activity".Contains(elSource.Type)) continue; // find object on Diagram var diaObjSource = Util.GetDiagramObjectById(rep, dia, elSource.ElementID); //diaObjSource = dia.GetDiagramObjectByID(elSource.ElementID, ""); if (diaObjSource == null) return; string[] portTypes = {"left", "right"}; foreach (string portBoundTo in portTypes) { // arrange sequence of ports if (isOptimizePortLayout == false && portBoundTo == "left") continue; int pos = 0; List<int> lPorts; if (isOptimizePortLayout == false) { lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "", "", ""); } else { if (portBoundTo == "left") lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "Port", "'Server', 'Receiver' ", "DESC"); else lPorts = sqlUtil.GetAndSortEmbeddedElements(elSource, "Port", "'Client', 'Sender' ", ""); } // over all sorted ports string oldStereotype = ""; foreach (int i in lPorts) { Element portEmbedded = rep.GetElementByID(i); if (embeddedElementType == "" | embeddedElementType.Contains(portEmbedded.Type)) { // only ports / parameters (port has no further embedded elements if (portEmbedded.Type == "ActivityParameter" | portEmbedded.EmbeddedElements.Count == 0) { if (isOptimizePortLayout) { if (portBoundTo == "left") { if ("Sender Client".Contains(portEmbedded.Stereotype)) continue; } else { if ("Receiver Server".Contains(portEmbedded.Stereotype)) continue; } } // Make a gap between different stereotypes if (pos == 0 && "Sender Receiver".Contains(portEmbedded.Stereotype)) oldStereotype = portEmbedded.Stereotype; if (pos > 0 && "Sender Receiver".Contains(oldStereotype) && oldStereotype != portEmbedded.Stereotype) { pos = pos + 1; // make a gap oldStereotype = portEmbedded.Stereotype; } Util.VisualizePortForDiagramobject(pos, dia, diaObjSource, portEmbedded, null, portBoundTo); pos = pos + 1; } else { // Port: Visualize Port + Interface foreach (Element interf in portEmbedded.EmbeddedElements) { Util.VisualizePortForDiagramobject(pos, dia, diaObjSource, portEmbedded, interf); pos = pos + 1; } } } } } } rep.ReloadDiagram(dia.DiagramID); }