Esempio n. 1
0
        /// <summary>
        /// Removes the PSM subtree under element <paramref name="e"/>.
        /// </summary>
        /// <param name="e">element under which the subtree is deleted</param>
        public void RemovePSMSubtree(Element e)
        {
            if (!(Diagram is PSMDiagram))
            {
                throw new InvalidOperationException("Method can be called only for PSM diagrams");
            }
            DeleteFromPSMDiagramConsideringRepresentativesMacroCommand c = (DeleteFromPSMDiagramConsideringRepresentativesMacroCommand)DeleteFromPSMDiagramConsideringRepresentativesMacroCommandFactory.Factory().Create(this);

            if (c.InitializeCommand(null, new [] { e }))
            {
                c.Execute();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes selected elements from the active diagram.
        /// </summary>
        /// <seealso cref="IDeletable"/>
        /// <param name="parameter">passed boolean value can set the ForceDelete flag</param>
        public override void Execute(object parameter)
        {
            IEnumerable <IModelElementRepresentant> _deleted = ActiveDiagramView.SelectedRepresentants;
            List <Element> deleted = new List <Element>(_deleted.Count());

            foreach (IModelElementRepresentant deletable in _deleted)
            {
                deleted.Add(ActiveDiagramView.ElementRepresentations.GetElementRepresentedBy(deletable));
            }
            DeleteFromPSMDiagramConsideringRepresentativesMacroCommand c =
                (DeleteFromPSMDiagramConsideringRepresentativesMacroCommand)DeleteFromPSMDiagramConsideringRepresentativesMacroCommandFactory.Factory().Create(ActiveDiagramView.Controller);

            if (parameter is bool)
            {
                c.ForceDelete = (bool)parameter;
            }

            if (c.InitializeCommand(SelectionCallback, deleted))
            {
                c.Execute();
            }
        }