Exemplo n.º 1
0
        protected void OnInsertQueryOnClipboard()
        {
            TableNode           node           = CurrentNode.DataItem as TableNode;
            IEditSchemaProvider schemaProvider = (IEditSchemaProvider)node.ConnectionContext.SchemaProvider;

            Gtk.Clipboard clp = Clipboard.Get(Gdk.Selection.Clipboard);
            clp.Text = schemaProvider.GetInsertQuery(node.Table);
            MessageService.ShowMessage(AddinCatalog.GetString("INSERT INTO Statement has been copied to Clipboard."));
        }
Exemplo n.º 2
0
        protected void OnShowDefinitionOnClipboard()
        {
            TableNode           node           = CurrentNode.DataItem as TableNode;
            IEditSchemaProvider schemaProvider = (IEditSchemaProvider)node.ConnectionContext.SchemaProvider;

            Gtk.Clipboard clp = Clipboard.Get(Gdk.Selection.Clipboard);
            clp.Text = schemaProvider.GetTableCreateStatement(node.Table);
            MessageService.ShowMessage(AddinCatalog.GetString("CREATE Statement has been copied to Clipboard."));
        }
Exemplo n.º 3
0
        public override void RenameItem(string newName)
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            if (node.Table.Name != newName)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(RenameItemThreaded), new object[] { node, newName });
            }
        }
Exemplo n.º 4
0
        protected void OnShowDefinitionOnNewWindow()
        {
            TableNode           node           = CurrentNode.DataItem as TableNode;
            IEditSchemaProvider schemaProvider = (IEditSchemaProvider)node.ConnectionContext.SchemaProvider;
            SqlQueryView        view           = new SqlQueryView();

            view.SelectedConnectionContext = node.ConnectionContext;
            view.TextEditor.Insert(0, schemaProvider.GetTableCreateStatement(node.Table));
            IdeApp.Workbench.OpenDocument(view, true);
        }
Exemplo n.º 5
0
        protected void OnAlterTable()
        {
            TableNode       node           = CurrentNode.DataItem as TableNode;
            IDbFactory      fac            = node.ConnectionContext.DbFactory;
            ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider;

            if (fac.GuiProvider.ShowTableEditorDialog(schemaProvider, node.Table, false))
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(OnAlterTableThreaded), CurrentNode.DataItem);
            }
        }
Exemplo n.º 6
0
        protected void OnDropTable()
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            if (Services.MessageService.AskQuestion(
                    GettextCatalog.GetString("Are you sure you want to drop table '{0}'", node.Table.Name),
                    GettextCatalog.GetString("Drop Table")
                    ))
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(OnDropTableThreaded), CurrentNode.DataItem);
            }
        }
Exemplo n.º 7
0
        protected void OnSelectAllCommand()
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            IdentifierExpression tableId = new IdentifierExpression(node.Table.Name);
            SelectStatement      sel     = new SelectStatement(new FromTableClause(tableId));

            IPooledDbConnection conn    = node.ConnectionContext.ConnectionPool.Request();
            IDbCommand          command = conn.CreateCommand(sel);

            conn.ExecuteTableAsync(command, new ExecuteCallback <DataTable> (OnSelectCommandThreaded), null);
        }
Exemplo n.º 8
0
        protected void OnDropTable()
        {
            TableNode   node       = (TableNode)CurrentNode.DataItem;
            AlertButton dropButton = new AlertButton(AddinCatalog.GetString("Drop"), Gtk.Stock.Delete);

            if (MessageService.Confirm(
                    AddinCatalog.GetString("Are you sure you want to drop table '{0}'", node.Table.Name),
                    dropButton
                    ))
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(OnDropTableThreaded), CurrentNode.DataItem);
            }
        }
Exemplo n.º 9
0
        protected void OnShowDefinitionOnCurrentWindow()
        {
            TableNode           node           = CurrentNode.DataItem as TableNode;
            IEditSchemaProvider schemaProvider = (IEditSchemaProvider)node.ConnectionContext.SchemaProvider;

            if (IdeApp.Workbench.ActiveDocument.IsFile && !IdeApp.Workbench.ActiveDocument.IsViewOnly)
            {
                IdeApp.Workbench.ActiveDocument.Editor.InsertAtCaret(schemaProvider.GetTableCreateStatement(node.Table));
            }
            else
            {
                MessageService.ShowError(AddinCatalog.GetString("Cannot insert text into the current window."));
            }
        }
