1 {*********************************************************}
3 { Zeos Database Objects }
4 { Component Property Editors }
6 { Originally written by Sergey Seroukhov }
8 {*********************************************************}
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
13 { License Agreement: }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
46 { http://www.sourceforge.net/projects/zeoslib. }
49 { Zeos Development Group. }
50 {********************************************************@}
58 {$IFDEF WITH_PROPERTY_EDITOR}
61 Types, Classes, ZClasses, ZCompatibility, ZDbcIntfs,
62 ZConnectionGroup, ZAbstractConnection, ZURL,
67 DesignIntf, DesignEditors;
74 {** Implements the basic methods of the property editor. }
75 TZStringProperty = class(TStringProperty)
77 function GetAttributes: TPropertyAttributes; override;
78 procedure GetValueList(List: TStrings); virtual; abstract;
79 procedure GetValues(Proc: TGetStrProc); override;
80 function GetZComponent:TPersistent; virtual;
83 {** Shows all Fields received from FieldDefs. }
84 TZDataFieldPropertyEditor = class(TZStringProperty)
86 procedure GetValueList(List: TStrings); override;
89 {** Shows all Fields received from IndexDefs - not used yet. }
90 TZIndexFieldPropertyEditor = class(TZStringProperty)
92 procedure GetValueList(List: TStrings); override;
95 {** Shows all Fields received from the MasterSource's DataSet.FieldDefs. }
96 TZMasterFieldPropertyEditor = class(TZStringProperty)
98 procedure GetValueList(List: TStrings); override;
101 {** Shows all Tables received from Connection.IZDatabaseMetadata. }
102 TZTableNamePropertyEditor = class(TZStringProperty)
104 procedure GetValueList(List: TStrings); override;
107 {** Shows all Procedures received from Connection.IZDatabaseMetadata. }
108 TZProcedureNamePropertyEditor = class(TZStringProperty)
110 procedure GetValueList(List: TStrings); override;
113 {** Shows all Sequences received from Connection.IZDatabaseMetadata. }
114 TZSequenceNamePropertyEditor = class(TZStringProperty)
116 procedure GetValueList(List: TStrings); override;
119 {** Implements a property editor for ZConnection.Protocol property. }
120 TZProtocolPropertyEditor = class(TZStringProperty)
122 function GetValue: string; override;
123 procedure GetValueList(List: TStrings); override;
124 procedure SetValue(const Value: string); override;
127 {** Implements a property editor for ZConnection.ClientCodePage property. }
128 TZClientCodePagePropertyEditor = class(TZStringProperty)
130 function GetValue: string; override;
131 procedure GetValueList(List: TStrings); override;
132 procedure SetValue(const Value: string); override;
135 {** Implements a property editor for ZConnection.Database property. }
136 TZDatabasePropertyEditor = class(TZStringProperty)
138 function GetAttributes: TPropertyAttributes; override;
139 function GetValue: string; override;
140 procedure Edit; override;
141 procedure GetValueList(List: TStrings); override;
142 procedure SetValue(const Value: string); override;
145 {** Implements a property editor for ZConnection.LibLocation property. }
146 TZLibLocationPropertyEditor = class(TZStringProperty)
148 function GetAttributes: TPropertyAttributes; override;
149 function GetValue: string; override;
150 procedure Edit; override;
151 procedure SetValue(const Value: string); override;
154 // Modified by Una.Bicicleta 2010/10/31
155 {** Implements a property editor for ZConnectionGroup.Database property. }
156 TZConnectionGroupPropertyEditor = class(TZStringProperty)
158 function GetAttributes: TPropertyAttributes; override;
159 function GetValue: string; override;
160 procedure Edit; override;
161 procedure GetValueList(List: TStrings); override;
162 procedure SetValue(const Value: string); override;
165 {** Implements a property editor for ZGroupedConnection.Catalog property. }
166 TZGroupedConnectionCatalogPropertyEditor = class(TZStringProperty)
168 function GetValue: string; override;
169 procedure GetValueList(List: TStrings); override;
170 procedure SetValue(const Value: string); override;
173 {** Implements a property editor for ZGroupedConnection.LibLocation property. }
174 {** added 2013/02/20 }
175 TZConnectionGroupLibLocationPropertyEditor = class(TZStringProperty)
177 function GetAttributes: TPropertyAttributes; override;
178 function GetValue: string; override;
179 procedure Edit; override;
180 procedure SetValue(const Value: string); override;
182 /////////////////////////////////////////////////////////
185 {** Implements a property editor for ZConnection.Catalog property. }
186 TZCatalogPropertyEditor = class(TZStringProperty)
188 function GetValue: string; override;
189 procedure GetValueList(List: TStrings); override;
190 procedure SetValue(const Value: string); override;
193 {$IFDEF USE_METADATA}
194 {** Shows all Catalogs received from Connection.IZDatabaseMetadata. }
195 TZCatalogProperty = class(TZStringProperty)
197 procedure GetValueList(List: TStrings); override;
200 {** Shows all Columns received from Connection.IZDatabaseMetadata. }
201 TZColumnNamePropertyEditor = class(TZStringProperty)
203 procedure GetValueList(List: TStrings); override;
206 {** Shows all Schemes received from Connection.IZDatabaseMetadata. }
207 TZSchemaPropertyEditor = class(TZStringProperty)
209 procedure GetValueList(List: TStrings); override;
212 {** Shows all Types received from Connection.IZDatabaseMetadata. }
213 TZTypeNamePropertyEditor = class(TZStringProperty)
215 procedure GetValueList(List: TStrings); override;
226 {$IFDEF WITH_PROPERTY_EDITOR}
228 uses SysUtils, Forms, Dialogs, Controls, DB, TypInfo, ZSysUtils, ZSelectSchema
229 {$IFDEF USE_METADATA}
239 {$IFDEF SHOW_WARNING}
241 {$ENDIF SHOW_WARNING}
245 procedure GetItemNames(FieldDefs: TFieldDefs; List: TStrings); overload;
250 for i := 0 to Pred(FieldDefs.Count) do
251 List.Append(FieldDefs[i].Name);
254 procedure GetItemNames(IndexDefs: TIndexDefs; List: TStrings); overload;
259 for i := 0 to Pred(IndexDefs.Count) do
260 List.Append(IndexDefs[i].Name);
264 { Returns the IndexDefs from Dataset }
265 function GetIndexDefs(Component: TPersistent): TIndexDefs;
269 DataSet := Component as TDataSet;
270 Result := GetObjectProp(DataSet, 'IndexDefs') as TIndexDefs;
271 if Assigned(Result) then
273 Result.Updated := False;
278 function IsEmpty(const s: string): Boolean;
280 Result := Trim(s) = '';
286 Gets a type of property attributes.
287 @return a type of property attributes.
289 function TZStringProperty.GetAttributes: TPropertyAttributes;
291 Result := [paValueList, paSortList];
295 Processes a list of list items.
296 @param Proc a procedure to process the list items.
298 procedure TZStringProperty.GetValues(Proc: TGetStrProc);
303 Values := TStringList.Create;
305 GetValueList(Values);
306 for i := 0 to Pred(Values.Count) do
314 Gets the component that has the property.
316 function TZStringProperty.GetZComponent:TPersistent;
318 Result:=GetComponent(0);
321 { TZDataFieldPropertyEditor }
324 Processes a list of list items.
325 @param List the list to process the list items.
327 procedure TZDataFieldPropertyEditor.GetValueList(List: TStrings);
330 with (GetZComponent as TDataSet) do
332 // Update the FieldDefs and return the Fieldnames
333 FieldDefs.Updated := False;
336 FieldDefs.GetItemNames(List);
338 GetItemNames(FieldDefs, List);
345 { TZIndexFieldPropertyEditor }
347 procedure TZIndexFieldPropertyEditor.GetValueList(List: TStrings);
350 GetIndexDefs(GetZComponent).GetItemNames(List);
352 GetItemNames(GetIndexDefs(GetZComponent), List);
356 { TZMasterFieldPropertyEditor }
358 procedure TZMasterFieldPropertyEditor.GetValueList(List: TStrings);
360 DataSource: TDataSource;
362 DataSource := GetObjectProp(GetZComponent, 'MasterSource') as TDataSource;
363 if (DataSource <> nil) and (DataSource.DataSet <> nil) then
364 {$IFDEF WITH_WIDESTRINGS_GETFIELDNAMES}
365 DataSource.DataSet.GetFieldNames(TWideStrings(List));
367 DataSource.DataSet.GetFieldNames(List);
371 { TZTableNamePropertyEditor }
374 Processes a list of list items.
375 @param List the list to process the list items.
377 procedure TZTableNamePropertyEditor.GetValueList(List: TStrings);
379 Connection: TZAbstractConnection;
380 Metadata: IZDatabaseMetadata;
381 ResultSet: IZResultSet;
382 Schema, Tablename:String;
383 IdentifierConvertor: IZIdentifierConvertor;
386 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
387 if Assigned(Connection) and Connection.Connected then
389 Metadata := Connection.DbcConnection.GetMetadata;
390 IdentifierConvertor := Metadata.GetIdentifierConvertor;
391 Catalog := Connection.Catalog;
393 {$IFDEF USE_METADATA}
394 if GetZComponent is TZSqlMetadata then
396 Catalog := GetStrProp(GetZComponent, 'Catalog');
397 Schema := GetStrProp(GetZComponent, 'Schema');
398 {$IFDEF SHOW_WARNING}
399 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
400 (MessageDlg(SPropertyQuery + CRLF + SPropertyTables + CRLF +
401 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
412 // Look for the Tables of the defined Catalog and Schema
413 ResultSet := Metadata.GetTables(Catalog, Schema, '', nil);
414 while ResultSet.Next do
416 TableName := ResultSet.GetStringByName('TABLE_NAME');
417 TableName := IdentifierConvertor.Quote(TableName);
418 Schema := ResultSet.GetStringByName('TABLE_SCHEM');
419 (*if Connection.DbcConnection.GetMetadata.GetDatabaseInfo.SupportsCatalogsInTableDefinitions then
420 if Catalog <> '' then
422 TableName := IdentifierConvertor.Quote(Catalog) + IdentifierConvertor.Quote(Schema) + '.' + TableName
424 TableName := {IdentifierConvertor.Quote(Catalog) + '.' + }TableName
427 TableName := IdentifierConvertor.Quote(Schema) + '.' + TableName
429 TableName := TableName
432 TableName := IdentifierConvertor.Quote(Schema) + '.' + TableName
434 TableName := TableName;*)
436 TableName := IdentifierConvertor.Quote(Schema) + '.' + TableName;
437 if Catalog <> '' then
438 TableName := IdentifierConvertor.Quote(Catalog) + '.' + TableName;
448 { TZProcedureNamePropertyEditor }
451 Processes a list of list items.
452 @param List the list to process the list items.
454 procedure TZProcedureNamePropertyEditor.GetValueList(List: TStrings);
456 Connection: TZAbstractConnection;
457 Metadata: IZDatabaseMetadata;
458 IdentifierConvertor: IZIdentifierConvertor;
459 ResultSet: IZResultSet;
460 Catalog, Schema: string;
461 ProcedureName: string;
463 procedure ExtractOverload(OverloadSeparator: String);
468 SL := TStringList.Create;
469 PutSplitString(SL, ProcedureName, OverloadSeparator);
472 SL.Delete(SL.Count -1);
474 for i := 0 to SL.Count -1 do
475 if ProcedureName = '' then
476 ProcedureName := ProcedureName + SL[i]
478 ProcedureName := ProcedureName +OverloadSeparator+ SL[i]; //don't forget to give the delimiter back too
482 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
483 if Assigned(Connection) and Connection.Connected then
485 Metadata := Connection.DbcConnection.GetMetadata;
486 IdentifierConvertor := Metadata.GetIdentifierConvertor;
487 Catalog := Connection.Catalog;
489 {$IFDEF USE_METADATA}
490 if GetZComponent is TZSqlMetadata then
492 Catalog := GetStrProp(GetZComponent, 'Catalog');
493 Schema := GetStrProp(GetZComponent, 'Schema');
494 {$IFDEF SHOW_WARNING}
495 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
496 (MessageDlg(SPropertyQuery + CRLF + SPropertyProcedures + CRLF +
497 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
508 Metadata := Connection.DbcConnection.GetMetadata;
509 // Look for the Procedures
510 ResultSet := Metadata.GetProcedures(Catalog, Schema, '');
511 while ResultSet.Next do
513 ProcedureName := ResultSet.GetStringByName('PROCEDURE_NAME');
514 if ( not Metadata.GetDatabaseInfo.SupportsOverloadPrefixInStoredProcedureName ) then
515 if not ( StartsWith(ProcedureName, MetaData.GetDatabaseInfo.GetIdentifierQuoteString) or
516 EndsWith(ProcedureName, MetaData.GetDatabaseInfo.GetIdentifierQuoteString) or
517 (Pos('.', ProcedureName) > 0) ) then
518 ProcedureName := IdentifierConvertor.Quote(ProcedureName);
519 Schema := ResultSet.GetStringByName('PROCEDURE_SCHEM');
520 if Metadata.GetDatabaseInfo.SupportsCatalogsInProcedureCalls then
521 if Catalog <> '' then
523 ProcedureName := IdentifierConvertor.Quote(Catalog) +'.'+ IdentifierConvertor.Quote(Schema) + '.' + ProcedureName
525 ProcedureName := ProcedureName
528 ProcedureName := IdentifierConvertor.Quote(Schema) + '.' + ProcedureName
530 ProcedureName := ProcedureName
533 ProcedureName := IdentifierConvertor.Quote(Schema) + '.' + ProcedureName
535 ProcedureName := ProcedureName;
536 List.Add(ProcedureName);
545 { TZSequenceNamePropertyEditor }
548 Gets a selected string value.
549 @return a selected string value.
551 procedure TZSequenceNamePropertyEditor.GetValueList(List: TStrings);
553 Connection: TZAbstractConnection;
554 Metadata: IZDatabaseMetadata;
555 ResultSet: IZResultSet;
556 {$IFDEF USE_METADATA}
557 Catalog, Schema: string;
560 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
561 if Assigned(Connection) and Connection.Connected then
563 {$IFDEF USE_METADATA}
564 if GetZComponent is TZSqlMetadata then
566 Catalog := GetStrProp(GetZComponent, 'Catalog');
567 Schema := GetStrProp(GetZComponent, 'Schema');
568 {$IFDEF SHOW_WARNING}
569 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
570 (MessageDlg(SPropertyQuery + CRLF + SPropertySequences + CRLF +
571 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
574 Metadata := Connection.DbcConnection.GetMetadata;
575 // Look for the Procedures of the defined Catalog and Schema
576 ResultSet := Metadata.GetSequences(Catalog, Schema, '');
577 while ResultSet.Next do
578 List.Add(ResultSet.GetStringByName('SEQUENCE_NAME'));
587 Metadata := Connection.DbcConnection.GetMetadata;
588 // Look for the Procedures
589 ResultSet := Metadata.GetSequences(Connection.Catalog, '', '');
590 while ResultSet.Next do
591 if ResultSet.GetStringByName('SEQUENCE_SCHEM') <> '' then
592 List.Add(ResultSet.GetStringByName('SEQUENCE_SCHEM')+
593 '.'+ResultSet.GetStringByName('SEQUENCE_NAME'))
595 List.Add(ResultSet.GetStringByName('SEQUENCE_NAME'));
603 { TZProtocolPropertyEditor }
606 Gets a selected string value.
607 @return a selected string value.
609 function TZProtocolPropertyEditor.GetValue: string;
611 Result := GetStrValue;
615 Sets a new selected string value.
616 @param Value a new selected string value.
618 procedure TZProtocolPropertyEditor.SetValue(const Value: string);
621 if GetZComponent is TZAbstractConnection then
622 (GetZComponent as TZAbstractConnection).Connected := False;
626 Processes a list of list items.
627 @param List the list to process the list items.
629 procedure TZProtocolPropertyEditor.GetValueList(List: TStrings);
632 Drivers: IZCollection;
633 Protocols: TStringDynArray;
635 Drivers := DriverManager.GetDrivers;
637 for I := 0 to Drivers.Count - 1 do
639 Protocols := (Drivers[I] as IZDriver).GetSupportedProtocols;
640 for J := Low(Protocols) to High(Protocols) do
641 List.Append(Protocols[J]);
645 {TZClientCodePagePropertyEditor -> EgonHugeist 19.01.2012}
648 Sets a new selected string value.
649 @param Value a new selected string value.
651 function TZClientCodePagePropertyEditor.GetValue: string;
653 Result := GetStrValue;
657 Processes a list of list items.
658 @param List the list to process the list items.
660 procedure TZClientCodePagePropertyEditor.GetValueList(List: TStrings);
662 Connection: TZAbstractConnection;
664 SDyn: TStringDynArray;
668 if GetZComponent is TZAbstractConnection then
669 Connection := (GetZComponent as TZAbstractConnection)
673 if Assigned(Connection) then
675 if Connection.Protocol = '' then
676 List.Append('No Protocol selected!')
680 Url.Protocol := Connection.Protocol;
681 SDyn := DriverManager.GetDriver(Url.URL).GetSupportedClientCodePages(Url,
682 {$IFNDEF UNICODE}Connection.AutoEncodeStrings, {$ENDIF}True, Connection.ControlsCodePage);
684 for i := 0 to high(SDyn) do
685 List.Append(SDyn[i]);
687 TStringList(List).Sort;
693 Sets a new selected string value.
694 @param Value a new selected string value.
696 procedure TZClientCodePagePropertyEditor.SetValue(const Value: string);
699 if GetZComponent is TZAbstractConnection then
700 (GetZComponent as TZAbstractConnection).Connected := False;
704 { TZDatabasePropertyEditor }
707 Gets a type of property attributes.
708 @return a type of property attributes.
710 function TZDatabasePropertyEditor.GetAttributes: TPropertyAttributes;
712 if GetZComponent is TZAbstractConnection then
714 if ((GetZComponent as TZAbstractConnection).Protocol = 'mssql') or
715 ((GetZComponent as TZAbstractConnection).Protocol = 'sybase') then
716 Result := inherited GetAttributes
718 Result := [paDialog];
723 Gets a selected string value.
724 @return a selected string value.
726 function TZDatabasePropertyEditor.GetValue: string;
728 Result := GetStrValue;
732 Sets a new selected string value.
733 @param Value a new selected string value.
735 procedure TZDatabasePropertyEditor.SetValue(const Value: string);
738 if GetZComponent is TZAbstractConnection then
739 (GetZComponent as TZAbstractConnection).Connected := False;
743 Processes a list of list items.
744 @param List the list to process the list items.
746 procedure TZDatabasePropertyEditor.GetValueList(List: TStrings);
748 DbcConnection: IZConnection;
751 if GetZComponent is TZAbstractConnection then
753 URL := (GetZComponent as TZAbstractConnection).GetURL;
754 (GetZComponent as TZAbstractConnection).ShowSqlHourGlass;
756 DbcConnection := DriverManager.GetConnectionWithParams(Url,
757 (GetZComponent as TZAbstractConnection).Properties);
759 with DbcConnection.GetMetadata.GetCatalogs do
762 List.Append(GetStringByName('TABLE_CAT'));
768 (GetZComponent as TZAbstractConnection).HideSqlHourGlass;
776 Brings up the proper database property editor dialog.
778 procedure TZDatabasePropertyEditor.Edit;
782 if GetZComponent is TZAbstractConnection then
784 if ((GetZComponent as TZAbstractConnection).Protocol = 'mssql') or
785 ((GetZComponent as TZAbstractConnection).Protocol = 'sybase') then
791 if ((GetZComponent as TZAbstractConnection).Protocol = 'ado') then
792 (GetZComponent as TZAbstractConnection).Database := PromptDataSource(Application.Handle,
793 (GetZComponent as TZAbstractConnection).Database)
799 OD := TOpenDialog.Create(nil);
801 OD.InitialDir := ExtractFilePath((GetZComponent as TZAbstractConnection).Database);
803 (GetZComponent as TZAbstractConnection).Database := OD.FileName;
813 { TZLibLocationPropertyEditor }
816 Gets a type of property attributes.
817 @return a type of property attributes.
819 function TZLibLocationPropertyEditor.GetAttributes: TPropertyAttributes;
821 if GetZComponent is TZAbstractConnection then
822 Result := [paDialog];
826 Gets a selected string value.
827 @return a selected string value.
829 function TZLibLocationPropertyEditor.GetValue: string;
831 Result := GetStrValue;
835 Sets a new selected string value.
836 @param Value a new selected string value.
838 procedure TZLibLocationPropertyEditor.SetValue(const Value: string);
841 if GetZComponent is TZAbstractConnection then
842 (GetZComponent as TZAbstractConnection).Connected := False;
846 Brings up the proper LibLocation property editor dialog.
848 procedure TZLibLocationPropertyEditor.Edit;
852 if GetZComponent is TZAbstractConnection then
854 OD := TOpenDialog.Create(nil);
856 OD.InitialDir := ExtractFilePath((GetZComponent as TZAbstractConnection).LibLocation);
858 (GetZComponent as TZAbstractConnection).LibLocation := OD.FileName;
867 { TZCatalogPropertyEditor }
870 Gets a selected string value.
871 @return a selected string value.
873 function TZCatalogPropertyEditor.GetValue: string;
875 Result := GetStrValue;
879 Sets a new selected string value.
880 @param Value a new selected string value.
882 procedure TZCatalogPropertyEditor.SetValue(const Value: string);
888 Processes a list of list items.
889 @param List the list to process the list items.
891 procedure TZCatalogPropertyEditor.GetValueList(List: TStrings);
893 DbcConnection: IZConnection;
896 if GetZComponent is TZAbstractConnection then
898 URL := (GetZComponent as TZAbstractConnection).GetURL;
899 (GetZComponent as TZAbstractConnection).ShowSqlHourGlass;
901 DbcConnection := DriverManager.GetConnectionWithParams(Url,
902 (GetZComponent as TZAbstractConnection).Properties);
904 if Assigned(DbcConnection) then
905 if DbcConnection.GetMetadata.GetDatabaseInfo.SupportsCatalogsInDataManipulation then
906 with DbcConnection.GetMetadata.GetCatalogs do
909 List.Append(GetStringByName('TABLE_CAT'));
913 else if DbcConnection.GetMetadata.GetDatabaseInfo.SupportsSchemasInDataManipulation then
914 with DbcConnection.GetMetadata.GetSchemas do
917 List.Append(GetStringByName('TABLE_SCHEM'));
922 (GetZComponent as TZAbstractConnection).HideSqlHourGlass;
929 {$IFDEF USE_METADATA}
931 { TZCatalogProperty }
934 Processes a list of list items.
935 @param List the list to process the list items.
937 procedure TZCatalogProperty.GetValueList(List: TStrings);
939 Connection: TZAbstractConnection;
940 Metadata: IZDatabaseMetadata;
941 ResultSet: IZResultSet;
943 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
944 if Assigned(Connection) and Connection.Connected then
946 Metadata := Connection.DbcConnection.GetMetadata;
947 ResultSet := Metadata.GetCatalogs;
948 while ResultSet.Next do
949 List.Add(ResultSet.GetStringByName('TABLE_CAT'));
955 { TZColumnNamePropertyEditor }
958 Processes a list of list items.
959 @param List the list to process the list items.
961 procedure TZColumnNamePropertyEditor.GetValueList(List: TStrings);
963 Connection: TZAbstractConnection;
964 Metadata: IZDatabaseMetadata;
965 ResultSet: IZResultSet;
966 Catalog, Schema, TableName: string;
968 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
969 if Assigned(Connection) and Connection.Connected then
971 Catalog := GetStrProp(GetZComponent, 'Catalog');
972 Schema := GetStrProp(GetZComponent, 'Schema');
973 TableName := GetStrProp(GetZComponent, 'TableName');
974 {$IFDEF SHOW_WARNING}
975 if not IsEmpty(TableName) or not (IsEmpty(Schema) and IsEmpty(Schema)) or
976 (MessageDlg(SPropertyQuery + CRLF + SPropertyTables + CRLF +
977 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
980 Metadata := Connection.DbcConnection.GetMetadata;
981 // Look for the Columns of the defined Catalog, Schema and TableName
982 ResultSet := Metadata.GetColumns(Catalog, Schema, TableName, '');
983 while ResultSet.Next do
984 if List.IndexOf(ResultSet.GetStringByName('COLUMN_NAME')) = -1 then
985 List.Add(ResultSet.GetStringByName('COLUMN_NAME'));
992 { TZSchemaPropertyEditor }
995 Processes a list of list items.
996 @param List the list to process the list items.
998 procedure TZSchemaPropertyEditor.GetValueList(List: TStrings);
1000 Connection: TZAbstractConnection;
1001 Metadata: IZDatabaseMetadata;
1002 ResultSet: IZResultSet;
1004 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
1005 if Assigned(Connection) and Connection.Connected then
1007 Metadata := Connection.DbcConnection.GetMetadata;
1008 ResultSet := Metadata.GetSchemas;
1009 while ResultSet.Next do
1010 List.Add(ResultSet.GetStringByName('TABLE_SCHEM'));
1016 { TZTypeNamePropertyEditor }
1019 Processes a list of list items.
1020 @param List the list to process the list items.
1022 procedure TZTypeNamePropertyEditor.GetValueList(List: TStrings);
1024 Connection: TZAbstractConnection;
1025 Metadata: IZDatabaseMetadata;
1026 ResultSet: IZResultSet;
1028 Connection := GetObjectProp(GetZComponent, 'Connection') as TZAbstractConnection;
1029 if Assigned(Connection) and Connection.Connected then
1031 Metadata := Connection.DbcConnection.GetMetadata;
1032 ResultSet := Metadata.GetTypeInfo;
1033 while ResultSet.Next do
1034 List.Add(ResultSet.GetStringByName('TYPE_NAME'));
1041 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1043 { TZConnectionGroupCatalogPropertyEditor }
1046 function TZGroupedConnectionCatalogPropertyEditor.GetValue: string;
1048 Result := GetStrValue;
1051 procedure TZGroupedConnectionCatalogPropertyEditor.SetValue(const Value: string);
1056 procedure TZGroupedConnectionCatalogPropertyEditor.GetValueList(List: TStrings);
1058 DbcConnection: IZConnection;
1061 if GetZComponent is TZAbstractConnection then
1063 URL := (GetZComponent as TZAbstractConnection).GetURL;
1064 (GetZComponent as TZAbstractConnection).ShowSqlHourGlass;
1066 DbcConnection := DriverManager.GetConnectionWithParams(Url,
1067 (GetZComponent as TZAbstractConnection).Properties);
1069 with DbcConnection.GetMetadata.GetCatalogs do
1072 List.Append(GetStringByName('TABLE_CAT'));
1078 (GetZComponent as TZAbstractConnection).HideSqlHourGlass;
1088 { TZConnectionGroupPropertyEditor }
1091 Gets a type of property attributes.
1092 @return a type of property attributes.
1094 function TZConnectionGroupPropertyEditor.GetAttributes: TPropertyAttributes;
1096 if GetZComponent is TZConnectionGroup then
1098 if ((GetZComponent as TZConnectionGroup).Protocol = 'mssql') or
1099 ((GetZComponent as TZConnectionGroup).Protocol = 'sybase') then
1100 Result := inherited GetAttributes
1102 Result := [paDialog];
1107 Gets a selected string value.
1108 @return a selected string value.
1110 function TZConnectionGroupPropertyEditor.GetValue: string;
1112 Result := GetStrValue;
1116 Sets a new selected string value.
1117 @param Value a new selected string value.
1119 procedure TZConnectionGroupPropertyEditor.SetValue(const Value: string);
1122 // if GetZComponent is TZConnectionGroup then
1123 // (GetZComponent as TZConnectionGroup).Connected := False;
1127 Processes a list of list items.
1128 @param List the list to process the list items.
1130 procedure TZConnectionGroupPropertyEditor.GetValueList(List: TStrings);
1132 DbcConnection: IZConnection;
1134 if GetZComponent is TZConnectionGroup then
1136 DbcConnection := (GetZComponent as TZAbstractConnection).DbcConnection;
1137 with DbcConnection.GetMetadata.GetCatalogs do
1140 List.Append(GetStringByName('TABLE_CAT'));
1150 Brings up the proper database property editor dialog.
1152 procedure TZConnectionGroupPropertyEditor.Edit;
1156 if GetZComponent is TZConnectionGroup then
1158 if ((GetZComponent as TZConnectionGroup).Protocol = 'mssql') or
1159 ((GetZComponent as TZConnectionGroup).Protocol = 'sybase') then
1165 if ((GetZComponent as TZConnectionGroup).Protocol = 'ado') then
1166 (GetZComponent as TZConnectionGroup).Database := PromptDataSource(Application.Handle,
1167 (GetZComponent as TZConnectionGroup).Database)
1173 OD := TOpenDialog.Create(nil);
1175 OD.InitialDir := ExtractFilePath((GetZComponent as TZConnectionGroup).Database);
1177 (GetZComponent as TZConnectionGroup).Database := OD.FileName;
1187 {** added 2013/02/20 }
1188 { TZConnectionGroupLibLocationPropertyEditor }
1191 Gets a type of property attributes.
1192 @return a type of property attributes.
1194 function TZConnectionGroupLibLocationPropertyEditor.GetAttributes: TPropertyAttributes;
1196 if GetZComponent is TZConnectionGroup then
1197 Result := [paDialog];
1201 Gets a selected string value.
1202 @return a selected string value.
1204 function TZConnectionGroupLibLocationPropertyEditor.GetValue: string;
1206 Result := GetStrValue;
1210 Sets a new selected string value.
1211 @param Value a new selected string value.
1213 procedure TZConnectionGroupLibLocationPropertyEditor.SetValue(const Value: string);
1216 //if GetZComponent is TZAbstractConnection then
1217 // (GetZComponent as TZAbstractConnection).Connected := False;
1221 Brings up the proper LibLocation property editor dialog.
1223 procedure TZConnectionGroupLibLocationPropertyEditor.Edit;
1227 if GetZComponent is TZConnectionGroup then
1229 OD := TOpenDialog.Create(nil);
1231 OD.InitialDir := ExtractFilePath((GetZComponent as TZConnectionGroup).LibraryLocation);
1233 (GetZComponent as TZConnectionGroup).LibraryLocation := OD.FileName;