/// <summary> /// Checks whether selected elements can be moved to a Content Choice. /// </summary> /// <returns> /// true if this command can be executed; otherwise, false. /// </returns> /// <param name="parameter">ignored</param> public override bool CanExecute(object parameter) { if (ActiveDiagramView != null && ActiveDiagramView.SelectedItems.Count > 1) { PSMSuperordinateComponent parent; IList <PSMSubordinateComponent> components; if (PSMDiagramHelper.AreComponentsOfCommonParent(ActiveDiagramView.SelectedRepresentants, out parent, out components)) { return(true); } } return(false); }
public override void Execute(object parameter) { if (ActiveDiagramView != null && ActiveDiagramView.SelectedItems.Count > 1) { PSMSuperordinateComponent parent; IList <PSMSubordinateComponent> components; if (PSMDiagramHelper.AreComponentsOfCommonParent(ActiveDiagramView.SelectedRepresentants, out parent, out components)) { NewPSMContentChoiceCommand command = (NewPSMContentChoiceCommand)NewPSMContentChoiceCommandFactory.Factory().Create(ActiveDiagramView.Controller); command.Parent = parent; command.ContainedComponents.AddRange(components); command.Execute(); } } }
public override void Execute(object parameter) { if (ActiveDiagramView != null && ActiveDiagramView.SelectedItems.Count > 0) { PSMSuperordinateComponent parent; IList <PSMSubordinateComponent> components; if (PSMDiagramHelper.AreComponentsOfCommonParent(ActiveDiagramView.SelectedRepresentants, out parent, out components)) { if (components.All(component => component is PSMAssociation)) { JoinAssociationsToClassUnionMacroCommand command = (JoinAssociationsToClassUnionMacroCommand)JoinAssociationsToClassUnionMacroCommandFactory.Factory().Create(ActiveDiagramView.Controller); command.Set(parent, components.Cast <PSMAssociation>().OrderBy(a => a.ComponentIndex())); command.Execute(); } } } }