Exemplo n.º 10
0
        protected void OnDeleteQueryOnCurrentWindow()
        {
            TableNode           node           = CurrentNode.DataItem as TableNode;
            IEditSchemaProvider schemaProvider = (IEditSchemaProvider)node.ConnectionContext.SchemaProvider;

            if (IdeApp.Workbench.ActiveDocument.IsFile && !IdeApp.Workbench.ActiveDocument.IsViewOnly)
            {
                IdeApp.Workbench.ActiveDocument.TextEditor.InsertText(IdeApp.Workbench.ActiveDocument.TextEditor.CursorPosition,
                                                                      schemaProvider.GetDeleteQuery(node.Table));
            }
            else
            {
                MessageService.ShowError(AddinCatalog.GetString("Cannot insert text into the current window."));
            }
        }
Exemplo n.º 11
0
        protected void OnEmptyTable()
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            if (Services.MessageService.AskQuestion(
                    GettextCatalog.GetString("Are you sure you want to empty table '{0}'", node.Table.Name),
                    GettextCatalog.GetString("Empty Table")
                    ))
            {
                IdentifierExpression tableId = new IdentifierExpression(node.Table.Name);
                DeleteStatement      del     = new DeleteStatement(new FromTableClause(tableId));

                IPooledDbConnection conn    = node.ConnectionContext.ConnectionPool.Request();
                IDbCommand          command = conn.CreateCommand(del);
                conn.ExecuteNonQueryAsync(command, new ExecuteCallback <int> (OnEmptyTableCallback), null);
            }
        }
Exemplo n.º 12
0
        protected void OnQueryCommand()
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            IdentifierExpression tableId = new IdentifierExpression(node.Table.Name);
            SelectStatement      sel     = new SelectStatement(new FromTableClause(tableId));

            SqlQueryView view = new SqlQueryView();

            view.SelectedConnectionContext = node.ConnectionContext;

            IDbFactory fac = DbFactoryService.GetDbFactory(node.ConnectionContext.ConnectionSettings);

            view.Text = fac.Dialect.GetSql(sel);

            IdeApp.Workbench.OpenDocument(view, true);
        }
Exemplo n.º 13
0
        private void BuildChildNodesThreaded(object state)
        {
            TableNode    node    = state as TableNode;
            ITreeBuilder builder = Context.GetTreeBuilder(state);
            IDbFactory   fac     = node.ConnectionContext.DbFactory;

            if (fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.Columns))
            {
                DispatchService.GuiDispatch(delegate {
                    builder.AddChild(new ColumnsNode(node.ConnectionContext, node.Table));
                });
            }

            if (fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.PrimaryKeyConstraint) ||
                fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.ForeignKeyConstraint) ||
                fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.CheckConstraint) ||
                fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.UniqueConstraint)
                )
            {
                DispatchService.GuiDispatch(delegate {
                    builder.AddChild(new ConstraintsNode(node.ConnectionContext, node.Table));
                });
            }

            if (fac.IsCapabilitySupported("Table", SchemaActions.Schema, TableCapabilities.Trigger))
            {
                DispatchService.GuiDispatch(delegate {
                    builder.AddChild(new TriggersNode(node.ConnectionContext));
                });
            }

            //TODO: rules

            DispatchService.GuiDispatch(delegate {
                builder.Expanded = true;
            });
        }
Exemplo n.º 14
0
        private void RenameItemThreaded(object state)
        {
            object[] objs = state as object[];

            TableNode       node     = objs[0] as TableNode;
            string          newName  = objs[1] as string;
            ISchemaProvider provider = node.Table.SchemaProvider;

            if (provider.IsValidName(newName))
            {
                provider.RenameTable(node.Table, newName);
                node.Refresh();
            }
            else
            {
                DispatchService.GuiDispatch(delegate() {
                    Services.MessageService.ShowError(String.Format(
                                                          "Unable to rename table '{0}' to '{1}'!",
                                                          node.Table.Name, newName
                                                          ));
                });
            }
            node.Refresh();
        }
Exemplo n.º 15
0
        public override string GetNodeName(ITreeNavigator thisNode, object dataObject)
        {
            TableNode node = dataObject as TableNode;

            return(node.Table.Name);
        }