Ejemplo n.º 1
0
        /// <summary>
        /// Returns the appropriate strategy to delete
        /// </summary>
        /// <param name="itemToDelete">The item to delete.</param>
        /// <returns></returns>
        /// <exception cref="NotSupportedException"></exception>
        internal IDeleteStrategy Create(TreeItem itemToDelete)
        {
            IDialogService dialogService = new DialogService();

            if (itemToDelete.GetType() == typeof(DatabaseItem))
            {
                return(new DatabaseDeleteStrategy(dialogService));
            }
            if (itemToDelete.GetType() == typeof(TableItem))
            {
                return(new TableDeleteStrategy(dialogService));
            }
            if (itemToDelete.GetType() == typeof(TriggerItem))
            {
                return(new TriggerDeleteStrategy(dialogService));
            }
            if (itemToDelete.GetType() == typeof(ViewItem))
            {
                return(new ViewDeleteStrategy(dialogService));
            }
            if (itemToDelete.GetType() == typeof(IndexItem))
            {
                return(new IndexDeleteStrategy(dialogService));
            }

            throw new NotSupportedException();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates the tabs for the specified tree item depending on its type.
        /// </summary>
        /// <param name="treeItem">The tree item.</param>
        /// <returns></returns>
        public static List <TabItem> GenerateTabsFor(TreeItem treeItem)
        {
            if (treeItem == null)
            {
                return(GenerateDefaultTabs());
            }

            if (treeItem.GetType() == typeof(DatabaseItem))
            {
                return(GenerateDatabaseTabs((DatabaseItem)treeItem));
            }
            if (treeItem.GetType() == typeof(TableItem))
            {
                return(GenerateTableTabs((TableItem)treeItem));
            }
            if (treeItem.GetType() == typeof(ViewItem))
            {
                return(GenerateViewTabs((ViewItem)treeItem));
            }
            if (treeItem.GetType() == typeof(IndexItem))
            {
                return(GenerateIndexTabs((IndexItem)treeItem));
            }
            if (treeItem.GetType() == typeof(TriggerItem))
            {
                return(GenerateTriggerTabs((TriggerItem)treeItem));
            }
            return(GenerateDefaultTabs());
        }
Ejemplo n.º 3
0
        private void Rename()
        {
            StatusInfo = string.Empty;
            var itemType = originalElement.GetType();

            try
            {
                if (itemType == typeof(DatabaseItem))
                {
                    RenameDatabase();
                }
                else if (itemType == typeof(TableItem))
                {
                    RenameTable();
                }
                else if (itemType == typeof(ViewItem))
                {
                    RenameView();
                }
                else if (itemType == typeof(IndexItem))
                {
                    RenameIndex();
                }
                else if (itemType == typeof(TriggerItem))
                {
                    RenameTrigger();
                }

                StatusInfo = LocalisationHelper.GetString("ElementRenameWindow_Success");
                originalElement.DisplayName = NewName;
                WindowTitle = LocalisationHelper.GetString("WindowTitle_RenameElement", NewName);
            }
            catch (Exception ex)
            {
                logger.Warn("Failed to rename the element '" + originalElement.DisplayName + "' from RenameWindow.", ex);
                dialogService.ShowMessage("MessageBox_NameChangeFailed");
            }
        }
Ejemplo n.º 4
0
        internal void Delete(TreeItem treeItem)
        {
            var factory = new DeleteStrategyFactory();

            try
            {
                var deleteStrategy = factory.Create(treeItem);
                deleteStrategy.Execute(treeViewItems, treeItem);
            }
            catch (Exception ex)
            {
                log.Error("Failed to delete item '" + treeItem.DisplayName + "' of type  " + treeItem.GetType() + ".", ex);
                StatusBarInfo = ex.Message.Replace("SQL logic error or missing database\r\n", "SQL-Error - ");
            }
        }