ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/design/IBDBReg.pas
(Generate patch)

Comparing ibx/trunk/design/IBDBReg.pas (file contents):
Revision 15 by tony, Thu Feb 28 16:56:14 2013 UTC vs.
Revision 39 by tony, Tue May 17 08:14:52 2016 UTC

# Line 54 | Line 54 | unit IBDBReg;
54  
55   interface
56  
57 < uses {Windows,} SysUtils, Classes, Graphics, Dialogs, Controls, Forms, TypInfo,
57 > uses SysUtils, Classes, Graphics, Dialogs, Controls, Forms, TypInfo,
58       DB, IBTable, IBDatabase,  IBEventsEditor,  LazarusPackageIntf,
59 <      IBUpdateSQL, IBXConst, ComponentEditors, PropEdits, DBPropEdits, FieldsEditor;
59 >      IBUpdateSQL, IBXConst, ComponentEditors, PropEdits, DBPropEdits, FieldsEditor,
60 >     dbFieldLinkPropEditor, dbFieldListPropEditor, IBDialogs;
61  
62   type
63  
# Line 92 | Line 93 | type
93      procedure GetValues(Proc: TGetStrProc); override;
94    end;
95  
96 +  { TDBStringProperty }
97 +
98    TDBStringProperty = class(TStringProperty)
99 +  private
100 +    function ConnecttoDB: boolean;
101    public
102      function GetAttributes: TPropertyAttributes; override;
103      procedure GetValueList(List: TStrings); virtual;
104      procedure GetValues(Proc: TGetStrProc); override;
105 +    procedure Edit; override;
106    end;
107  
108 +  { TIBIndexFieldNamesProperty }
109 +
110    TIBIndexFieldNamesProperty = class(TDBStringProperty)
111    public
112      procedure GetValueList(List: TStrings); override;
# Line 184 | Line 192 | type
192    public
193      procedure Edit; override;
194    end;
195 < (*
195 >
196 >  { TIBTableFieldLinkProperty }
197 >
198    TIBTableFieldLinkProperty = class(TFieldLinkProperty)
199    private
200      FTable: TIBTable;
201    protected
202 +    function GetIndexDefs: TIndexDefs; override;
203      function GetIndexFieldNames: string; override;
204      function GetMasterFields: string; override;
205      procedure SetIndexFieldNames(const Value: string); override;
# Line 196 | Line 207 | type
207    public
208      procedure Edit; override;
209    end;
210 < *)
210 >
211   { TSQLPropertyEditor }
212  
213    TSQLPropertyEditor = class(TStringsPropertyEditor)
# Line 314 | Line 325 | type
325      procedure Edit; override;
326    end;
327  
328 +  { TDBDynamicGridFieldProperty }
329 +
330 +  TDBDynamicGridFieldProperty = class(TFieldProperty)
331 +  public
332 +    procedure FillValues(const Values: TStringList); override;
333 +  end;
334 +
335 +  { TDBLookupPropertiesGridFieldProperty }
336 +
337 +  TDBLookupPropertiesGridFieldProperty = class(TFieldProperty)
338 +  public
339 +    procedure FillValues(const Values: TStringList); override;
340 +  end;
341 +
342 +  { TIBTreeViewFieldProperty }
343 +
344 +  TIBTreeViewFieldProperty = class(TFieldProperty)
345 +  public
346 +    procedure FillValues(const Values: TStringList); override;
347 +  end;
348 +
349 +  { TIBDynamicGridIndexNamesProperty }
350 +
351 +  TIBDynamicGridIndexNamesProperty = class(TIndexFieldNamesProperty)
352 +  protected
353 +    function GetFieldDefs: TFieldDefs; override;
354 +    function GetIndexFieldNames: string; override;
355 +    procedure SetIndexFieldNames(const Value: string); override;
356 +  end;
357 +
358 +
359 +
360   procedure Register;
361  
362   implementation
# Line 321 | Line 364 | implementation
364   uses IB, IBQuery, IBStoredProc, IBCustomDataSet,
365       IBIntf, IBSQL, IBSQLMonitor, IBDatabaseInfo, IBEvents,
366       IBServices, IBDatabaseEdit, IBTransactionEdit,
367 <     IBBatchMove, DBLoginDlg, IBExtract,LResources, IBSelectSQLEditor,
367 >     IBBatchMove, IBExtract,LResources, IBSelectSQLEditor,
368       IBModifySQLEditor,IBDeleteSQLEditor,IBRefreshSQLEditor,
369       IBInsertSQLEditor, IBGeneratorEditor, IBUpdateSQLEditor, IBDataSetEditor,
370 <     IBSQLEditor, ibserviceeditor, LCLVersion;
370 >     IBSQLEditor, ibserviceeditor, LCLVersion, IBDynamicGrid, IBLookupComboEditBox,
371 >     IBTreeView, DBControlGrid, ibxscript, IBLocalDBSupport, IBDSDialogs;
372  
373  
374  
# Line 336 | Line 380 | begin
380      Exit;
381    end;
382  
383 <  RegisterNoIcon([TIBStringField, TIBBCDField]);
383 >  RegisterNoIcon([TIBStringField, TIBBCDField, TIBMemoField]);
384    {$if lcl_fullversion < 01010000}
385    {see http://bugs.freepascal.org/view.php?id=19035 }
386    RegisterNoIcon([TIntegerField]);
# Line 344 | Line 388 | begin
388    RegisterComponents(IBPalette1, [ TIBQuery, TIBDataSet,
389     TIBDatabase, TIBTransaction, TIBUpdateSQL, TIBEvents,
390       TIBSQL, TIBDatabaseInfo, TIBSQLMonitor,
391 <       TIBStoredProc,TIBBatchMove,  TIBTable,TIBExtract]);
391 >       TIBStoredProc,TIBBatchMove,  TIBTable,TIBExtract, TIBXScript, TIBLocalDBSupport]);
392    if IBServiceAPIPresent  then
393      RegisterComponents(IBPalette2, [TIBConfigService, TIBBackupService,
394        TIBRestoreService, TIBValidationService, TIBStatisticalService,
395        TIBLogService, TIBSecurityService, TIBServerProperties]);
396 +
397 +
398 +  RegisterComponents(IBPalette3,[TIBLookupComboEditBox,TIBDynamicGrid,TIBTreeView,TDBControlGrid]);
399    RegisterPropertyEditor(TypeInfo(TIBFileName), TIBDatabase, 'DatabaseName', TIBFileNameProperty); {do not localize}
400    RegisterPropertyEditor(TypeInfo(string), TIBStoredProc, 'StoredProcName', TIBStoredProcNameProperty); {do not localize}
401    RegisterPropertyEditor(TypeInfo(TParams), TIBStoredProc, 'Params', TIBStoredProcParamsProperty);
402    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'TableName', TIBTableNameProperty); {do not localize}
403    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'IndexName', TIBIndexNameProperty); {do not localize}
404    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'IndexFieldNames', TIBIndexFieldNamesProperty); {do not localize}
405 < //  RegisterPropertyEditor(TypeInfo(string), TIBTable, 'MasterFields', TIBTableFieldLinkProperty); {do not localize}
405 >  RegisterPropertyEditor(TypeInfo(string), TIBTable, 'MasterFields', TIBTableFieldLinkProperty); {do not localize}
406    RegisterPropertyEditor(TypeInfo(TStrings), TIBQuery, 'SQL', TIBQuerySQLProperty); {do not localize}
407    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'SelectSQL', TIBDatasetSQLProperty); {do not localize}
408    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'ModifySQL', TIBUpdateSQLProperty); {do not localize}
# Line 379 | Line 426 | begin
426    RegisterComponentEditor(TIBStoredProc, TIBStoredProcEditor);
427    RegisterComponentEditor(TIBSQL, TIBSQLEditor);
428    RegisterComponentEditor(TIBCustomService, TIBServiceEditor);
429 +
430 +
431 +  {Firebird Data Access Controls}
432 +  RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'KeyField', TDBDynamicGridFieldProperty);
433 +  RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'ListField', TDBDynamicGridFieldProperty);
434 +  RegisterPropertyEditor(TypeInfo(string), TIBDynamicGrid, 'IndexFieldNames', TIBDynamicGridIndexNamesProperty);
435 +  RegisterPropertyEditor(TypeInfo(string), TDBLookupProperties, 'DataFieldName', TDBLookupPropertiesGridFieldProperty);
436 +  RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'KeyField', TIBTreeViewFieldProperty);
437 +  RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'TextField', TIBTreeViewFieldProperty);
438 +  RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'ParentField', TIBTreeViewFieldProperty);
439 +  RegisterPropertyEditor(TypeInfo(string), TIBTreeView, 'HasChildField', TIBTreeViewFieldProperty);
440 +
441 +  IBGUIInterface :=  TIBDSLCLInterface.Create;
442 + end;
443 +
444 + procedure LoadDataSourceFields(DataSource: TDataSource; List: TStrings);
445 + var
446 +  DataSet: TDataSet;
447 +  i: Integer;
448 + begin
449 +  if Assigned(DataSource) then
450 +  begin
451 +    DataSet := DataSource.DataSet;
452 +    if Assigned(DataSet) then
453 +    begin
454 +      if DataSet.Fields.Count > 0 then
455 +        DataSet.GetFieldNames(List)
456 +      else
457 +      begin
458 +        DataSet.FieldDefs.Update;
459 +        for i := 0 to DataSet.FieldDefs.Count - 1 do
460 +          List.Add(DataSet.FieldDefs[i].Name);
461 +      end;
462 +    end;
463 +  end;
464 + end;
465 +
466 + { TDBLookupPropertiesGridFieldProperty }
467 +
468 + procedure TDBLookupPropertiesGridFieldProperty.FillValues(
469 +  const Values: TStringList);
470 + var
471 +  P: TDBLookupProperties;
472 + begin
473 +  P :=TDBLookupProperties(GetComponent(0));
474 +  if not (P is TDBLookupProperties) then exit;
475 +  LoadDataSourceFields(TIBDynamicGrid(P.Owner.Grid).DataSource, Values);
476 + end;
477 +
478 + { TIBTreeViewFieldProperty }
479 +
480 + procedure TIBTreeViewFieldProperty.FillValues(const Values: TStringList);
481 + var ListSource: TDataSource;
482 + begin
483 +  ListSource :=  TIBTreeView(GetComponent(0)).DataSource;
484 +  LoadDataSourceFields(ListSource, Values);
485 + end;
486 +
487 + { TIBDynamicGridIndexNamesProperty }
488 +
489 + function TIBDynamicGridIndexNamesProperty.GetFieldDefs: TFieldDefs;
490 + var Grid: TIBDynamicGrid;
491 + begin
492 +  Result := nil;
493 +  Grid := TIBDynamicGrid(GetComponent(0));
494 +  if assigned(Grid.DataSource) and assigned(Grid.DataSource.DataSet) then
495 +     Result := Grid.DataSource.DataSet.FieldDefs
496 + end;
497 +
498 + function TIBDynamicGridIndexNamesProperty.GetIndexFieldNames: string;
499 + var Grid: TIBDynamicGrid;
500 + begin
501 +  Grid := TIBDynamicGrid(GetComponent(0));
502 +  Result := Grid.IndexFieldNames
503 + end;
504 +
505 + procedure TIBDynamicGridIndexNamesProperty.SetIndexFieldNames(
506 +  const Value: string);
507 + var Grid: TIBDynamicGrid;
508 + begin
509 +  Grid := TIBDynamicGrid(GetComponent(0));
510 +  Grid.IndexFieldNames := Value
511 + end;
512 +
513 + { TDBDynamicGridFieldProperty }
514 +
515 + procedure TDBDynamicGridFieldProperty.FillValues(const Values: TStringList);
516 + var
517 +  P: TDBLookupProperties;
518 + begin
519 +  P :=TDBLookupProperties(GetComponent(0));
520 +  if not (P is TDBLookupProperties) then exit;
521 +  LoadDataSourceFields(P.ListSource, Values);
522   end;
523  
524   { TIBServiceEditor }
# Line 463 | Line 603 | end;
603  
604   procedure TIBTableNameProperty.GetValues(Proc: TGetStrProc);
605   var
606 <   TableName : TIBTable;
606 >   Table : TIBTable;
607     i : integer;
608   begin
609 <  TableName := GetComponent(0) as TIBTable;
610 <  with TableName do
609 >  Table := GetComponent(0) as TIBTable;
610 >   if Table.Database = nil then
611 >      Exit;
612 >  with Table do
613      for I := 0 to TableNames.Count - 1 do
614        Proc (TableNames[i]);
615   end;
616  
617   { TDBStringProperty }
618  
619 + function TDBStringProperty.ConnecttoDB: boolean;
620 + var DataSet: TIBCustomDataSet;
621 + begin
622 +  Result := false;
623 +  DataSet := (GetComponent(0) as TIBCustomDataSet);
624 +  if assigned(Dataset.Database) then
625 +  begin
626 +    try
627 +      DataSet.Database.Connected := true;
628 +    except on E: Exception do
629 +      ShowMessage(E.Message)
630 +    end;
631 +    Result := DataSet.Database.Connected
632 +  end;
633 + end;
634 +
635   function TDBStringProperty.GetAttributes: TPropertyAttributes;
636   begin
637    Result := [paValueList, paSortList, paMultiSelect];
# Line 488 | Line 646 | var
646    I: Integer;
647    Values: TStringList;
648   begin
649 +  if not ConnecttoDB then Exit;
650    Values := TStringList.Create;
651    try
652      GetValueList(Values);
# Line 497 | Line 656 | begin
656    end;
657   end;
658  
659 + procedure TDBStringProperty.Edit;
660 + begin
661 +  if ConnecttoDB then
662 +    inherited Edit;
663 + end;
664 +
665   { Utility Functions }
666  
667   function GetPropertyValue(Instance: TPersistent; const PropName: string): TPersistent;
# Line 558 | Line 723 | var
723    Query: TIBQuery;
724   begin
725    Query := GetComponent(0) as TIBQuery;
726 <  if IBSelectSQLEditor.EditSQL(Query.Database,Query.SQL) then Modified;
726 >  if IBSelectSQLEditor.EditSQL(Query,Query.SQL) then Modified;
727   end;
728  
729   { TIBDatasetSQLProperty }
# Line 568 | Line 733 | var
733    IBDataset: TIBDataset;
734   begin
735    IBDataset := GetComponent(0) as TIBDataset;
736 <  if IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.SelectSQL) then Modified;
736 >  if IBSelectSQLEditor.EditSQL(IBDataSet,IBDataSet.SelectSQL) then Modified;
737   end;
738  
739   { TIBSQLProperty }
# Line 578 | Line 743 | var
743    IBSQL: TIBSQL;
744   begin
745    IBSQL := GetComponent(0) as TIBSQL;
746 <  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.SQL) then Modified;
746 >  if IBSQLEditor.EditIBSQL(IBSQL) then Modified;
747   end;
748  
749   { TIBUpdateSQLEditor }
# Line 731 | Line 896 | begin
896      Dec(Index, inherited GetVerbCount);
897      case Index of
898        0: Query.ExecSQL;
899 <      1: if ibselectsqleditor.EditSQL(Query.Database,Query.SQL) then Designer.Modified;
899 >      1: if ibselectsqleditor.EditSQL(Query,Query.SQL) then Designer.Modified;
900      end;
901    end;
902   end;
# Line 801 | Line 966 | begin
966    end;
967    inherited Edit;
968   end;
969 < (*
969 >
970   { TIBTableFieldLinkProperty }
971  
972   procedure TIBTableFieldLinkProperty.Edit;
973   begin
974    FTable := DataSet as TIBTable;
975 +  if assigned(FTable.Database) then
976 +    FTable.Database.Connected := true;
977    inherited Edit;
978   end;
979  
980 + function TIBTableFieldLinkProperty.GetIndexDefs: TIndexDefs;
981 + begin
982 +  Result :=  FTable.IndexDefs
983 + end;
984 +
985   function TIBTableFieldLinkProperty.GetIndexFieldNames: string;
986   begin
987    Result := FTable.IndexFieldNames;
# Line 828 | Line 1000 | end;
1000   procedure TIBTableFieldLinkProperty.SetMasterFields(const Value: string);
1001   begin
1002    FTable.MasterFields := Value;
1003 < end;*)
1003 > end;
1004  
1005   { TIBUpdateSQLProperty }
1006  
# Line 837 | Line 1009 | var
1009    IBDataset: TIBDataset;
1010   begin
1011    IBDataset := GetComponent(0) as TIBDataset;
1012 <  if IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.ModifySQL) then Modified;
1012 >  if IBModifySQLEditor.EditSQL(IBDataSet,IBDataSet.ModifySQL) then Modified;
1013   end;
1014  
1015   { TIBUpdateSQLUpdateProperty }
# Line 845 | Line 1017 | end;
1017   procedure TIBUpdateSQLUpdateProperty.Edit;
1018   begin
1019    GetObjects;
1020 <  if IBModifySQLEditor.EditSQL(FDatabase,FIBUpdateSQL.ModifySQL) then Modified;
1020 >  if IBModifySQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.ModifySQL) then Modified;
1021   end;
1022  
1023   { TIBRefreshSQLProperty }
# Line 856 | Line 1028 | var
1028    aDatabase: TIBDatabase;
1029   begin
1030    IBDataset := GetComponent(0) as TIBDataset;
1031 <  if IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.RefreshSQL) then Modified;
1031 >  if IBRefreshSQLEditor.EditSQL(IBDataSet,IBDataSet.RefreshSQL) then Modified;
1032   end;
1033  
1034   { TIBUpdateSQLRefreshSQLProperty }
# Line 864 | Line 1036 | end;
1036   procedure TIBUpdateSQLRefreshSQLProperty.Edit;
1037   begin
1038    GetObjects;
1039 <  if IBRefreshSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.RefreshSQL) then Modified;
1039 >  if IBRefreshSQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.RefreshSQL) then Modified;
1040   end;
1041  
1042   { TIBDeleteSQLProperty }
1043  
1044   procedure TIBDeleteSQLProperty.Edit;
1045   var
1046 <  IBDataset: TIBDataset;
1046 >  IBDataset: TIBDataSet;
1047   begin
1048 <  IBDataset := GetComponent(0) as TIBDataset;
1049 <  if IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.DeleteSQL) then Modified;
1048 >  IBDataset := GetComponent(0) as TIBDataSet;
1049 >  if IBDeleteSQLEditor.EditSQL(IBDataSet,IBDataSet.DeleteSQL) then Modified;
1050   end;
1051  
1052   { TIBUpdateSQLDeleteProperty }
# Line 887 | Line 1059 | end;
1059   procedure TIBUpdateSQLDeleteProperty.Edit;
1060   begin
1061    GetObjects;
1062 <  if IBDeleteSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.DeleteSQL) then Modified;
1062 >  if IBDeleteSQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.DeleteSQL) then Modified;
1063   end;
1064  
1065   { TUpdateSQLPropertyEditor }
# Line 910 | Line 1082 | end;
1082  
1083   procedure TIBInsertSQLProperty.Edit;
1084   var
1085 <  IBDataset: TIBDataset;
1085 >  IBDataset: TIBDataSet;
1086   begin
1087 <  IBDataset := GetComponent(0) as TIBDataset;
1088 <  if IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.InsertSQL) then Modified;
1087 >  IBDataset := GetComponent(0) as TIBDataSet;
1088 >  if IBInsertSQLEditor.EditSQL(IBDataSet,IBDataSet.InsertSQL) then Modified;
1089   end;
1090  
1091   { TIBUpdateSQLInsertSQLProperty }
# Line 921 | Line 1093 | end;
1093   procedure TIBUpdateSQLInsertSQLProperty.Edit;
1094   begin
1095    GetObjects;
1096 <  if IBInsertSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.InsertSQL) then Modified;
1096 >  if IBInsertSQLEditor.EditSQL(FIBUpdateSQL.Dataset,FIBUpdateSQL.InsertSQL) then Modified;
1097   end;
1098  
1099   { TIBGeneratorProperty }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines