📄 regfibpluseditors.pas
字号:
procedure TFIBSQLsProperty.Edit;
var pName:string;
KindSQL:integer;
begin
pName:=GetPropInfo^.Name;
if pName='SelectSQL' then
KindSQL:=0
else
if pName='UpdateSQL' then
KindSQL:=2
else
if pName='InsertSQL' then
KindSQL:=1
else
if pName='DeleteSQL' then
KindSQL:=3
else
KindSQL:=4;
if not FindPropInCode(TSQLs(GetComponent(0)).Owner,pName) then
ShowDataSetSQLEditor(TSQLs(GetComponent(0)).Owner,KindSQL,Designer);
end;
function TFIBSQLsProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
function TFIBSQLsProperty.GetValue: string;
begin
Result := SCompEditSQLText;
end;
function TpFIBSQLPropEdit.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
procedure TpFIBSQLPropEdit.Edit;
begin
if GetComponent(0) is TpFIBQuery then
begin
if not FindPropInCode(TComponent(GetComponent(0)),'SQL') then
if ShowSQLEdit(TpFIBQuery(GetComponent(0))) then
Modified;
FindPropInCode(TComponent(GetComponent(0)),'SQL');
end;
end;
type
TpFIBStoredProcProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
function TpFIBStoredProcProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList];
end;
procedure TpFIBStoredProcProperty.GetValues(Proc: TGetStrProc);
var
StoredProc: TpFIBStoredProc;
Qry: TpFIBQuery;
Trans: TpFIBTransaction;
lSQLDA: TFIBXSQLDA;
begin
StoredProc := GetComponent(0) as TpFIBStoredProc;
if not Assigned(StoredProc.Database) then Exit;
Qry := nil; Trans := nil;
try
Qry := TpFIBQuery.Create(nil);
Qry.ParamCheck:=false;
Qry.Database := StoredProc.Database;
Trans := TpFIBTransaction.Create(nil);
Trans.DefaultDatabase := StoredProc.Database;
Qry.Transaction := Trans;
Qry.SQL.Text := 'SELECT RDB$PROCEDURE_NAME FROM RDB$PROCEDURES';
Trans.StartTransaction;
try
Qry.ExecQuery;
lSQLDA := Qry.Current;
while not Qry.Eof do
begin
Proc(Trim(lSQLDA.ByName['RDB$PROCEDURE_NAME'].AsString));
lSQLDA := Qry.Next;
end;
Qry.Close;
finally
Trans.Commit;
end;
finally
Qry.Free;
Trans.Free;
end;
end;
{ TpFIBSQLLoggerEditor }
procedure TpFIBSQLLoggerEditor.ExecuteVerb(Index: Integer);
begin
{$IFNDEF LINUX}
with TFIBSQLLogger(Component) do
if ExistStatisticsTable then
ShowMessage(Database.DBName + ': ' + SCompEditStatTableExist)
else
begin
CreateStatisticsTable;
ShowMessage(Database.DBName + ': ' + SCompEditStatTableCreated)
end;
{$ENDIF}
end;
function TpFIBSQLLoggerEditor.GetVerb(Index: Integer): string;
begin
Result := SCompEditCreateStatTable;
end;
function TpFIBSQLLoggerEditor.GetVerbCount: Integer;
begin
Result:=1;
end;
{ TFIBConditionsEditor }
procedure TFIBConditionsEditor.Edit;
begin
if GetComponent(0) is TFIBQuery then
if EditConditions(TFIBQuery(GetComponent(0)).Conditions) then
Designer.Modified
else
else
if GetComponent(0) is TpFIBDataSet then
if EditConditions(TpFIBDataSet(GetComponent(0)).Conditions) then
Designer.Modified
end;
function TFIBConditionsEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
function TpFIBAutoUpdateOptionsEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog, paSubProperties];
end;
procedure TpFIBAutoUpdateOptionsEditor.Edit;
begin
if EditAutoUpdateOptions(GetComponent(0) as TpFIBDataSet) then
Modified
end;
function TpFIBDataSetOptionsEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
procedure TpFIBDataSetOptionsEditor.Edit;
var
pName: string;
DataSets: array of TFIBDataSet;
k:integer;
begin
pName := GetPropInfo^.Name;
SetLength(DataSets,PropCount);
for k := 0 to PropCount-1 do
begin
DataSets[k]:=GetComponent(k) as TFIBDataSet;
end;
if pName = 'Options' then
EditOptions(DataSets, 0)
else
EditOptions(DataSets, 1);
end;
{ TFileNameProperty }
procedure TFileNameProperty.Edit;
var
FileOpen: TOpenDialog;
pName:string;
pValue:string;
begin
pName :=GetPropInfo^.Name;
pValue :=GetValue;
FileOpen := TOpenDialog.Create(Application);
try
with Fileopen do
begin
if Trim(pValue)<>'' then
// if DirectoryExists(ExtractFilePath(pValue)) then
FileOpen.InitialDir:=ExtractFilePath(pValue)
else
FileOpen.InitialDir:='c:\';
if pName='DBName' then
Filter := 'IB base files|*.gdb|IB7 base files|*.ib|Firebird base files|*.fdb|All files|*.*'
else
Filter := 'DLL|*.dll|All files|*.*';
if FileExists(pValue) then
FileName:=pValue;
if Execute then
SetValue(Filename);
end;
finally
Fileopen.free;
end;
end;
function TFileNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paRevertable];
end;
{ TEdParamToFields }
procedure TEdParamToFields.Edit;
begin
if (GetComponent(0) is TAutoUpdateOptions)
and (TAutoUpdateOptions(GetComponent(0)).Owner is TpFIBDataSet)
then
if ShowEdParamToFields(TpFIBDataSet(TAutoUpdateOptions(GetComponent(0)).Owner))
then
Designer.Modified
end;
function TEdParamToFields.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
function TEdParamToFields.GetValue: string;
begin
if (GetComponent(0) is TAutoUpdateOptions)
and (TAutoUpdateOptions(GetComponent(0)).ParamsToFieldsLinks.Count>0) then
Result:='(TPARAMS_FIELDS_LINKS)'
else
Result:='(TParams_Fields_Links)'
end;
{ TpFIBQueryEditor }
procedure TpFIBQueryEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0:
begin
if not FindPropInCode(Component,'SQL') then
if ShowSQLEdit(TpFIBQuery(Component)) then
Designer.Modified;
FindPropInCode(Component,'SQL')
end;
1: begin
TpFIBQuery(Component).CheckValidStatement;
ShowMessage(SNoErrors);
end;
end;
end;
function TpFIBQueryEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SEditSQL;
1: Result := SCheckSQLs;
end;
end;
function TpFIBQueryEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
procedure TpFIBTRParamsEditor.Edit;
begin
if EditFIBTrParams(GetComponent(0) as TpFIBTransaction) then
Modified
end;
function TpFIBTRParamsEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog]-[paSubProperties];
end;
function TpFIBTRParamsEditor.GetValue: string;
begin
if (GetComponent(0) as TpFIBTransaction).TRParams.Count=0 then
Result:='(Empty)'
else
Result:='(TTRParams)'
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(string), TpFIBDatabase, 'AliasName', TFIBAliasEdit);
RegisterPropertyEditor(TypeInfo(string), TpFIBDatabase, 'DBName', TFileNameProperty);
RegisterPropertyEditor(TypeInfo(string), TpFIBDatabase, 'LibraryName', TFileNameProperty);
RegisterPropertyEditor(TypeInfo(TNotifyEvent),TpFIBDatabase, 'OnConnect', nil );
RegisterPropertyEditor(TypeInfo(TFIBLoginEvent),TpFIBDatabase, 'OnLogin', nil );
RegisterPropertyEditor(TypeInfo(string),TpFIBTransaction,
'UserKindTransaction', TFIBTrKindEdit
);
RegisterPropertyEditor(TypeInfo(TStrings),TSQLs,'',TFIBSQLsProperty);
RegisterPropertyEditor(TypeInfo(TSQLs),TFIBDataSet,'',TFIBSQLsProperties);
RegisterPropertyEditor(TypeInfo(TConditions),nil,'',TFIBConditionsEditor);
RegisterPropertyEditor(TypeInfo(TStrings), TAutoUpdateOptions,
'ParamsToFieldsLinks', TEdParamToFields
);
RegisterPropertyEditor(TypeInfo(string), TAutoUpdateOptions,
'UpdateTableName', TTableNameEdit
);
RegisterPropertyEditor(TypeInfo(string), TAutoUpdateOptions,
'KeyFields', TKeyFieldNameEdit
);
RegisterPropertyEditor(TypeInfo(integer), TpFIBDataSet,
'DataSet_ID', TDataSet_ID_Edit
);
RegisterPropertyEditor(TypeInfo(string), TpFIBStoredProc, 'StoredProcName',
TpFIBStoredProcProperty
);
RegisterPropertyEditor(TypeInfo(boolean),TFIBDataSet,'WaitEndMasterScroll',nil);
RegisterPropertyEditor(TypeInfo(TStrings), TpFIBQuery, 'SQL',
TpFIBSQLPropEdit
);
RegisterPropertyEditor(TypeInfo(TStrings),TFIBDataSet,'SelectSQL',nil);
RegisterPropertyEditor(TypeInfo(TStrings),TFIBDataSet,'InsertSQL',nil);
RegisterPropertyEditor(TypeInfo(TStrings),TFIBDataSet,'UpdateSQL',nil);
RegisterPropertyEditor(TypeInfo(TStrings),TFIBDataSet,'DeleteSQL',nil);
RegisterPropertyEditor(TypeInfo(TStrings),TFIBDataSet,'RefreshSQL',nil);
{$IFNDEF LINUX}
RegisterComponentEditor(TFIBSQLLogger, TpFIBSQLLoggerEditor);
{$ENDIF}
RegisterComponentEditor(TpFIBTransaction, TpFIBTransactionEditor);
RegisterComponentEditor(TpFIBQuery, TpFIBQueryEditor);
RegisterComponentEditor(TpFIBDatabase, TpFIBDatabaseEditor);
RegisterComponentEditor(TFIBDataSet, TFIBGenSQlEd);
RegisterPropertyEditor(TypeInfo(string), TAutoUpdateOptions,
'GeneratorName', TGeneratorNameEdit
);
RegisterPropertyEditor(TypeInfo(TStrings), TpFIBTransaction, 'TRParams', TpFIBTRParamsEditor);
RegisterPropertyEditor(TypeInfo(TAutoUpdateOptions), TpFIBDataSet, 'AutoUpdateOptions', TpFIBAutoUpdateOptionsEditor);
RegisterPropertyEditor(TypeInfo(TpPrepareOptions), nil, 'Options', TpFIBDataSetOptionsEditor);
RegisterPropertyEditor(TypeInfo(TpFIBDsOptions), nil, 'PrepareOptions', TpFIBDataSetOptionsEditor);
{$IFDEF INC_SERVICE_SUPPORT}
RegisterPropertyEditor(TypeInfo(string), TpFIBCustomService, 'LibraryName', TFileNameProperty);
{$ENDIF}
RegisterFields([TFIBStringField,TFIBIntegerField,TFIBSmallIntField,
TFIBFloatField,TFIBBCDField,TFIBBooleanField,TFIBDateField,TFIBTimeField,TFIBDateTimeField,
TFIBWideStringField]
);
{$IFDEF D6+}
RegisterPropertiesInCategory('Transactions',['*Transaction*'] );
{$ENDIF}
end;
{ TpFIBTRParamsEditor }
initialization
AppHandleException :=Application.HandleException;
finalization
AppHandleException :=nil;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -