Esempio n. 1
0
        public void MoveAttributeDown(PSMAttribute attribute)
        {
            ComponentsReorderCommand <PSMAttribute> command = (ComponentsReorderCommand <PSMAttribute>) ComponentsReorderCommandFactory <PSMAttribute> .Factory().Create(DiagramController);

            command.Action       = EReorderAction.MoveOneItem;
            command.ItemIndex    = AttributeHolder.PSMAttributes.IndexOf(attribute);
            command.NewItemIndex = command.ItemIndex + 1;
            command.Collection   = AttributeHolder.PSMAttributes;
            command.Execute();
        }
Esempio n. 2
0
        public override void Execute(object parameter)
        {
            if (ActiveDiagramView != null && ActiveDiagramView.SelectedItems.Count == 1)
            {
                ISelectable selectedItem = ActiveDiagramView.SelectedItems.First();
                IList <PSMSuperordinateComponent> rootsCollection;
                IList <PSMSubordinateComponent>   subordinateComponentCollection;
                IList <PSMAssociationChild>       associationChildCollection;

                Element component = GetComponentAndCollection(selectedItem, (PSMDiagram)ActiveDiagramView.Diagram, out rootsCollection, out associationChildCollection, out subordinateComponentCollection);

                if (component != null)
                {
                    int index;
                    if (rootsCollection != null)
                    {
                        if ((index = GetIndexInCollection(rootsCollection, (PSMClass)component)) > 0)
                        {
                            ComponentsReorderCommand <PSMSuperordinateComponent> command =
                                (ComponentsReorderCommand <PSMSuperordinateComponent>)
                                ComponentsReorderCommandFactory <PSMSuperordinateComponent> .Factory().Create(ActiveDiagramView.Controller);

                            command.Action       = EReorderAction.MoveOneItem;
                            command.Collection   = rootsCollection;
                            command.ItemIndex    = index;
                            command.NewItemIndex = index - 1;
                            command.Execute();
                            OnCanExecuteChanged(new EventArgs());
                            cmdMoveToRight.OnCanExecuteChanged(new EventArgs());
                        }
                    }
                    if (subordinateComponentCollection != null)
                    {
                        if ((index = GetIndexInCollection(subordinateComponentCollection, (PSMSubordinateComponent)component)) > 0)
                        {
                            ComponentsReorderCommand <PSMSubordinateComponent> command =
                                (ComponentsReorderCommand <PSMSubordinateComponent>)
                                ComponentsReorderCommandFactory <PSMSubordinateComponent> .Factory().Create(ActiveDiagramView.Controller);

                            command.Action       = EReorderAction.MoveOneItem;
                            command.Collection   = subordinateComponentCollection;
                            command.ItemIndex    = index;
                            command.NewItemIndex = index - 1;
                            command.Execute();
                            OnCanExecuteChanged(new EventArgs());
                            cmdMoveToRight.OnCanExecuteChanged(new EventArgs());
                        }
                    }
                    if (associationChildCollection != null)
                    {
                        if ((index = GetIndexInCollection(associationChildCollection, (PSMAssociationChild)component)) > 0)
                        {
                            ComponentsReorderCommand <PSMAssociationChild> command =
                                (ComponentsReorderCommand <PSMAssociationChild>)
                                ComponentsReorderCommandFactory <PSMAssociationChild> .Factory().Create(ActiveDiagramView.Controller);

                            command.Action       = EReorderAction.MoveOneItem;
                            command.Collection   = associationChildCollection;
                            command.ItemIndex    = index;
                            command.NewItemIndex = index - 1;
                            command.Execute();
                            OnCanExecuteChanged(new EventArgs());
                            cmdMoveToRight.OnCanExecuteChanged(new EventArgs());
                        }
                    }
                }
            }
        }