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 5 by tony, Fri Feb 18 16:26:16 2011 UTC vs.
Revision 15 by tony, Thu Feb 28 16:56:14 2013 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, LCLVersion;
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
334 >  begin
335 >    MessageDlg('IBX is unable to locate the Firebird Library - have you remembered to install it?',mtError,[mbOK],0);
336 >    Exit;
337 >  end;
338 >
339 >  RegisterNoIcon([TIBStringField, TIBBCDField]);
340 >  {$if lcl_fullversion < 01010000}
341 >  {see http://bugs.freepascal.org/view.php?id=19035 }
342 >  RegisterNoIcon([TIntegerField]);
343 >  {$endif}
344 >  RegisterComponents(IBPalette1, [ TIBQuery, TIBDataSet,
345 >   TIBDatabase, TIBTransaction, TIBUpdateSQL, TIBEvents,
346 >     TIBSQL, TIBDatabaseInfo, TIBSQLMonitor,
347 >       TIBStoredProc,TIBBatchMove,  TIBTable,TIBExtract]);
348 >  if IBServiceAPIPresent  then
349      RegisterComponents(IBPalette2, [TIBConfigService, TIBBackupService,
350        TIBRestoreService, TIBValidationService, TIBStatisticalService,
351        TIBLogService, TIBSecurityService, TIBServerProperties]);
308  RegisterClasses([TIBStringField, TIBBCDField]);
309 //  RegisterFields([TIBStringField, TIBBCDField]); --not sure if this is needed in lazarus
352    RegisterPropertyEditor(TypeInfo(TIBFileName), TIBDatabase, 'DatabaseName', TIBFileNameProperty); {do not localize}
353    RegisterPropertyEditor(TypeInfo(string), TIBStoredProc, 'StoredProcName', TIBStoredProcNameProperty); {do not localize}
354    RegisterPropertyEditor(TypeInfo(TParams), TIBStoredProc, 'Params', TIBStoredProcParamsProperty);
# Line 320 | Line 362 | begin
362    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'InsertSQL', TIBInsertSQLProperty); {do not localize}
363    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'RefreshSQL', TIBRefreshSQLProperty); {do not localize}
364    RegisterPropertyEditor(TypeInfo(TStrings), TIBDataSet, 'DeleteSQL', TIBDeleteSQLProperty); {do not localize}
365 <  RegisterPropertyEditor(TypeInfo(TStrings), TIBSQL, 'SQL', TIBSQLProperty); {do not localize}
365 >  RegisterPropertyEditor(TypeInfo(TStrings), TIBSQL, 'SQL', TIBSQLSQLPropertyEditor); {do not localize}
366    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'RefreshSQL', TIBUpdateSQLRefreshSQLProperty); {do not localize}
367    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'ModifySQL', TIBUpdateSQLUpdateProperty); {do not localize}
368    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'InsertSQL', TIBUpdateSQLInsertSQLProperty); {do not localize}
369    RegisterPropertyEditor(TypeInfo(TStrings), TIBUpdateSQL, 'DeleteSQL', TIBUpdateSQLDeleteProperty); {do not localize}
370    RegisterPropertyEditor(TypeInfo(TStrings), TIBEvents, 'Events', TIBEventListProperty); {do not localize}
371 <  RegisterPropertyEditor(TypeInfo(TPersistent), TIBDataSet, 'Generator', TIBGeneratorProperty);  {do not localize}
371 >  RegisterPropertyEditor(TypeInfo(TPersistent), TIBDataSet, 'GeneratorField', TIBGeneratorProperty);  {do not localize}
372 >  RegisterPropertyEditor(TypeInfo(TPersistent), TIBQuery, 'GeneratorField', TIBGeneratorProperty);  {do not localize}
373  
374    RegisterComponentEditor(TIBDatabase, TIBDatabaseEditor);
375    RegisterComponentEditor(TIBTransaction, TIBTransactionEditor);
# Line 334 | Line 377 | begin
377    RegisterComponentEditor(TIBDataSet, TIBDataSetEditor);
378    RegisterComponentEditor(TIBQuery, TIBQueryEditor);
379    RegisterComponentEditor(TIBStoredProc, TIBStoredProcEditor);
380 +  RegisterComponentEditor(TIBSQL, TIBSQLEditor);
381 +  RegisterComponentEditor(TIBCustomService, TIBServiceEditor);
382 + end;
383 +
384 + { TIBServiceEditor }
385 +
386 + procedure TIBServiceEditor.ExecuteVerb(Index: Integer);
387 + begin
388 +  if Index < inherited GetVerbCount then
389 +    inherited ExecuteVerb(Index) else
390 +  begin
391 +    Dec(Index, inherited GetVerbCount);
392 +    case Index of
393 +      0 : if ibserviceeditor.EditIBService(TIBCustomService(Component)) then Designer.Modified;
394 +    end;
395 +  end;
396 + end;
397 +
398 + function TIBServiceEditor.GetVerb(Index: Integer): string;
399 + begin
400 +  if Index < inherited GetVerbCount then
401 +    Result := inherited GetVerb(Index) else
402 +  begin
403 +    Dec(Index, inherited GetVerbCount);
404 +    case Index of
405 +      0: Result := SIBServiceEditor;
406 +      1 : Result := SInterbaseExpressVersion;
407 +    end;
408 +  end;
409 + end;
410 +
411 + function TIBServiceEditor.GetVerbCount: Integer;
412 + begin
413 +  Result := inherited GetVerbCount + 2;
414   end;
415  
416   { TIBFileNameProperty }
# Line 342 | Line 419 | begin
419    with TOpenDialog.Create(Application) do
420      try
421        InitialDir := ExtractFilePath(GetStrValue);
422 <      Filter := 'Database Files|*.gdb'; {do not localize}
422 >      Filter := SDatabaseFilter; {do not localize}
423        if Execute then
424          SetStrValue(FileName);
425      finally
# Line 370 | Line 447 | var
447     i : integer;
448   begin
449      StoredProc := GetComponent(0) as TIBStoredProc;
450 +    if StoredProc.Database = nil then
451 +      Exit;
452 +
453      with StoredProc do
454 +    try
455        for I := 0 to StoredProcedureNames.Count - 1 do
456          Proc (StoredProcedureNames[i]);
457 +    except on E: Exception do
458 +      MessageDlg(E.Message,mtError,[mbOK],0)
459 +    end;
460   end;
461  
462   { TIBTableNameProperty }
# Line 474 | Line 558 | var
558    Query: TIBQuery;
559   begin
560    Query := GetComponent(0) as TIBQuery;
561 <  if Assigned(Query.Database) and
478 <    IBSelectSQLEditor.EditSQL(Query.Database,Query.Transaction,Query.SQL) then Modified;
561 >  if IBSelectSQLEditor.EditSQL(Query.Database,Query.SQL) then Modified;
562   end;
563  
564   { TIBDatasetSQLProperty }
# Line 485 | Line 568 | var
568    IBDataset: TIBDataset;
569   begin
570    IBDataset := GetComponent(0) as TIBDataset;
571 <  if Assigned(IBDataSet.Database) and
489 <     IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.SelectSQL) then Modified;
571 >  if IBSelectSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.SelectSQL) then Modified;
572   end;
573  
574   { TIBSQLProperty }
# Line 496 | Line 578 | var
578    IBSQL: TIBSQL;
579   begin
580    IBSQL := GetComponent(0) as TIBSQL;
581 <  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.Transaction,IBSQL.SQL) then Modified;
581 >  if IBSelectSQLEditor.EditSQL(IBSQL.Database,IBSQL.SQL) then Modified;
582   end;
583  
584   { TIBUpdateSQLEditor }
# Line 516 | Line 598 | end;
598  
599   function TIBUpdateSQLEditor.GetVerbCount: Integer;
600   begin
601 <  Result := 2;
601 >  Result :=  2;
602   end;
603  
604   { TIBDataSetEditor }
# Line 525 | Line 607 | procedure TIBDataSetEditor.ExecuteVerb(I
607   var
608    IBDataset: TIBDataset;
609   begin
610 +  if Index < inherited GetVerbCount then
611 +    inherited ExecuteVerb(Index) else
612 +  begin
613 +    Dec(Index, inherited GetVerbCount);
614      case Index of
615        0:
616          if IBDataSetEditor.EditIBDataSet(TIBDataSet(Component)) then
617            Designer.Modified;
618        1: (Component as TIBDataSet).ExecSQL;
619      end;
620 +  end;
621   end;
622  
623   function TIBDataSetEditor.GetVerb(Index: Integer): string;
# Line 549 | Line 636 | end;
636  
637   function TIBDataSetEditor.GetVerbCount: Integer;
638   begin
639 <  Result := 3;
639 >  Result := inherited GetVerbCount + 3;
640   end;
641  
642   { TIBEventListProperty }
# Line 568 | Line 655 | begin
655    Events := TStringList.Create;
656    try
657      Events.Assign( IBEvents.Events);
658 <    if EditAlerterEvents( Events) then IBEvents.Events.Assign(Events);
658 >    if EditAlerterEvents( Events) then
659 >    begin
660 >      IBEvents.Events.Assign(Events);
661 >      Modified
662 >    end;
663    finally
664      Events.Free;
665    end;
# Line 633 | Line 724 | procedure TIBQueryEditor.ExecuteVerb(Ind
724   var
725    Query: TIBQuery;
726   begin
727 +  if Index < inherited GetVerbCount then
728 +    inherited ExecuteVerb(Index) else
729 +  begin
730      Query := Component as TIBQuery;
731      Dec(Index, inherited GetVerbCount);
732      case Index of
733        0: Query.ExecSQL;
734 <      1: if ibselectsqleditor.EditSQL(Query.Database,Query.Transaction,Query.SQL) then Designer.Modified;
734 >      1: if ibselectsqleditor.EditSQL(Query.Database,Query.SQL) then Designer.Modified;
735      end;
736 +  end;
737   end;
738  
739   function TIBQueryEditor.GetVerb(Index: Integer): string;
# Line 657 | Line 752 | end;
752  
753   function TIBQueryEditor.GetVerbCount: Integer;
754   begin
755 <  Result :=  3;
755 >  Result := inherited GetVerbCount + 3;
756   end;
757  
758   { TIBStoredProcEditor }
759  
760   procedure TIBStoredProcEditor.ExecuteVerb(Index: Integer);
761   begin
762 +  if Index < inherited GetVerbCount then
763 +    inherited ExecuteVerb(Index) else
764 +  begin
765 +    Dec(Index, inherited GetVerbCount);
766      if Index = 0 then (Component as TIBStoredProc).ExecProc;
767 +  end;
768   end;
769  
770   function TIBStoredProcEditor.GetVerb(Index: Integer): string;
771   begin
772 +  if Index < inherited GetVerbCount then
773 +    Result := inherited GetVerb(Index) else
774 +  begin
775 +    Dec(Index, inherited GetVerbCount);
776      case Index of
777        0: Result := SExecute;
778        1: Result := SInterbaseExpressVersion;
779      end;
780 +  end;
781   end;
782  
783   function TIBStoredProcEditor.GetVerbCount: Integer;
# Line 732 | Line 837 | var
837    IBDataset: TIBDataset;
838   begin
839    IBDataset := GetComponent(0) as TIBDataset;
840 <  if Assigned(IBDataSet.Database) and
736 <    IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.ModifySQL) then Modified;
840 >  if IBModifySQLEditor.EditSQL(IBDataSet.Database,IBDataSet.ModifySQL) then Modified;
841   end;
842  
843   { TIBUpdateSQLUpdateProperty }
844  
845   procedure TIBUpdateSQLUpdateProperty.Edit;
846   begin
847 <  if not GetObjects then
848 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
745 <  else
746 <  if IBModifySQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.ModifySQL) then Modified;
847 >  GetObjects;
848 >  if IBModifySQLEditor.EditSQL(FDatabase,FIBUpdateSQL.ModifySQL) then Modified;
849   end;
850  
851   { TIBRefreshSQLProperty }
# Line 751 | Line 853 | end;
853   procedure TIBRefreshSQLProperty.Edit;
854   var
855    IBDataset: TIBDataset;
856 +  aDatabase: TIBDatabase;
857   begin
858    IBDataset := GetComponent(0) as TIBDataset;
859 <  if Assigned(IBDataSet.Database) and
757 <    IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.RefreshSQL) then Modified;
859 >  if IBRefreshSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.RefreshSQL) then Modified;
860   end;
861  
862   { TIBUpdateSQLRefreshSQLProperty }
863  
864   procedure TIBUpdateSQLRefreshSQLProperty.Edit;
865   begin
866 <  if not GetObjects then
867 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
766 <  else
767 <  if IBRefreshSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.RefreshSQL) then Modified;
866 >  GetObjects;
867 >  if IBRefreshSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.RefreshSQL) then Modified;
868   end;
869  
870   { TIBDeleteSQLProperty }
# Line 774 | Line 874 | var
874    IBDataset: TIBDataset;
875   begin
876    IBDataset := GetComponent(0) as TIBDataset;
877 <  if Assigned(IBDataSet.Database) and
778 <    IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.DeleteSQL) then Modified;
877 >  if IBDeleteSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.DeleteSQL) then Modified;
878   end;
879  
880   { TIBUpdateSQLDeleteProperty }
# Line 787 | Line 886 | end;
886  
887   procedure TIBUpdateSQLDeleteProperty.Edit;
888   begin
889 <  if not GetObjects then
890 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
792 <  else
793 <  if IBDeleteSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.DeleteSQL) then Modified;
889 >  GetObjects;
890 >  if IBDeleteSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.DeleteSQL) then Modified;
891   end;
892  
893   { TUpdateSQLPropertyEditor }
# Line 801 | Line 898 | begin
898    FIBUpdateSQL := GetComponent(0) as TIBUpdateSQL;
899    if not assigned(FIBUpdateSQL) or not assigned(FIBUpdateSQL.DataSet) then
900      Exit;
901 +  FDatabase := nil;
902    if FIBUpdateSQL.DataSet is TIBQuery then
903    begin
904      FDatabase := (FIBUpdateSQL.DataSet as TIBQuery).Database;
# Line 815 | Line 913 | var
913    IBDataset: TIBDataset;
914   begin
915    IBDataset := GetComponent(0) as TIBDataset;
916 <  if Assigned(IBDataSet.Database) and
819 <    IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.Transaction,IBDataSet.InsertSQL) then Modified;
916 >  if IBInsertSQLEditor.EditSQL(IBDataSet.Database,IBDataSet.InsertSQL) then Modified;
917   end;
918  
919   { TIBUpdateSQLInsertSQLProperty }
920  
921   procedure TIBUpdateSQLInsertSQLProperty.Edit;
922   begin
923 <  if not GetObjects then
924 <    ShowMessage('Not Linked to an IBQuery object or Database not assigned')
828 <  else
829 <  if IBInsertSQLEditor.EditSQL(FDatabase,FDatabase.DefaultTransaction,FIBUpdateSQL.InsertSQL) then Modified;
923 >  GetObjects;
924 >  if IBInsertSQLEditor.EditSQL(FDatabase,FIBUpdateSQL.InsertSQL) then Modified;
925   end;
926  
927   { TIBGeneratorProperty }
# Line 841 | Line 936 | begin
936    if IBGeneratorEditor.EditGenerator(GetPersistentReference as TIBGenerator) then Modified;
937   end;
938  
939 + { TIBSQLEditor }
940 +
941 + procedure TIBSQLEditor.ExecuteVerb(Index: Integer);
942 + begin
943 +  if IBSQLEditor.EditIBSQL(TIBSQL(Component)) then Modified;
944 + end;
945 +
946 + function TIBSQLEditor.GetVerb(Index: Integer): string;
947 + begin
948 +  case Index of
949 +    0 : Result := SIBSQLEditor;
950 +    1: Result := SInterbaseExpressVersion;
951 +  end;
952 + end;
953 +
954 + function TIBSQLEditor.GetVerbCount: Integer;
955 + begin
956 +  Result:= 2
957 + end;
958 +
959 + { TIBSQLSQLPropertyEditor }
960 +
961 + procedure TIBSQLSQLPropertyEditor.Edit;
962 + var
963 +  IBSQL: TIBSQL;
964 + begin
965 +  IBSQL := GetComponent(0) as TIBSQL;
966 +  if IBSQLEditor.EditIBSQL(IBSQL) then Modified;
967 + end;
968 +
969   initialization
970    {$I IBDBReg.lrs}
971   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines