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

Comparing ibx/trunk/design/IBDBReg.pas (file contents):
Revision 17 by tony, Sat Dec 28 19:22:24 2013 UTC vs.
Revision 19 by tony, Mon Jul 7 13:00:15 2014 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;
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 355 | Line 366 | begin
366    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'TableName', TIBTableNameProperty); {do not localize}
367    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'IndexName', TIBIndexNameProperty); {do not localize}
368    RegisterPropertyEditor(TypeInfo(string), TIBTable, 'IndexFieldNames', TIBIndexFieldNamesProperty); {do not localize}
369 < //  RegisterPropertyEditor(TypeInfo(string), TIBTable, 'MasterFields', TIBTableFieldLinkProperty); {do not localize}
369 >  RegisterPropertyEditor(TypeInfo(string), TIBTable, 'MasterFields', TIBTableFieldLinkProperty); {do not localize}
370    RegisterPropertyEditor(TypeInfo(TStrings), TIBQuery, 'SQL', TIBQuerySQLProperty); {do not localize}
371    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'SelectSQL', TIBDatasetSQLProperty); {do not localize}
372    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'ModifySQL', TIBUpdateSQLProperty); {do not localize}
# Line 463 | Line 474 | end;
474  
475   procedure TIBTableNameProperty.GetValues(Proc: TGetStrProc);
476   var
477 <   TableName : TIBTable;
477 >   Table : TIBTable;
478     i : integer;
479   begin
480 <  TableName := GetComponent(0) as TIBTable;
481 <  with TableName do
480 >  Table := GetComponent(0) as TIBTable;
481 >   if Table.Database = nil then
482 >      Exit;
483 >  with Table do
484      for I := 0 to TableNames.Count - 1 do
485        Proc (TableNames[i]);
486   end;
487  
488   { TDBStringProperty }
489  
490 + function TDBStringProperty.ConnecttoDB: boolean;
491 + var DataSet: TIBCustomDataSet;
492 + begin
493 +  Result := false;
494 +  DataSet := (GetComponent(0) as TIBCustomDataSet);
495 +  if assigned(Dataset.Database) then
496 +  begin
497 +    try
498 +      DataSet.Database.Connected := true;
499 +    except on E: Exception do
500 +      ShowMessage(E.Message)
501 +    end;
502 +    Result := DataSet.Database.Connected
503 +  end;
504 + end;
505 +
506   function TDBStringProperty.GetAttributes: TPropertyAttributes;
507   begin
508    Result := [paValueList, paSortList, paMultiSelect];
# Line 488 | Line 517 | var
517    I: Integer;
518    Values: TStringList;
519   begin
520 +  if not ConnecttoDB then Exit;
521    Values := TStringList.Create;
522    try
523      GetValueList(Values);
# Line 497 | Line 527 | begin
527    end;
528   end;
529  
530 + procedure TDBStringProperty.Edit;
531 + begin
532 +  if ConnecttoDB then
533 +    inherited Edit;
534 + end;
535 +
536   { Utility Functions }
537  
538   function GetPropertyValue(Instance: TPersistent; const PropName: string): TPersistent;
# Line 558 | Line 594 | var
594    Query: TIBQuery;
595   begin
596    Query := GetComponent(0) as TIBQuery;
597 <  if IBSelectSQLEditor.EditSQL(Query.Database,Query.SQL) then Modified;
597 >  if IBSelectSQLEditor.EditSQL(Query,Query.SQL) then Modified;
598   end;
599  
600   { TIBDatasetSQLProperty }
# Line 568 | Line 604 | var
604    IBDataset: TIBDataset;
605   begin
606    IBDataset := GetComponent(0) as TIBDataset;
607 <  if IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.SelectSQL) then Modified;
607 >  if IBSelectSQLEditor.EditSQL(IBDataSet,IBDataSet.SelectSQL) then Modified;
608   end;
609  
610   { TIBSQLProperty }
# Line 578 | Line 614 | var
614    IBSQL: TIBSQL;
615   begin
616    IBSQL := GetComponent(0) as TIBSQL;
617 <  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.SQL) then Modified;
617 >  if IBSQLEditor.EditIBSQL(IBSQL) then Modified;
618   end;
619  
620   { TIBUpdateSQLEditor }
# Line 731 | Line 767 | begin
767      Dec(Index, inherited GetVerbCount);
768      case Index of
769        0: Query.ExecSQL;
770 <      1: if ibselectsqleditor.EditSQL(Query.Database,Query.SQL) then Designer.Modified;
770 >      1: if ibselectsqleditor.EditSQL(Query,Query.SQL) then Designer.Modified;
771      end;
772    end;
773   end;
# Line 801 | Line 837 | begin
837    end;
838    inherited Edit;
839   end;
840 < (*
840 >
841   { TIBTableFieldLinkProperty }
842  
843   procedure TIBTableFieldLinkProperty.Edit;
844   begin
845    FTable := DataSet as TIBTable;
846 +  if assigned(FTable.Database) then
847 +    FTable.Database.Connected := true;
848    inherited Edit;
849   end;
850  
851 + function TIBTableFieldLinkProperty.GetIndexDefs: TIndexDefs;
852 + begin
853 +  Result :=  FTable.IndexDefs
854 + end;
855 +
856   function TIBTableFieldLinkProperty.GetIndexFieldNames: string;
857   begin
858    Result := FTable.IndexFieldNames;
# Line 828 | Line 871 | end;
871   procedure TIBTableFieldLinkProperty.SetMasterFields(const Value: string);
872   begin
873    FTable.MasterFields := Value;
874 < end;*)
874 > end;
875  
876   { TIBUpdateSQLProperty }
877  
# Line 837 | Line 880 | var
880    IBDataset: TIBDataset;
881   begin
882    IBDataset := GetComponent(0) as TIBDataset;
883 <  if IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.ModifySQL) then Modified;
883 >  if IBModifySQLEditor.EditSQL(IBDataSet,IBDataSet.ModifySQL) then Modified;
884   end;
885  
886   { TIBUpdateSQLUpdateProperty }
# Line 845 | Line 888 | end;
888   procedure TIBUpdateSQLUpdateProperty.Edit;
889   begin
890    GetObjects;
891 <  if IBModifySQLEditor.EditSQL(FDatabase,FIBUpdateSQL.ModifySQL) then Modified;
891 >  if IBModifySQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.ModifySQL) then Modified;
892   end;
893  
894   { TIBRefreshSQLProperty }
# Line 856 | Line 899 | var
899    aDatabase: TIBDatabase;
900   begin
901    IBDataset := GetComponent(0) as TIBDataset;
902 <  if IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.RefreshSQL) then Modified;
902 >  if IBRefreshSQLEditor.EditSQL(IBDataSet,IBDataSet.RefreshSQL) then Modified;
903   end;
904  
905   { TIBUpdateSQLRefreshSQLProperty }
# Line 864 | Line 907 | end;
907   procedure TIBUpdateSQLRefreshSQLProperty.Edit;
908   begin
909    GetObjects;
910 <  if IBRefreshSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.RefreshSQL) then Modified;
910 >  if IBRefreshSQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.RefreshSQL) then Modified;
911   end;
912  
913   { TIBDeleteSQLProperty }
914  
915   procedure TIBDeleteSQLProperty.Edit;
916   var
917 <  IBDataset: TIBDataset;
917 >  IBDataset: TIBDataSet;
918   begin
919 <  IBDataset := GetComponent(0) as TIBDataset;
920 <  if IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.DeleteSQL) then Modified;
919 >  IBDataset := GetComponent(0) as TIBDataSet;
920 >  if IBDeleteSQLEditor.EditSQL(IBDataSet,IBDataSet.DeleteSQL) then Modified;
921   end;
922  
923   { TIBUpdateSQLDeleteProperty }
# Line 887 | Line 930 | end;
930   procedure TIBUpdateSQLDeleteProperty.Edit;
931   begin
932    GetObjects;
933 <  if IBDeleteSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.DeleteSQL) then Modified;
933 >  if IBDeleteSQLEditor.EditSQL(FIBUpdateSQL.DataSet,FIBUpdateSQL.DeleteSQL) then Modified;
934   end;
935  
936   { TUpdateSQLPropertyEditor }
# Line 910 | Line 953 | end;
953  
954   procedure TIBInsertSQLProperty.Edit;
955   var
956 <  IBDataset: TIBDataset;
956 >  IBDataset: TIBDataSet;
957   begin
958 <  IBDataset := GetComponent(0) as TIBDataset;
959 <  if IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.InsertSQL) then Modified;
958 >  IBDataset := GetComponent(0) as TIBDataSet;
959 >  if IBInsertSQLEditor.EditSQL(IBDataSet,IBDataSet.InsertSQL) then Modified;
960   end;
961  
962   { TIBUpdateSQLInsertSQLProperty }
# Line 921 | Line 964 | end;
964   procedure TIBUpdateSQLInsertSQLProperty.Edit;
965   begin
966    GetObjects;
967 <  if IBInsertSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.InsertSQL) then Modified;
967 >  if IBInsertSQLEditor.EditSQL(FIBUpdateSQL.Dataset,FIBUpdateSQL.InsertSQL) then Modified;
968   end;
969  
970   { TIBGeneratorProperty }
# Line 968 | Line 1011 | end;
1011  
1012   initialization
1013    {$I IBDBReg.lrs}
1014 < end.
1014 > end.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines