Example #1
0
        private void treeView_KeyPress(View.KeyEventEventArgs obj)
        {
            if (!_treeView.CanFocus || !_treeView.HasFocus)
            {
                return;
            }

            try
            {
                switch (obj.KeyEvent.Key)
                {
                case Key.DeleteChar:
                    var many = _treeView.GetAllSelectedObjects().ToArray();
                    obj.Handled = true;

                    //delete many at once?
                    if (many.Length > 1)
                    {
                        if (many.Cast <object>().All(d => d is IDeleteable))
                        {
                            var cmd = new ExecuteCommandDelete(_activator, many.Cast <IDeleteable>().ToArray());
                            if (!cmd.IsImpossible)
                            {
                                cmd.Execute();
                            }
                            else
                            {
                                _activator.Show("Cannot Delete", cmd.ReasonCommandImpossible);
                            }
                        }
                    }
                    else
                    if (_treeView.SelectedObject is IDeleteable d)
                    {
                        // it is a single object selection
                        _activator.DeleteWithConfirmation(d);
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                _activator.ShowException("Error", ex);
            }
        }
Example #2
0
        public void TestDeleteMultiple_OneObjectInheritsAnother()
        {
            var ei = WhenIHaveA <ExtractionInformation>();
            var ci = ei.CatalogueItem;

            ItemActivator.YesNoResponse = true;

            Assert.IsTrue(ci.Exists());
            Assert.IsTrue(ei.Exists());

            //now because we don't actually have a CASCADE in memory we will have to fake it
            ei.DeleteInDatabase();

            var cmd = new ExecuteCommandDelete(ItemActivator, new IDeleteable[] { ci, ei });

            cmd.Execute();

            Assert.IsFalse(ci.Exists());
            Assert.IsFalse(ei.Exists());
        }
        public void TestExtractionFilterDeleting_WhenItHas_ExtractionFilterParameterSet_Interactive()
        {
            var filter = WhenIHaveA <ExtractionFilter>();

            var set = new ExtractionFilterParameterSet(Repository, filter, "fff");

            Assert.IsTrue(filter.Exists());
            Assert.IsTrue(set.Exists());

            var activator = new TestActivateItems(this, Repository);

            activator.InteractiveDeletes = true;
            activator.YesNoResponse      = true;

            var del = new ExecuteCommandDelete(activator, filter);

            del.Execute();

            Assert.IsFalse(filter.Exists());
            Assert.IsFalse(set.Exists());
        }