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 6 by tony, Fri Feb 18 16:26:16 2011 UTC vs.
Revision 7 by tony, Sun Aug 5 18:28:19 2012 UTC

# Line 24 | Line 24
24   {       Corporation. All Rights Reserved.                                }
25   {    Contributor(s): Jeff Overcash                                       }
26   {                                                                        }
27 + {    IBX For Lazarus (Firebird Express)                                  }
28 + {    Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk }
29 + {    Portions created by MWA Software are copyright McCallum Whyman      }
30 + {    Associates Ltd 2011                                                 }
31   {************************************************************************}
32  
33   unit IBDBReg;
# Line 51 | Line 55 | unit IBDBReg;
55   interface
56  
57   uses {Windows,} SysUtils, Classes, Graphics, Dialogs, Controls, Forms, TypInfo,
58 <     DB, IBTable, IBDatabase,  IBEventsEditor,
58 >     DB, IBTable, IBDatabase,  IBEventsEditor,  LazarusPackageIntf,
59        IBUpdateSQL, IBXConst, ComponentEditors, PropEdits, DBPropEdits, FieldsEditor;
60  
61   type
# Line 124 | Line 128 | type
128  
129   { TIBQueryEditor }
130  
131 <  TIBQueryEditor = class(TComponentEditor)
131 >  TIBQueryEditor = class(TFieldsComponentEditor)
132    public
133      procedure ExecuteVerb(Index: Integer); override;
134      function GetVerb(Index: Integer): string; override;
# Line 133 | Line 137 | type
137  
138   { TIBStoredProcEditor }
139  
140 <  TIBStoredProcEditor = class(TComponentEditor)
140 >  TIBStoredProcEditor = class(TFieldsComponentEditor)
141    public
142      procedure ExecuteVerb(Index: Integer); override;
143      function GetVerb(Index: Integer): string; override;
# Line 142 | Line 146 | type
146  
147   { TIBDataSetEditor }
148  
149 <  TIBDataSetEditor = class(TComponentEditor)
149 >  TIBDataSetEditor = class(TFieldsComponentEditor)
150    public
151      procedure ExecuteVerb(Index: Integer); override;
152      function GetVerb(Index: Integer): string; override;
# Line 158 | Line 162 | type
162     function GetVerbCount: Integer; override;
163    end;
164  
165 + { TIBSQLEditor }
166 +
167 +  TIBSQLEditor  = class(TComponentEditor)
168 +  public
169 +    procedure ExecuteVerb(Index: Integer); override;
170 +    function GetVerb(Index: Integer): string; override;
171 +   function GetVerbCount: Integer; override;
172 +  end;
173 +
174 + { TIBServiceEditor}
175 +
176 +  TIBServiceEditor = class(TComponentEditor)
177 +  public
178 +    procedure ExecuteVerb(Index: Integer); override;
179 +    function GetVerb(Index: Integer): string; override;
180 +   function GetVerbCount: Integer; override;
181 +  end;
182 +
183    TIBStoredProcParamsProperty = class(TCollectionPropertyEditor)
184    public
185      procedure Edit; override;
# Line 189 | Line 211 | type
211      procedure Edit; override;
212    end;
213  
214 + {TIBSQLSQLPropertyEditor }
215 +
216 +  TIBSQLSQLPropertyEditor = class(TSQLPropertyEditor)
217 +  public
218 +    procedure Edit; override;
219 +  end;
220 +
221   { TIBDatasetSQLProperty }
222  
223    TIBDatasetSQLProperty = class(TSQLPropertyEditor)
# Line 290 | Line 319 | procedure Register;
319   implementation
320  
321   uses IB, IBQuery, IBStoredProc, IBCustomDataSet,
322 <     IBIntf, IBSQL, (*IBSQLMonitor,*) IBDatabaseInfo, IBEvents,
323 <     IBServices, (*IBInstall,*) IBDatabaseEdit, IBTransactionEdit,
322 >     IBIntf, IBSQL, IBSQLMonitor, IBDatabaseInfo, IBEvents,
323 >     IBServices, IBDatabaseEdit, IBTransactionEdit,
324       IBBatchMove, DBLoginDlg, IBExtract,LResources, IBSelectSQLEditor,
325       IBModifySQLEditor,IBDeleteSQLEditor,IBRefreshSQLEditor,
326 <     IBInsertSQLEditor, IBGeneratorEditor, IBUpdateSQLEditor, IBDataSetEditor;
326 >     IBInsertSQLEditor, IBGeneratorEditor, IBUpdateSQLEditor, IBDataSetEditor,
327 >     IBSQLEditor, ibserviceeditor;
328 >
329 >
330  
331   procedure Register;
332   begin
333 <  RegisterComponents(IBPalette1, [TIBTable, TIBQuery,
334 <    TIBStoredProc, TIBDatabase, TIBTransaction, TIBUpdateSQL, TIBBatchMove,
335 <    TIBDataSet, TIBSQL, TIBDatabaseInfo, (*TIBSQLMonitor,*) TIBEvents, TIBExtract]);
336 <  if (TryIBLoad) and IBServiceAPIPresent  then
333 >  if not TryIBLoad then Exit;
334 >
335 >  RegisterNoIcon([TIBStringField, TIBBCDField]);
336 >  RegisterNoIcon([TIntegerField]);
337 >  RegisterComponents(IBPalette1, [ TIBQuery, TIBDataSet,
338 >   TIBDatabase, TIBTransaction, TIBUpdateSQL, TIBEvents,
339 >     TIBSQL, TIBDatabaseInfo, TIBSQLMonitor,
340 >       TIBStoredProc,TIBBatchMove,  TIBTable,TIBExtract]);
341 >  if IBServiceAPIPresent  then
342      RegisterComponents(IBPalette2, [TIBConfigService, TIBBackupService,
343        TIBRestoreService, TIBValidationService, TIBStatisticalService,
344        TIBLogService, TIBSecurityService, TIBServerProperties]);
308  RegisterClasses([TIBStringField, TIBBCDField]);
309 //  RegisterFields([TIBStringField, TIBBCDField]); --not sure if this is needed in lazarus
345    RegisterPropertyEditor(TypeInfo(TIBFileName), TIBDatabase, 'DatabaseName', TIBFileNameProperty); {do not localize}
346    RegisterPropertyEditor(TypeInfo(string), TIBStoredProc, 'StoredProcName', TIBStoredProcNameProperty); {do not localize}
347    RegisterPropertyEditor(TypeInfo(TParams), TIBStoredProc, 'Params', TIBStoredProcParamsProperty);
# Line 320 | Line 355 | begin
355    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'InsertSQL', TIBInsertSQLProperty); {do not localize}
356    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'RefreshSQL', TIBRefreshSQLProperty); {do not localize}
357    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'DeleteSQL', TIBDeleteSQLProperty); {do not localize}
358 <  RegisterPropertyEditor(TypeInfo(TStrings), TIBSQL, 'SQL', TIBSQLProperty); {do not localize}
358 >  RegisterPropertyEditor(TypeInfo(TStrings), TIBSQL, 'SQL', TIBSQLSQLPropertyEditor); {do not localize}
359    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'RefreshSQL', TIBUpdateSQLRefreshSQLProperty); {do not localize}
360    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'ModifySQL', TIBUpdateSQLUpdateProperty); {do not localize}
361    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'InsertSQL', TIBUpdateSQLInsertSQLProperty); {do not localize}
362    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'DeleteSQL', TIBUpdateSQLDeleteProperty); {do not localize}
363    RegisterPropertyEditor(TypeInfo(TStrings), TIBEvents, 'Events', TIBEventListProperty); {do not localize}
364 <  RegisterPropertyEditor(TypeInfo(TPersistent), TIBDataSet, 'Generator', TIBGeneratorProperty);  {do not localize}
364 >  RegisterPropertyEditor(TypeInfo(TPersistent), TIBDataSet, 'GeneratorField', TIBGeneratorProperty);  {do not localize}
365 >  RegisterPropertyEditor(TypeInfo(TPersistent), TIBQuery, 'GeneratorField', TIBGeneratorProperty);  {do not localize}
366  
367    RegisterComponentEditor(TIBDatabase, TIBDatabaseEditor);
368    RegisterComponentEditor(TIBTransaction, TIBTransactionEditor);
# Line 334 | Line 370 | begin
370    RegisterComponentEditor(TIBDataSet, TIBDataSetEditor);
371    RegisterComponentEditor(TIBQuery, TIBQueryEditor);
372    RegisterComponentEditor(TIBStoredProc, TIBStoredProcEditor);
373 +  RegisterComponentEditor(TIBSQL, TIBSQLEditor);
374 +  RegisterComponentEditor(TIBCustomService, TIBServiceEditor);
375 + end;
376 +
377 + { TIBServiceEditor }
378 +
379 + procedure TIBServiceEditor.ExecuteVerb(Index: Integer);
380 + begin
381 +  if Index < inherited GetVerbCount then
382 +    inherited ExecuteVerb(Index) else
383 +  begin
384 +    Dec(Index, inherited GetVerbCount);
385 +    case Index of
386 +      0 : if ibserviceeditor.EditIBService(TIBCustomService(Component)) then Designer.Modified;
387 +    end;
388 +  end;
389 + end;
390 +
391 + function TIBServiceEditor.GetVerb(Index: Integer): string;
392 + begin
393 +  if Index < inherited GetVerbCount then
394 +    Result := inherited GetVerb(Index) else
395 +  begin
396 +    Dec(Index, inherited GetVerbCount);
397 +    case Index of
398 +      0: Result := SIBServiceEditor;
399 +      1 : Result := SInterbaseExpressVersion;
400 +    end;
401 +  end;
402 + end;
403 +
404 + function TIBServiceEditor.GetVerbCount: Integer;
405 + begin
406 +  Result := inherited GetVerbCount + 2;
407   end;
408  
409   { TIBFileNameProperty }
# Line 342 | Line 412 | begin
412    with TOpenDialog.Create(Application) do
413      try
414        InitialDir := ExtractFilePath(GetStrValue);
415 <      Filter := 'Database Files|*.gdb'; {do not localize}
415 >      Filter := SDatabaseFilter; {do not localize}
416        if Execute then
417          SetStrValue(FileName);
418      finally
# Line 370 | Line 440 | var
440     i : integer;
441   begin
442      StoredProc := GetComponent(0) as TIBStoredProc;
443 +    if StoredProc.Database = nil then
444 +      Exit;
445 +
446      with StoredProc do
447 +    try
448        for I := 0 to StoredProcedureNames.Count - 1 do
449          Proc (StoredProcedureNames[i]);
450 +    except on E: Exception do
451 +      MessageDlg(E.Message,mtError,[mbOK],0)
452 +    end;
453   end;
454  
455   { TIBTableNameProperty }
# Line 474 | Line 551 | var
551    Query: TIBQuery;
552   begin
553    Query := GetComponent(0) as TIBQuery;
554 <  if Assigned(Query.Database) and
478 <    IBSelectSQLEditor.EditSQL(Query.Database,Query.Transaction,Query.SQL) then Modified;
554 >  if IBSelectSQLEditor.EditSQL(Query.Database,Query.SQL) then Modified;
555   end;
556  
557   { TIBDatasetSQLProperty }
# Line 485 | Line 561 | var
561    IBDataset: TIBDataset;
562   begin
563    IBDataset := GetComponent(0) as TIBDataset;
564 <  if Assigned(IBDataSet.Database) and
489 <     IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.SelectSQL) then Modified;
564 >  if IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.SelectSQL) then Modified;
565   end;
566  
567   { TIBSQLProperty }
# Line 496 | Line 571 | var
571    IBSQL: TIBSQL;
572   begin
573    IBSQL := GetComponent(0) as TIBSQL;
574 <  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.Transaction,IBSQL.SQL) then Modified;
574 >  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.SQL) then Modified;
575   end;
576  
577   { TIBUpdateSQLEditor }
# Line 516 | Line 591 | end;
591  
592   function TIBUpdateSQLEditor.GetVerbCount: Integer;
593   begin
594 <  Result := 2;
594 >  Result :=  2;
595   end;
596  
597   { TIBDataSetEditor }
# Line 525 | Line 600 | procedure TIBDataSetEditor.ExecuteVerb(I
600   var
601    IBDataset: TIBDataset;
602   begin
603 +  if Index < inherited GetVerbCount then
604 +    inherited ExecuteVerb(Index) else
605 +  begin
606 +    Dec(Index, inherited GetVerbCount);
607      case Index of
608        0:
609          if IBDataSetEditor.EditIBDataSet(TIBDataSet(Component)) then
610            Designer.Modified;
611        1: (Component as TIBDataSet).ExecSQL;
612      end;
613 +  end;
614   end;
615  
616   function TIBDataSetEditor.GetVerb(Index: Integer): string;
# Line 549 | Line 629 | end;
629  
630   function TIBDataSetEditor.GetVerbCount: Integer;
631   begin
632 <  Result := 3;
632 >  Result := inherited GetVerbCount + 3;
633   end;
634  
635   { TIBEventListProperty }
# Line 568 | Line 648 | begin
648    Events := TStringList.Create;
649    try
650      Events.Assign( IBEvents.Events);
651 <    if EditAlerterEvents( Events) then IBEvents.Events.Assign(Events);
651 >    if EditAlerterEvents( Events) then
652 >    begin
653 >      IBEvents.Events.Assign(Events);
654 >      Modified
655 >    end;
656    finally
657      Events.Free;
658    end;
# Line 633 | Line 717 | procedure TIBQueryEditor.ExecuteVerb(Ind
717   var
718    Query: TIBQuery;
719   begin
720 +  if Index < inherited GetVerbCount then
721 +    inherited ExecuteVerb(Index) else
722 +  begin
723      Query := Component as TIBQuery;
724      Dec(Index, inherited GetVerbCount);
725      case Index of
726        0: Query.ExecSQL;
727 <      1: if ibselectsqleditor.EditSQL(Query.Database,Query.Transaction,Query.SQL) then Designer.Modified;
727 >      1: if ibselectsqleditor.EditSQL(Query.Database,Query.SQL) then Designer.Modified;
728      end;
729 +  end;
730   end;
731  
732   function TIBQueryEditor.GetVerb(Index: Integer): string;
# Line 657 | Line 745 | end;
745  
746   function TIBQueryEditor.GetVerbCount: Integer;
747   begin
748 <  Result :=  3;
748 >  Result := inherited GetVerbCount + 3;
749   end;
750  
751   { TIBStoredProcEditor }
752  
753   procedure TIBStoredProcEditor.ExecuteVerb(Index: Integer);
754   begin
755 +  if Index < inherited GetVerbCount then
756 +    inherited ExecuteVerb(Index) else
757 +  begin
758 +    Dec(Index, inherited GetVerbCount);
759      if Index = 0 then (Component as TIBStoredProc).ExecProc;
760 +  end;
761   end;
762  
763   function TIBStoredProcEditor.GetVerb(Index: Integer): string;
764   begin
765 +  if Index < inherited GetVerbCount then
766 +    Result := inherited GetVerb(Index) else
767 +  begin
768 +    Dec(Index, inherited GetVerbCount);
769      case Index of
770        0: Result := SExecute;
771        1: Result := SInterbaseExpressVersion;
772      end;
773 +  end;
774   end;
775  
776   function TIBStoredProcEditor.GetVerbCount: Integer;
# Line 732 | Line 830 | var
830    IBDataset: TIBDataset;
831   begin
832    IBDataset := GetComponent(0) as TIBDataset;
833 <  if Assigned(IBDataSet.Database) and
736 <    IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.ModifySQL) then Modified;
833 >  if IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.ModifySQL) then Modified;
834   end;
835  
836   { TIBUpdateSQLUpdateProperty }
837  
838   procedure TIBUpdateSQLUpdateProperty.Edit;
839   begin
840 <  if not GetObjects then
841 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
745 <  else
746 <  if IBModifySQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.ModifySQL) then Modified;
840 >  GetObjects;
841 >  if IBModifySQLEditor.EditSQL(FDatabase,FIBUpdateSQL.ModifySQL) then Modified;
842   end;
843  
844   { TIBRefreshSQLProperty }
# Line 751 | Line 846 | end;
846   procedure TIBRefreshSQLProperty.Edit;
847   var
848    IBDataset: TIBDataset;
849 +  aDatabase: TIBDatabase;
850   begin
851    IBDataset := GetComponent(0) as TIBDataset;
852 <  if Assigned(IBDataSet.Database) and
757 <    IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.RefreshSQL) then Modified;
852 >  if IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.RefreshSQL) then Modified;
853   end;
854  
855   { TIBUpdateSQLRefreshSQLProperty }
856  
857   procedure TIBUpdateSQLRefreshSQLProperty.Edit;
858   begin
859 <  if not GetObjects then
860 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
766 <  else
767 <  if IBRefreshSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.RefreshSQL) then Modified;
859 >  GetObjects;
860 >  if IBRefreshSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.RefreshSQL) then Modified;
861   end;
862  
863   { TIBDeleteSQLProperty }
# Line 774 | Line 867 | var
867    IBDataset: TIBDataset;
868   begin
869    IBDataset := GetComponent(0) as TIBDataset;
870 <  if Assigned(IBDataSet.Database) and
778 <    IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.DeleteSQL) then Modified;
870 >  if IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.DeleteSQL) then Modified;
871   end;
872  
873   { TIBUpdateSQLDeleteProperty }
# Line 787 | Line 879 | end;
879  
880   procedure TIBUpdateSQLDeleteProperty.Edit;
881   begin
882 <  if not GetObjects then
883 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
792 <  else
793 <  if IBDeleteSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.DeleteSQL) then Modified;
882 >  GetObjects;
883 >  if IBDeleteSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.DeleteSQL) then Modified;
884   end;
885  
886   { TUpdateSQLPropertyEditor }
# Line 801 | Line 891 | begin
891    FIBUpdateSQL := GetComponent(0) as TIBUpdateSQL;
892    if not assigned(FIBUpdateSQL) or not assigned(FIBUpdateSQL.DataSet) then
893      Exit;
894 +  FDatabase := nil;
895    if FIBUpdateSQL.DataSet is TIBQuery then
896    begin
897      FDatabase := (FIBUpdateSQL.DataSet as TIBQuery).Database;
# Line 815 | Line 906 | var
906    IBDataset: TIBDataset;
907   begin
908    IBDataset := GetComponent(0) as TIBDataset;
909 <  if Assigned(IBDataSet.Database) and
819 <    IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.InsertSQL) then Modified;
909 >  if IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.InsertSQL) then Modified;
910   end;
911  
912   { TIBUpdateSQLInsertSQLProperty }
913  
914   procedure TIBUpdateSQLInsertSQLProperty.Edit;
915   begin
916 <  if not GetObjects then
917 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
828 <  else
829 <  if IBInsertSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.InsertSQL) then Modified;
916 >  GetObjects;
917 >  if IBInsertSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.InsertSQL) then Modified;
918   end;
919  
920   { TIBGeneratorProperty }
# Line 841 | Line 929 | begin
929    if IBGeneratorEditor.EditGenerator(GetPersistentReference as TIBGenerator) then Modified;
930   end;
931  
932 + { TIBSQLEditor }
933 +
934 + procedure TIBSQLEditor.ExecuteVerb(Index: Integer);
935 + begin
936 +  if IBSQLEditor.EditIBSQL(TIBSQL(Component)) then Modified;
937 + end;
938 +
939 + function TIBSQLEditor.GetVerb(Index: Integer): string;
940 + begin
941 +  case Index of
942 +    0 : Result := SIBSQLEditor;
943 +    1: Result := SInterbaseExpressVersion;
944 +  end;
945 + end;
946 +
947 + function TIBSQLEditor.GetVerbCount: Integer;
948 + begin
949 +  Result:= 2
950 + end;
951 +
952 + { TIBSQLSQLPropertyEditor }
953 +
954 + procedure TIBSQLSQLPropertyEditor.Edit;
955 + var
956 +  IBSQL: TIBSQL;
957 + begin
958 +  IBSQL := GetComponent(0) as TIBSQL;
959 +  if IBSQLEditor.EditIBSQL(IBSQL) then Modified;
960 + end;
961 +
962   initialization
963    {$I IBDBReg.lrs}
964   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines