Skip to content

Commit

Permalink
Add option to omit the selected text popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekkonnect committed May 29, 2023
1 parent cd31fc5 commit e8d54fb
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 116 deletions.
11 changes: 10 additions & 1 deletion CHANGE.LOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
2023/05/29 v1.5.0 Feature: The SQL query editor now opens immediately after
loading a database.
Feature: Ctrl+Enter in the SQL query editor only
executes the surrounding statement around the cursor.
Optimization: Added an assembly dependency to the
System.Data.SqlServerCe assembly, and eliminated the
use of reflection to interact with it.
Feature: A new setting to avoid showing the popup
for only executing the selected text.
2017/07/13 v1.4.14 Fix bug: Failed to display tables of more than 255
fields.
2017/02/17 v1.4.13 Right-clicking on the header causes the width of
the column fit all cells.
Added German translation (Thanks to Peet Baldem).
Added German translation (Thanks to Peet Baldem).
2015/11/11 v1.4.12 Added traditional and simplified Chinese
translations (Thanks to Jordan Chen).
2015/08/31 v1.4.11 Added Turkish translation.
Expand Down
1 change: 1 addition & 0 deletions CompactView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<DependentUpon>AboutForm.cs</DependentUpon>
</Compile>
<Compile Include="ColorComboBox.cs" />
<Compile Include="DataSetExtensions.cs" />
<Compile Include="ExportForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
36 changes: 36 additions & 0 deletions DataSetExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**************************************************************************
Copyright (C) 2023 Rekkonnect
This file is part of CompactView.
CompactView is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CompactView is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CompactView. If not, see <http://www.gnu.org/licenses/>.
CompactView web site <http://sourceforge.net/p/compactview/>.
**************************************************************************/

using System.Data;

namespace CompactView
{
public static class DataSetExtensions
{
public static void ReadField<T>(this DataTable table, DataRow row, string name, ref T field)
{
if (table.Columns.Contains(name))
{
field = row.Field<T>(name);
}
}
}
}
4 changes: 3 additions & 1 deletion GlobalText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ private static void FillEnglish()
{ "Indexes", "Indexes" },
{ "Keys", "Keys" },
{ "TableConstraints", "Table Constraints" },
{ "ForeignConstraints", "Foreign Constraints" }
{ "ForeignConstraints", "Foreign Constraints" },
{ "BehaviorSettingsGroup", "Behavior" },
{ "ExecuteSelectedStatementWithoutAsking", "Always execute the selected statement without asking" },
};

string fileName = XmlName("en-EN");
Expand Down
11 changes: 6 additions & 5 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private void LoadDatabase(string fileName, string password)
{
GlobalText.ShowError("UnableToOpen", ex.Message);
btnQuery.Enabled = btnExecute.Enabled = btnClear.Enabled = false;
settings.RemoveFromRecentFiles(fileName);
settings.RecentFiles.Remove(fileName);
UpdateRecentFilesMenu();
}
Cursor = Cursors.Default;
Expand Down Expand Up @@ -454,18 +454,19 @@ private void ExecuteQuery(bool shouldWarnPartialSelection)
if (isEmptySql)
return;

bool partial = !string.IsNullOrWhiteSpace(rtbQuery.SelectedText);
shouldWarnPartialSelection &= partial;
bool isPartialSelection = !string.IsNullOrWhiteSpace(rtbQuery.SelectedText);
shouldWarnPartialSelection &= isPartialSelection
&& !settings.OmitSelectedTextExecutionPopup;
if (shouldWarnPartialSelection)
{
DialogResult result = MessageBox.Show(GlobalText.GetValue("SelectedTextQuery"), GlobalText.GetValue("Confirm"),
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result == DialogResult.Cancel)
return;

shouldWarnPartialSelection = result == DialogResult.Yes;
isPartialSelection = result == DialogResult.Yes;
}
string sql = shouldWarnPartialSelection
string sql = isPartialSelection
? rtbQuery.SelectedText.Trim()
: rtbQuery.Text.Trim();

Expand Down
35 changes: 32 additions & 3 deletions OptionsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions OptionsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void SetCultureTexts()
groupBox2.Text = GlobalText.GetValue("UserDefined");
btnOk.Text = GlobalText.GetValue("Ok");
btnCancel.Text = GlobalText.GetValue("Cancel");
behaviorGroupBox.Text = GlobalText.GetValue("Colors");
}

private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -211,5 +212,10 @@ private void cbColorSet_SelectedIndexChanged(object sender, EventArgs e)
label1.ForeColor = label3.ForeColor = dataGrid.DefaultCellStyle.ForeColor;
label2.ForeColor = label4.ForeColor = dataGrid.AlternatingRowsDefaultCellStyle.ForeColor;
}

private void alwaysExecuteSelectedStatementCheckBox_CheckedChanged(object sender, EventArgs e)
{
settings.OmitSelectedTextExecutionPopup = alwaysExecuteSelectedStatementCheckBox.Checked;
}
}
}
Loading

0 comments on commit e8d54fb

Please sign in to comment.