public CommonTab(FormattedSQLBuilder builder, SQLBuilderSelectFormat selectFormat) { InitializeComponent(); _builder = builder; _formattingOptions = (SQLFormattingOptions)_builder.Options; _selectFormat = selectFormat; }
public SubQueryTab(SQLFormattingOptions formattingOptions, string prefix = "Sub-Query") { InitializeComponent(); _formattingOptions = formattingOptions; if (prefix == "Sub-Query") { _selectFormat = formattingOptions.ExpressionSubQueryFormat; } if (prefix == "Derived Tables") { groupBox1.Text = "Derived tables format options"; label1.Text = "Derived tables indent:"; chBxSubQueriesFromNewLines.Text = "Start derived tables from new lines"; label2.Text = "Derived Tables format options\n" + "determine the layout of sub-queries\n" + "used as data sources in the query."; _selectFormat = formattingOptions.DerivedQueryFormat; } if (prefix == "CTE") { groupBox1.Text = "Common table expressions format options"; label1.Text = "CTE indent:"; chBxSubQueriesFromNewLines.Text = "Start derived tables from new lines"; label2.Text = "Derived Tables format options\n" + "determine the layout of sub-queries\n" + "used above the main query in the with clause."; _selectFormat = formattingOptions.CTESubQueryFormat; } }
public MainQueryTab(SQLFormattingOptions options) { InitializeComponent(); Options = options; LoadOptions(); }
public ContentWindowChild(SQLContext sqlContext) { Init(); SqlContext = sqlContext; SqlSourceType = SourceType.New; SqlQuery = new SQLQuery(SqlContext); SqlQuery.SQLUpdated += SqlQuery_SQLUpdated; SqlQuery.QueryRoot.AllowSleepMode = true; SqlQuery.QueryAwake += SqlQueryOnQueryAwake; SqlQuery.SleepModeChanged += SqlQuery_SleepModeChanged; NavigationBar.QueryView = QueryView; QueryView.Query = SqlQuery; QueryView.ActiveUnionSubQueryChanged += QueryView_ActiveUnionSubQueryChanged; BoxSql.Query = SqlQuery; BoxSqlCurrentSubQuery.Query = SqlQuery; BoxSqlCurrentSubQuery.ExpressionContext = QueryView.ActiveUnionSubQuery; QueryView.ActiveUnionSubQueryChanged += delegate { BoxSqlCurrentSubQuery.ExpressionContext = QueryView.ActiveUnionSubQuery; }; _transformerSql = new QueryTransformer(); _timerStartingExecuteSql = new Timer(TimerStartingExecuteSql_Elapsed); CBuilder.QueryTransformer = new QueryTransformer { Query = SqlQuery }; // Options to present the formatted SQL query text to end-user // Use names of virtual objects, do not replace them with appropriate derived tables SqlFormattingOptions = new SQLFormattingOptions { ExpandVirtualObjects = false }; // Options to generate the SQL query text for execution against a database server // Replace virtual objects with derived tables SqlGenerationOptions = new SQLGenerationOptions { ExpandVirtualObjects = true }; NavigationBar.QueryView = QueryView; NavigationBar.Query = SqlQuery; CBuilder.QueryTransformer.SQLUpdated += QueryTransformer_SQLUpdated; DataViewerResult.QueryTransformer = CBuilder.QueryTransformer; DataViewerResult.SqlQuery = SqlQuery; UpdateStateButtons(); }
public CommonTab(SQLFormattingOptions formattingOptions, SQLBuilderSelectFormat selectFormat) { InitializeComponent(); SelectFormat = selectFormat; FormattingOptions = formattingOptions; LoadOptions(); }
public ExpressionsTab(SQLFormattingOptions sqlFormattingOptions, SQLBuilderSelectFormat sqlBuilderSelectFormat) { InitializeComponent(); SelectFormat = sqlBuilderSelectFormat; FormattingOptions = sqlFormattingOptions; LoadOptions(); }
public MainQueryTab(SQLFormattingOptions sqlFormattingOptions) { InitializeComponent(); foreach (var value in typeof(KeywordFormat).GetEnumValues()) { ComboBoxKeywordCase.Items.Add(value); } Options = sqlFormattingOptions; LoadOptions(); }
public void CreateDefaultOptions() { BehaviorOptions = new BehaviorOptions(); DatabaseSchemaViewOptions = new DatabaseSchemaViewOptions(); DesignPaneOptions = new DesignPaneOptions(); VisualOptions = new VisualOptions(); AddObjectDialogOptions = new AddObjectDialogOptions(); DataSourceOptions = new DataSourceOptions(); QueryNavBarOptions = new QueryNavBarOptions(); UserInterfaceOptions = new UserInterfaceOptions(); SqlFormattingOptions = new SQLFormattingOptions(); SqlGenerationOptions = new SQLGenerationOptions(); }
public SqlGenerationPage(SQLGenerationOptions generationOptions, SQLFormattingOptions formattingOptions) : this() { _generationOptions = generationOptions; _formattingOptions = formattingOptions; foreach (var value in Enum.GetValues(_generationOptions.ObjectPrefixSkipping.GetType())) { cbObjectPrefixSkipping.Items.Add(value); } cbObjectPrefixSkipping.SelectedItem = _generationOptions.ObjectPrefixSkipping; cbQuoteAllIdentifiers.Checked = _generationOptions.QuoteIdentifiers == IdentQuotation.All; }
private void _query_SQLUpdated(object sender, EventArgs e) { // at this stage you can get simple unformatted query text... //SqlBox.Text = _query.SQL; // ... or format the query text with SQL formatter SQLFormattingOptions formattingOptions = new SQLFormattingOptions { KeywordFormat = KeywordFormat.UpperCase }; var sql = FormattedSQLBuilder.GetSQL(_query.QueryRoot, formattingOptions); // put the result SQL query text to the text box SqlBox.Text = sql; }
public ChildForm(SQLContext sqlContext, ConnectionInfo connectionInfo) { InitializeComponent(); _queryTransformerTop10 = new QueryTransformer(); Debug.Assert(sqlContext != null); SqlSourceType = SourceType.New; _sqlContext = sqlContext; _connectionInfo = connectionInfo; SqlQuery = new SQLQuery(_sqlContext); SqlQuery.QueryRoot.AllowSleepMode = true; SqlQuery.SleepModeChanged += SqlQuery_SleepModeChanged; SqlQuery.QueryAwake += SqlQuery_QueryAwake; _timerForFastResult = new Timer(TimerForFastResult_Elapsed); CBuilder.QueryTransformer = new QueryTransformer { Query = SqlQuery }; SqlFormattingOptions = new SQLFormattingOptions(); CBuilder.QueryTransformer.SQLUpdated += CBuilder_SQLUpdated; rtbQueryText.QueryProvider = SqlQuery; TextBoxCurrentSubQuerySql.QueryProvider = SqlQuery; resultGrid1.SqlQuery = SqlQuery; resultGrid2.SqlQuery = SqlQuery; resultGrid1.QueryTransformer = CBuilder.QueryTransformer; QView.Query = SqlQuery; NavBar.QueryView = QView; NavBar.Query = SqlQuery; RepairImageLists(); toolStripStatusLabel1.Text = "Query builder state: " + ((SqlQuery.SleepMode) ? "Inactive" : "Active"); Application.Idle += Application_Idle; SqlQuery.SQLUpdated += query_SQLUpdated; QueryView.ActiveUnionSubQueryChanged += QueryViewOnActiveUnionSubQueryChanged; rtbQueryText.ExpressionContext = QView.ActiveUnionSubQuery; TextBoxCurrentSubQuerySql.ExpressionContext = QView.ActiveUnionSubQuery; QueryNavBarOptions.Updated += QueryNavBarOptions_Updated; }
public void CreateDefaultOptions() { BehaviorOptions = new BehaviorOptions(); DatabaseSchemaViewOptions = new DatabaseSchemaViewOptions(); DesignPaneOptions = new DesignPaneOptions(); VisualOptions = new VisualOptions(); AddObjectDialogOptions = new AddObjectDialogOptions(); DataSourceOptions = new DataSourceOptions(); QueryNavBarOptions = new QueryNavBarOptions(); UserInterfaceOptions = new UserInterfaceOptions(); SqlFormattingOptions = new SQLFormattingOptions(); SqlGenerationOptions = new SQLGenerationOptions(); ExpressionEditorOptions = new ExpressionEditorOptions(); TextEditorOptions = new TextEditorOptions { Padding = DefaultTextEditorPadding, LineHeight = new LengthUnit(90, SizeUnitType.Percent) }; TextEditorSqlOptions = new SqlTextEditorOptions(); }
public SubQueryTab(SQLFormattingOptions formattingOptions, SubQueryType subQueryType = SubQueryType.Expression) { FormattingOptions = new SQLFormattingOptions(); InitializeComponent(); FormattingOptions.Dispose(); FormattingOptions = formattingOptions; switch (subQueryType) { case SubQueryType.Expression: SelectFormat = formattingOptions.ExpressionSubQueryFormat; break; case SubQueryType.Derived: GroupBoxControl.Header = "Derived tables format options"; TextBlockCaptionUpDown.Text = "Derived tables indent:"; CheckBoxStartSubQueriesNewLine.Content = "Start derived tables from new lines"; TextBlockDescription.Text = "Derived Tables format options\n" + "determine the layout of sub-queries\n" + "used as data sources in the query."; SelectFormat = formattingOptions.DerivedQueryFormat; break; case SubQueryType.Cte: GroupBoxControl.Header = "Common table expressions format options"; TextBlockCaptionUpDown.Text = "CTE indent:"; CheckBoxStartSubQueriesNewLine.Content = "Start CTE from new lines"; TextBlockDescription.Text = "CTE format options\n" + "determine the layout of sub-queries\n" + "used above the main query in the with clause."; SelectFormat = formattingOptions.CTESubQueryFormat; break; } LoadOptions(); }
public GeneralPage(SQLFormattingOptions sqlFormattingOptions) { Modified = false; _sqlFormattingOptions = sqlFormattingOptions; InitializeComponent(); cbWordWrap.Checked = (_sqlFormattingOptions.RightMargin != 0); updownRightMargin.Enabled = cbWordWrap.Checked; updownRightMargin.Value = _sqlFormattingOptions.RightMargin == 0 ? 80 : _sqlFormattingOptions.RightMargin; comboKeywordsCasing.Items.Add("Capitalized"); comboKeywordsCasing.Items.Add("Uppercase"); comboKeywordsCasing.Items.Add("Lowercase"); comboKeywordsCasing.SelectedIndex = (int)_sqlFormattingOptions.KeywordFormat; cbWordWrap.CheckedChanged += checkWordWrap_CheckedChanged; updownRightMargin.ValueChanged += updownRightMargin_ValueChanged; comboKeywordsCasing.SelectedIndexChanged += comboKeywordsCasing_SelectedIndexChanged; }
public ChildWindow(SQLContext sqlContext, DatabaseSchemaView databaseSchemaView) { ContentControl = new ContentWindowChild(sqlContext); _sqlFormattingOptions = new SQLFormattingOptions { ExpandVirtualObjects = false }; _databaseSchemaView = databaseSchemaView; Children.Add(ContentControl); Loaded += delegate { if (double.IsNaN(Width)) { Width = ActualWidth; } if (double.IsNaN(Height)) { Height = ActualHeight; } }; }
public SubQueryTab(SQLFormattingOptions formattingOptions, SubQueryType type = SubQueryType.Expression) { InitializeComponent(); FormattingOptions = formattingOptions; if (type == SubQueryType.Expression) { SelectFormat = formattingOptions.ExpressionSubQueryFormat; } else if (type == SubQueryType.Derived) { groupBox1.Text = "Derived tables format options"; label1.Text = "Derived tables indent:"; chBxSubQueriesFromNewLines.Text = "Start derived tables from new lines"; label2.Text = "Derived Tables format options\n" + "determine the layout of sub-queries\n" + "used as data sources in the query."; SelectFormat = formattingOptions.DerivedQueryFormat; } else if (type == SubQueryType.Cte) { groupBox1.Text = "Common table expressions format options"; label1.Text = "CTE indent:"; chBxSubQueriesFromNewLines.Text = "Start CTE from new lines"; label2.Text = "CTE format options\n" + "determine the layout of sub-queries\n" + "used above the main query in the with clause."; SelectFormat = formattingOptions.CTESubQueryFormat; } LoadOptions(); }
public void OnSQLUpdated(object sender, EventArgs e) { var qb = QueryBuilderStore.Get("AlternateNames"); var opts = new SQLFormattingOptions(); opts.Assign(qb.SQLFormattingOptions); opts.KeywordFormat = KeywordFormat.UpperCase; // get SQL query with real object names opts.UseAltNames = false; var plainSql = FormattedSQLBuilder.GetSQL(qb.SQLQuery.QueryRoot, opts); // get SQL query with alternate names opts.UseAltNames = true; var sqlWithAltNames = FormattedSQLBuilder.GetSQL(qb.SQLQuery.QueryRoot, opts); // prepare additional data to be sent to the client qb.ExchangeData = new { SQL = plainSql, AlternateSQL = sqlWithAltNames }; }
public void OnSQLUpdated(object sender, EventArgs e) { var qb = QueryBuilderStore.Get(InstanceId); var opts = new SQLFormattingOptions(); opts.Assign(qb.SQLFormattingOptions); opts.KeywordFormat = KeywordFormat.UpperCase; // get query with virtual objects and fields opts.ExpandVirtualObjects = false; var sqlWithVirtObjects = FormattedSQLBuilder.GetSQL(qb.SQLQuery.QueryRoot, opts); // get SQL query with real object names opts.ExpandVirtualObjects = true; var plainSql = FormattedSQLBuilder.GetSQL(qb.SQLQuery.QueryRoot, opts); // prepare additional data to be sent to the client qb.ExchangeData = new { SQL = plainSql, VirtualObjectsSQL = sqlWithVirtObjects }; }
public SqlFormattingPage(SqlBuilderOptionsPages page, SQLFormattingOptions sqlFormattingOptions) { Modified = false; _page = page; _sqlFormattingOptions = sqlFormattingOptions; _format = new SQLBuilderSelectFormat(null); if (_page == SqlBuilderOptionsPages.MainQuery) { _format.Assign(sqlFormattingOptions.MainQueryFormat); } else if (_page == SqlBuilderOptionsPages.DerivedQueries) { _format.Assign(sqlFormattingOptions.DerivedQueryFormat); } else if (_page == SqlBuilderOptionsPages.ExpressionSubqueries) { _format.Assign(sqlFormattingOptions.ExpressionSubQueryFormat); } InitializeComponent(); cbPartsOnNewLines.Checked = _format.MainPartsFromNewLine; cbNewLineAfterKeywords.Checked = _format.NewLineAfterPartKeywords; updownGlobalIndent.Value = _format.IndentGlobal; updownPartIndent.Value = _format.IndentInPart; cbNewLineAfterSelectItem.Checked = _format.SelectListFormat.NewLineAfterItem; cbNewLineAfterDatasource.Checked = _format.FromClauseFormat.NewLineAfterDatasource; cbNewLineAfterJoin.Checked = _format.FromClauseFormat.NewLineAfterJoin; cbNewLineWhereTop.Checked = (_format.WhereFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.AllLogical || _format.WhereFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.TopmostOr || _format.WhereFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.TopmostLogical); checkNewLineWhereTop_CheckedChanged(null, new EventArgs()); cbNewLineWhereRest.Checked = (_format.WhereFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.AllLogical); checkNewLineWhereRest_CheckedChanged(null, new EventArgs()); updownWhereIndent.Value = _format.WhereFormat.IndentNestedConditions; cbNewLineAfterGroupItem.Checked = _format.GroupByFormat.NewLineAfterItem; cbNewLineHavingTop.Checked = (_format.HavingFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.AllLogical || _format.HavingFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.TopmostOr || _format.HavingFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.TopmostLogical); checkNewLineHavingTop_CheckedChanged(null, new EventArgs()); cbNewLineHavingRest.Checked = (_format.HavingFormat.NewLineAfter == SQLBuilderConditionFormatNewLine.AllLogical); checkNewLineHavingRest_CheckedChanged(null, new EventArgs()); updownHavingIndent.Value = _format.HavingFormat.IndentNestedConditions; updownHavingIndent.ValueChanged += Changed; updownHavingIndent.TextChanged += Changed; cbNewLineHavingRest.CheckedChanged += checkNewLineHavingRest_CheckedChanged; cbNewLineHavingTop.CheckedChanged += checkNewLineHavingTop_CheckedChanged; cbNewLineAfterGroupItem.CheckedChanged += Changed; updownWhereIndent.ValueChanged += Changed; updownWhereIndent.TextChanged += Changed; cbNewLineWhereRest.CheckedChanged += checkNewLineWhereRest_CheckedChanged; cbNewLineWhereTop.CheckedChanged += checkNewLineWhereTop_CheckedChanged; cbNewLineAfterJoin.CheckedChanged += Changed; cbNewLineAfterDatasource.CheckedChanged += Changed; cbNewLineAfterSelectItem.CheckedChanged += Changed; updownPartIndent.ValueChanged += Changed; updownPartIndent.TextChanged += Changed; updownGlobalIndent.ValueChanged += Changed; updownGlobalIndent.TextChanged += Changed; cbNewLineAfterKeywords.CheckedChanged += Changed; cbPartsOnNewLines.CheckedChanged += Changed; }
public MainQueryTab(FormattedSQLBuilder builder) { _builder = builder; _options = (SQLFormattingOptions)builder.Options; InitializeComponent(); }
public MainWindow() { // Options to present the formatted SQL query text to end-user // Use names of virtual objects, do not replace them with appropriate derived tables _sqlFormattingOptions = new SQLFormattingOptions { ExpandVirtualObjects = false }; // Options to generate the SQL query text for execution against a database server // Replace virtual objects with derived tables _sqlGenerationOptions = new SQLGenerationOptions { ExpandVirtualObjects = true }; InitializeComponent(); Closing += MainWindow_Closing; MdiContainer1.ActiveWindowChanged += MdiContainer1_ActiveWindowChanged; Dispatcher.CurrentDispatcher.Hooks.DispatcherInactive += Hooks_DispatcherInactive; var currentLang = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; LoadLanguage(); var defLang = "en"; if (Helpers.Localizer.Languages.Contains(currentLang.ToLower())) { Language = XmlLanguage.GetLanguage(currentLang); defLang = currentLang.ToLower(); } var menuItem = MenuItemLanguage.Items.Cast <MenuItem>().First(item => (string)item.Tag == defLang); menuItem.IsChecked = true; TryToLoadOptions(); // DEMO WARNING if (BuildInfo.GetEdition() == BuildInfo.Edition.Trial) { var trialNoticePanel = new Border { BorderBrush = Brushes.Black, BorderThickness = new Thickness(1), Background = Brushes.LightGreen, Padding = new Thickness(5), Margin = new Thickness(0, 0, 0, 2) }; trialNoticePanel.SetValue(Grid.RowProperty, 1); var label = new TextBlock { Text = @"Generation of random aliases for the query output columns is the limitation of the trial version. The full version is free from this behavior.", HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; var button = new Button { Background = Brushes.Transparent, Padding = new Thickness(0), BorderThickness = new Thickness(0), Cursor = Cursors.Hand, Margin = new Thickness(0, 0, 5, 0), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Content = new Image { Source = Properties.Resources.cancel.GetImageSource(), Stretch = Stretch.None } }; button.Click += delegate { GridRoot.Visibility = Visibility.Collapsed; }; trialNoticePanel.Child = label; GridRoot.Children.Add(trialNoticePanel); GridRoot.Children.Add(button); } }
public MainForm() { InitializeComponent(); // Options to present the formatted SQL query text to end-user // Use names of virtual objects, do not replace them with appropriate derived tables _sqlFormattingOptions = new SQLFormattingOptions { ExpandVirtualObjects = false }; // Options to generate the SQL query text for execution against a database server // Replace virtual objects with derived tables _sqlGenerationOptions = new SQLGenerationOptions { ExpandVirtualObjects = true }; if (Program.Settings.WindowPlacement == Rectangle.Empty) { StartPosition = FormStartPosition.WindowsDefaultLocation; } else { Bounds = Program.Settings.WindowPlacement; } if (Program.Settings.IsMaximized) { WindowState = FormWindowState.Maximized; } LoadLanguages(); SizeChanged += MainForm_SizeChanged; LocationChanged += MainForm_LocationChanged; MdiChildActivate += MainForm_MdiChildActivate; Application.Idle += Application_Idle; DBView.ItemDoubleClick += DBView_ItemDoubleClick; TryToLoadOptions(); // DEMO WARNING if (BuildInfo.GetEdition() == BuildInfo.Edition.Trial) { Panel trialNoticePanel = new Panel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, BackColor = Color.LightGreen, BorderStyle = BorderStyle.FixedSingle, Dock = DockStyle.Top, Padding = new Padding(6, 5, 3, 0), }; Label label = new Label { AutoSize = true, Margin = new Padding(0), Text = @"Generation of random aliases for the query output columns is the limitation of the trial version. The full version is free from this behavior.", Dock = DockStyle.Fill, UseCompatibleTextRendering = true }; var buttonClose = new PictureBox { Image = Properties.Resources.cancel, SizeMode = PictureBoxSizeMode.AutoSize, Cursor = Cursors.Hand }; buttonClose.Click += delegate { Controls.Remove(trialNoticePanel); }; trialNoticePanel.Controls.Add(buttonClose); trialNoticePanel.Resize += delegate { buttonClose.Location = new Point(trialNoticePanel.Width - buttonClose.Width - 10, trialNoticePanel.Height / 2 - buttonClose.Height / 2); }; trialNoticePanel.Controls.Add(label); Controls.Add(trialNoticePanel); Controls.SetChildIndex(trialNoticePanel, 2); } }