/// <summary> /// Closes the current connection, editing tables and puts the schema panel in focus. /// </summary> /// <param name="askToCloseConnections">Flag indicating whether users are asked for confirmation before closing active <see cref="EditConnectionInfo"/>.</param> /// <param name="givePanelFocus">Flag indicating whether the <see cref="SchemaSelectionPanel"/> is given focus.</param> /// <returns><c>true</c> if the schema and its open <see cref="EditConnectionInfo"/> objects are closed, <c>false</c> otherwise.</returns> public bool CloseSchema(bool askToCloseConnections, bool givePanelFocus) { if (askToCloseConnections && WorkbookConnectionInfos.GetWorkbookEditConnectionInfos(Globals.ThisAddIn.ActiveWorkbook).Count > 0) { // If there are Active OldStoredEditConnectionInfos warn the users that by closing the schema the active EditConnectionInfos will be closed. var dr = MiscUtilities.ShowCustomizedWarningDialog(Resources.ActiveEditConnectionInfosCloseWarningTitle, Resources.ActiveEditConnectionInfosCloseWarningDetail); if (dr == DialogResult.No) { return(false); } } WorkbookConnectionInfos.CloseWorkbookEditConnectionInfos(Globals.ThisAddIn.ActiveWorkbook); if (givePanelFocus) { SchemaSelectionPanel2.BringToFront(); } return(true); }
/// <summary> /// Event delegate method fired when the <see cref="DeleteToolStripMenuItem"/> context-menu item is clicked. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void DeleteToolStripMenuItem_Click(object sender, EventArgs e) { var selectedNode = ConnectionsList.SelectedNode; if (selectedNode == null || selectedNode.Type != MySqlListViewNode.MySqlNodeType.Connection || selectedNode.WbConnection == null) { return; } var dr = MiscUtilities.ShowCustomizedWarningDialog(Resources.DeleteConnectionWarningTitle, Resources.DeleteConnectionWarningDetail); if (dr == DialogResult.No) { return; } if (selectedNode.WbConnection != null && MySqlWorkbench.Connections.DeleteConnection(selectedNode.WbConnection.Id)) { LoadConnections(false); } }
/// <summary> /// Event delegate method fired when <see cref="ImportDataHotLabel"/> is clicked. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void ImportDataHotLabel_Click(object sender, EventArgs e) { var selectedNode = DBObjectList.SelectedNode; var parentTaskPane = Parent as ExcelAddInPane; if (selectedNode == null || parentTaskPane == null || selectedNode.Type != MySqlListViewNode.MySqlNodeType.DbObject || selectedNode.DbObject == null || _wbConnection == null) { return; } var passwordFlags = _wbConnection.TestConnectionAndRetryOnWrongPassword(); if (!passwordFlags.ConnectionSuccess) { return; } if (parentTaskPane.ActiveWorksheetInEditMode) { var dr = MiscUtilities.ShowCustomizedWarningDialog(Resources.WorksheetInEditModeWarningTitle, Resources.WorksheetInEditModeWarningDetail); if (dr != DialogResult.Yes) { return; } var newWorksheet = Globals.ThisAddIn.ActiveWorkbook.CreateWorksheet(selectedNode.DbObject.Name, true); if (newWorksheet == null) { return; } } try { DialogResult dr = DialogResult.Cancel; Cursor = Cursors.WaitCursor; var activeWorkbook = Globals.ThisAddIn.ActiveWorkbook; if (selectedNode.DbObject is DbTable) { var dbTable = selectedNode.DbObject as DbTable; dbTable.ImportParameters.ForEditDataOperation = false; using (var importForm = new ImportTableViewForm(dbTable, activeWorkbook.ActiveSheet.Name)) { dr = importForm.ShowDialog(); } } else if (selectedNode.DbObject is DbView) { var dbView = selectedNode.DbObject as DbView; dbView.ImportParameters.ForEditDataOperation = false; using (var importForm = new ImportTableViewForm(dbView, activeWorkbook.ActiveSheet.Name)) { dr = importForm.ShowDialog(); } } else if (selectedNode.DbObject is DbProcedure) { using (var importProcedureForm = new ImportProcedureForm(selectedNode.DbObject as DbProcedure, parentTaskPane.ActiveWorksheet.Name)) { dr = importProcedureForm.ShowDialog(); } } if (dr == DialogResult.OK) { RefreshActionLabelsEnabledStatus(null, false); } } catch (Exception ex) { MiscUtilities.ShowCustomizedErrorDialog(Resources.ImportDataErrorTitle, ex.Message, true); MySqlSourceTrace.WriteAppErrorToLog(ex); } finally { Cursor = Cursors.Default; } }