public static void SelectCompartmentItem(DiagramDocView docView, ModelElement compartmentOwner, string compartmentListName, ModelElement compartmentItem) { var shapeElement = DiagramUtil.GetModelElementFirstShape(compartmentOwner); ElementListCompartment compartment = null; foreach (ShapeElement shape in shapeElement.NestedChildShapes) { if (shape is ElementListCompartment) { if ((shape as ElementListCompartment).Name == compartmentListName) { compartment = (ElementListCompartment)shape; } } } if (compartment != null) { var listField = compartment.ListField; var child = listField.FindFirstChild(compartment, true); while (child != null && !child.RepresentedElements.OfType <ModelElement>().Any(element => element == compartmentItem)) { child = listField.FindNextChild(child, true); } var selectedShapesCollection = docView.CurrentDesigner.Selection; selectedShapesCollection.Clear(); selectedShapesCollection.Set(child); } }
public override void ExecCommand(MenuCommand menuCommand) { var currentSelection = GetCurrentSelectedPersistentType(); PersistentType currentPersistentType = currentSelection.CurrentPersistentType; PropertyBase newProperty = null; currentSelection.MakeActionWithinTransaction(string.Format("Add scalar property into '{0}'", currentPersistentType.Name), () => { newProperty = CreateNewProperty(currentPersistentType, GetPropertyKind()); }); if (newProperty != null) { Owner.SelectModelElement((ModelElement)currentPersistentType); var propertyBase = newProperty as IPropertyBase; var persistentType = propertyBase.GetRealOwner(); string compartmentName = propertyBase.PropertyKind == PropertyKind.Navigation ? "NavigationProperties" : "Properties"; DiagramUtil.SelectCompartmentItem(currentSelection.DiagramDocView, (ModelElement)persistentType, compartmentName, newProperty); } }
public override void ExecCommand(MenuCommand menuCommand) { var modelSelection = GetCurrentSelectedPersistentType(); var diagramDocView = modelSelection.DiagramDocView; DiagramUtil.AutoLayout(diagramDocView.CurrentDiagram.NestedChildShapes, diagramDocView.CurrentDiagram); new DiagramUtil().GetDiagramClientView(diagramDocView.CurrentDiagram).ZoomToFit(); }
public override void ExecCommand(MenuCommand menuCommand) { var currentSelection = GetCurrentSelectedPersistentType(); PersistentType currentPersistentType = currentSelection.CurrentPersistentType; EntityIndex newIndex = null; currentSelection.MakeActionWithinTransaction( string.Format("Add entity index into '{0}'", currentPersistentType.Name), () => { Interface ownerInterface = (Interface)currentPersistentType; newIndex = new EntityIndex(currentPersistentType.Partition); ownerInterface.Indexes.Add(newIndex); newIndex.Name = string.Format("Index{0}", ownerInterface.Indexes.Count); }); if (newIndex != null) { DiagramUtil.SelectCompartmentItem(currentSelection.DiagramDocView, currentPersistentType, "Indexes", newIndex); } }
private void ObjectModelBrowserOnDoubleClick(object sender, EventArgs eventArgs) { // Get the node selected in the model explorer tree ModelElementTreeNode node = (this.ObjectModelBrowser.SelectedNode as ModelElementTreeNode); if (node != null) { // Get the corresponding model element ModelElement element = node.ModelElement; if (element != null) { // Get the corresponding shape // If the model element is in a compartment the result will be null ShapeElement shape = DiagramUtil.GetModelElementFirstShape(element); if (shape == null) { // If the element is in a compartment, try to get the parent model element to select that ModelElement parentElement = GetCompartmentElementFirstParent(element); if (parentElement != null) { // Get the corresponding shape shape = DiagramUtil.GetModelElementFirstShape(parentElement); } } // Select the shape if (shape != null) { SelectShape(shape, this.ModelingDocData); } } } }