private void UpdateUI() { ModuleProxy moduleProxy = ModuleProxy.GetInstance(); if (moduleProxy != null) { moduleProxy.Module.UpdateUI(); } }
private void OkButton_Click(object sender, EventArgs e) { _nameTextBox.BackColor = Color.Empty; _connectionStringTextBox.BackColor = Color.Empty; string name = _nameTextBox.Text.Trim(); string connectionString = _connectionStringTextBox.Text.Trim(); SqlDataProvider provider = _providerComboBox.SelectedItem as SqlDataProvider; if (provider == null) { throw new Exception( Resources.ConnectionInvalidProvider); } bool validated = true; if (name == String.Empty) { validated = false; _nameTextBox.BackColor = Color.Yellow; } if (connectionString == String.Empty) { validated = false; _connectionStringTextBox.BackColor = Color.Yellow; } if (validated) { if (_connectionId == null) { _connectionId = Guid.NewGuid().ToString(); } SqlConnection cnn = new SqlConnection( _connectionId, name, connectionString, provider); _sqlConnections[_connectionId] = cnn; ModuleProxy.GetInstance().Module.DisableConnection(); DialogResult = DialogResult.OK; } }
private void ActivatePlugin() { ModuleProxy.GetInstance().Module = this; _applicationManager = ApplicationManager.GetInstance(); _pluginManager = PluginManager.GetInstance(); _sqlConnectionManager = SqlConnectionManager.GetInstance(); _sqlConnectionManager.Load(); /* * Enable SqlMetal/DMBL extract features if client flag set. */ bool enableSqlMetal = _applicationManager.ClientProfile.HaveFlag( ClientFlags.SqlManagerEnableDbmlExtract); _output = _applicationManager.GetDockedForm( QuickSharp.Output.Constants.DOCKED_FORM_KEY) as OutputForm; _toolsMenuRunQuery = MenuTools.CreateMenuItem( Constants.UI_TOOLS_MENU_RUN_QUERY, Resources.MainToolsMenuRunQuery, Resources.RunQuery, Keys.F5, null, UI_TOOLBAR_RUN_SQL_QUERY_Click, true); ToolStripMenuItem toolsMenu = _mainForm.GetMenuItemByName( QuickSharp.Core.Constants.UI_TOOLS_MENU); int index = toolsMenu.DropDownItems.IndexOfKey( QuickSharp.Core.Constants.UI_TOOLS_MENU_OPTIONS); /* * If menu not found insert at the top. */ if (index == -1) { index = 0; } toolsMenu.DropDownItems.Insert(index, _toolsMenuRunQuery); /* * Create toolbar buttons. */ _toolbarSqlConnection = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SQL_CONNECTION, Resources.ToolbarSqlConnection, Resources.SqlConnection, UI_TOOLBAR_SQL_CONNECTION_Click, true); _toolbarSqlConnection.ToolTipText = Resources.ToolbarActivateConnection; _toolbarSqlConnectionSelect = MenuTools.CreateToolbarDropDownButton( Constants.UI_TOOLBAR_SQL_CONNECTION_SELECT, null); _toolbarSqlConnectionSelect.DropDownOpening += new EventHandler( ToolbarSqlConnectionSelect_DropDownOpening); _toolbarSqlRunQuery = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SQL_RUN_QUERY, Resources.ToolbarSqlRunQuery, Resources.RunQuery, UI_TOOLBAR_RUN_SQL_QUERY_Click); _toolbarSqlExtractDbml = MenuTools.CreateToolbarButton( Constants.UI_TOOLBAR_SQL_EXTRACT_DBML, Resources.ToolbarSqlExtractDbml, Resources.ExtractDbml, UI_TOOLBAR_SQL_EXTRACT_DBML_Click); _mainForm.MainToolbar.Items.Add(_toolbarSqlConnection); _mainForm.MainToolbar.Items.Add(_toolbarSqlConnectionSelect); _mainForm.MainToolbar.Items.Add(_toolbarSqlRunQuery); if (enableSqlMetal) { _mainForm.MainToolbar.Items.Add(_toolbarSqlExtractDbml); } _mainForm.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); _mainForm.ClientWindow.ActiveDocumentChanged += new EventHandler(ClientWindow_ActiveDocumentChanged); _applicationManager.RegisterOptionsPageFactory( delegate { return(new SqlConnectionsOptionsPage()); }); if (enableSqlMetal) { _applicationManager.RegisterOptionsPageFactory( delegate { return(new SqlMetalOptionsPage()); }); } _applicationManager.FileSystemChange += new MessageHandler(UpdateUI); /* * We don't have any build tools but we want SQL files * recognised as source files. Register with the * non-tool source files list in the application store. */ ApplicationStorage appStore = ApplicationStorage.GetInstance(); /* * We have no dependency on the BuildTools plugin so we * can't assume the non-tool source list has been created. * Use the Get method to create the list if it doesn't exist. */ List <String> nonToolSourceTypes = appStore.Get( Constants.APP_STORE_KEY_NON_TOOL_SOURCE_TYPES, typeof(List <String>)) as List <String>; if (nonToolSourceTypes != null) { nonToolSourceTypes.Add(Constants.DOCUMENT_TYPE_SQL); } UpdateUI(); }