If the specified filename in SQL export dialog is empty, disable the execute button. If the file cannot be created for some reason, do not pop up a message dialog. Instead, log the error message into the result list. Fixes issue #1627.

This commit is contained in:
Ansgar Becker
2010-01-30 17:50:26 +00:00
parent 7196c7859d
commit fda4aa631f
2 changed files with 35 additions and 33 deletions

View File

@ -407,6 +407,7 @@ object frmTableTools: TfrmTableTools
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 6 TabOrder = 6
Text = 'comboExportOutputTarget' Text = 'comboExportOutputTarget'
OnChange = comboExportOutputTargetChange
OnExit = comboExportOutputTargetExit OnExit = comboExportOutputTargetExit
end end
end end

View File

@ -94,6 +94,7 @@ type
procedure ValidateControls(Sender: TObject); procedure ValidateControls(Sender: TObject);
procedure chkExportOptionClick(Sender: TObject); procedure chkExportOptionClick(Sender: TObject);
procedure btnExportOutputTargetSelectClick(Sender: TObject); procedure btnExportOutputTargetSelectClick(Sender: TObject);
procedure comboExportOutputTargetChange(Sender: TObject);
procedure comboExportOutputTargetExit(Sender: TObject); procedure comboExportOutputTargetExit(Sender: TObject);
procedure comboExportOutputTypeChange(Sender: TObject); procedure comboExportOutputTypeChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormClose(Sender: TObject; var Action: TCloseAction);
@ -293,6 +294,8 @@ begin
comboBulkTableEditCharset.Items := Mainform.Connection.CharsetList; comboBulkTableEditCharset.Items := Mainform.Connection.CharsetList;
if comboBulkTableEditCharset.Items.Count > 0 then if comboBulkTableEditCharset.Items.Count > 0 then
comboBulkTableEditCharset.ItemIndex := 0; comboBulkTableEditCharset.ItemIndex := 0;
ValidateControls(Sender);
end; end;
@ -331,7 +334,7 @@ begin
btnExecute.Enabled := SomeChecked and (memoFindText.Text <> ''); btnExecute.Enabled := SomeChecked and (memoFindText.Text <> '');
end else if tabsTools.ActivePage = tabSQLExport then begin end else if tabsTools.ActivePage = tabSQLExport then begin
btnExecute.Caption := 'Export'; btnExecute.Caption := 'Export';
btnExecute.Enabled := SomeChecked; btnExecute.Enabled := SomeChecked and (comboExportOutputTarget.Text <> '');
end else if tabsTools.ActivePage = tabBulkTableEdit then begin end else if tabsTools.ActivePage = tabBulkTableEdit then begin
btnExecute.Caption := 'Update'; btnExecute.Caption := 'Update';
chkBulkTableEditCollation.Enabled := Mainform.Connection.IsUnicode; chkBulkTableEditCollation.Enabled := Mainform.Connection.IsUnicode;
@ -398,7 +401,6 @@ begin
Mainform.DBtreeInitNode(Sender, ParentNode, Node, InitialStates); Mainform.DBtreeInitNode(Sender, ParentNode, Node, InitialStates);
Node.CheckType := ctTriStateCheckBox; Node.CheckType := ctTriStateCheckBox;
Node.CheckState := csUncheckedNormal; Node.CheckState := csUncheckedNormal;
ValidateControls(Sender);
end; end;
@ -800,6 +802,12 @@ begin
end; end;
procedure TfrmTableTools.comboExportOutputTargetChange(Sender: TObject);
begin
ValidateControls(Sender);
end;
procedure TfrmTableTools.comboExportOutputTargetExit(Sender: TObject); procedure TfrmTableTools.comboExportOutputTargetExit(Sender: TObject);
var var
ItemList: TStringList; ItemList: TStringList;
@ -946,7 +954,6 @@ begin
ToDb := comboExportOutputType.Text = OUTPUT_DB; ToDb := comboExportOutputType.Text = OUTPUT_DB;
ToServer := Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER; ToServer := Copy(comboExportOutputType.Text, 1, Length(OUTPUT_SERVER)) = OUTPUT_SERVER;
StartTime := GetTickCount; StartTime := GetTickCount;
try
if ToDir then begin if ToDir then begin
FreeAndNil(ExportStream); FreeAndNil(ExportStream);
if not DirectoryExists(comboExportOutputTarget.Text) then if not DirectoryExists(comboExportOutputTarget.Text) then
@ -972,12 +979,6 @@ begin
'/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=''NO_AUTO_VALUE_ON_ZERO'' */;'; '/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=''NO_AUTO_VALUE_ON_ZERO'' */;';
Output(Header, False, DBObj.Database<>ExportLastDatabase, True, False, False); Output(Header, False, DBObj.Database<>ExportLastDatabase, True, False, False);
end; end;
except
on E:Exception do begin
MessageDlg(E.Message, mterror, [mbOK], 0);
Exit;
end;
end;
// Database structure. Do that only in single-file and server mode. drop/create/use in directory or database mode makes no sense // Database structure. Do that only in single-file and server mode. drop/create/use in directory or database mode makes no sense
FinalDbName := DBObj.Database; FinalDbName := DBObj.Database;