--- ibx/trunk/design/IBDBReg.pas 2014/07/07 13:00:15 19 +++ ibx/trunk/design/IBDBReg.pas 2015/02/26 10:33:34 21 @@ -57,7 +57,7 @@ interface uses SysUtils, Classes, Graphics, Dialogs, Controls, Forms, TypInfo, DB, IBTable, IBDatabase, IBEventsEditor, LazarusPackageIntf, IBUpdateSQL, IBXConst, ComponentEditors, PropEdits, DBPropEdits, FieldsEditor, - dbFieldLinkPropEditor; + dbFieldLinkPropEditor, dbFieldListPropEditor; type @@ -325,6 +325,38 @@ type procedure Edit; override; end; + { TDBDynamicGridFieldProperty } + + TDBDynamicGridFieldProperty = class(TFieldProperty) + public + procedure FillValues(const Values: TStringList); override; + end; + + { TDBLookupPropertiesGridFieldProperty } + + TDBLookupPropertiesGridFieldProperty = class(TFieldProperty) + public + procedure FillValues(const Values: TStringList); override; + end; + + { TIBTreeViewFieldProperty } + + TIBTreeViewFieldProperty = class(TFieldProperty) + public + procedure FillValues(const Values: TStringList); override; + end; + + { TIBDynamicGridIndexNamesProperty } + + TIBDynamicGridIndexNamesProperty = class(TIndexFieldNamesProperty) + protected + function GetFieldDefs: TFieldDefs; override; + function GetIndexFieldNames: string; override; + procedure SetIndexFieldNames(const Value: string); override; + end; + + + procedure Register; implementation @@ -332,10 +364,11 @@ implementation uses IB, IBQuery, IBStoredProc, IBCustomDataSet, IBIntf, IBSQL, IBSQLMonitor, IBDatabaseInfo, IBEvents, IBServices, IBDatabaseEdit, IBTransactionEdit, - IBBatchMove, DBLoginDlg, IBExtract,LResources, IBSelectSQLEditor, + IBBatchMove, IBExtract,LResources, IBSelectSQLEditor, IBModifySQLEditor,IBDeleteSQLEditor,IBRefreshSQLEditor, IBInsertSQLEditor, IBGeneratorEditor, IBUpdateSQLEditor, IBDataSetEditor, - IBSQLEditor, ibserviceeditor, LCLVersion; + IBSQLEditor, ibserviceeditor, LCLVersion, IBDynamicGrid, IBLookupComboEditBox, + IBTreeView; @@ -360,6 +393,9 @@ begin RegisterComponents(IBPalette2, [TIBConfigService, TIBBackupService, TIBRestoreService, TIBValidationService, TIBStatisticalService, TIBLogService, TIBSecurityService, TIBServerProperties]); + + + RegisterComponents(IBPalette3,[TIBLookupComboEditBox,TIBDynamicGrid,TIBTreeView]); RegisterPropertyEditor(TypeInfo(TIBFileName), TIBDatabase, 'DatabaseName', TIBFileNameProperty); {do not localize} RegisterPropertyEditor(TypeInfo(string), TIBStoredProc, 'StoredProcName', TIBStoredProcNameProperty); {do not localize} RegisterPropertyEditor(TypeInfo(TParams), TIBStoredProc, 'Params', TIBStoredProcParamsProperty); @@ -390,6 +426,98 @@ begin RegisterComponentEditor(TIBStoredProc, TIBStoredProcEditor); RegisterComponentEditor(TIBSQL, TIBSQLEditor); RegisterComponentEditor(TIBCustomService, TIBServiceEditor); + + + {Firebird Data Access Controls} + RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'KeyField', TDBDynamicGridFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'ListField', TDBDynamicGridFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TIBDynamicGrid, 'IndexFieldNames', TIBDynamicGridIndexNamesProperty); + RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'DataFieldName', TDBLookupPropertiesGridFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'KeyField', TIBTreeViewFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'TextField', TIBTreeViewFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'ParentField', TIBTreeViewFieldProperty); + RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'HasChildField', TIBTreeViewFieldProperty); + +end; + +procedure LoadDataSourceFields(DataSource: TDataSource; List: TStrings); +var + DataSet: TDataSet; + i: Integer; +begin + if Assigned(DataSource) then + begin + DataSet := DataSource.DataSet; + if Assigned(DataSet) then + begin + if DataSet.Fields.Count > 0 then + DataSet.GetFieldNames(List) + else + begin + DataSet.FieldDefs.Update; + for i := 0 to DataSet.FieldDefs.Count - 1 do + List.Add(DataSet.FieldDefs[i].Name); + end; + end; + end; +end; + +{ TDBLookupPropertiesGridFieldProperty } + +procedure TDBLookupPropertiesGridFieldProperty.FillValues( + const Values: TStringList); +var + P: TDBLookupProperties; +begin + P :=TDBLookupProperties(GetComponent(0)); + if not (P is TDBLookupProperties) then exit; + LoadDataSourceFields(TIBDynamicGrid(P.Owner.Grid).DataSource, Values); +end; + +{ TIBTreeViewFieldProperty } + +procedure TIBTreeViewFieldProperty.FillValues(const Values: TStringList); +var ListSource: TDataSource; +begin + ListSource := TIBTreeView(GetComponent(0)).DataSource; + LoadDataSourceFields(ListSource, Values); +end; + +{ TIBDynamicGridIndexNamesProperty } + +function TIBDynamicGridIndexNamesProperty.GetFieldDefs: TFieldDefs; +var Grid: TIBDynamicGrid; +begin + Result := nil; + Grid := TIBDynamicGrid(GetComponent(0)); + if assigned(Grid.DataSource) and assigned(Grid.DataSource.DataSet) then + Result := Grid.DataSource.DataSet.FieldDefs +end; + +function TIBDynamicGridIndexNamesProperty.GetIndexFieldNames: string; +var Grid: TIBDynamicGrid; +begin + Grid := TIBDynamicGrid(GetComponent(0)); + Result := Grid.IndexFieldNames +end; + +procedure TIBDynamicGridIndexNamesProperty.SetIndexFieldNames( + const Value: string); +var Grid: TIBDynamicGrid; +begin + Grid := TIBDynamicGrid(GetComponent(0)); + Grid.IndexFieldNames := Value +end; + +{ TDBDynamicGridFieldProperty } + +procedure TDBDynamicGridFieldProperty.FillValues(const Values: TStringList); +var + P: TDBLookupProperties; +begin + P :=TDBLookupProperties(GetComponent(0)); + if not (P is TDBLookupProperties) then exit; + LoadDataSourceFields(P.ListSource, Values); end; { TIBServiceEditor }