{******************************************************************************}
{                       CnPack For Delphi/C++Builder                           }
{                     中国人自己的开放源码第三方开发包                         }
{                   (C)Copyright 2001-2015 CnPack 开发组                       }
{                   ------------------------------------                       }
{                                                                              }
{            本开发包是开源的自由软件，您可以遵照 CnPack 的发布协议来修        }
{        改和重新发布这一程序。                                                }
{                                                                              }
{            发布这一开发包的目的是希望它有用，但没有任何担保。甚至没有        }
{        适合特定目的而隐含的担保。更详细的情况请参阅 CnPack 发布协议。        }
{                                                                              }
{            您应该已经和开发包一起收到一份 CnPack 发布协议的副本。如果        }
{        还没有，可访问我们的网站：                                            }
{                                                                              }
{            网站地址：http://www.cnpack.org                                   }
{            电子邮件：master@cnpack.org                                       }
{                                                                              }
{******************************************************************************}

unit CnDBRegister;
{* |<PRE>
================================================================================
* 软件名称：CnPack 数据库工具组件包
* 单元名称：数据库组件包注册单元
* 单元作者：CnPack开发组
* 备    注：
* 开发平台：PWin98SE + Delphi 5.0
* 兼容测试：PWin9X/2000/XP + Delphi 5/6
* 本 地 化：该单元中的字符串均符合本地化处理方式
* 单元标识：$Id$
* 修改记录：2007.12.12 V1.0
*                创建单元
================================================================================
|</PRE>}

interface

{$I CnPack.inc}

uses
  Windows, Messages, SysUtils, Classes, Graphics,
{$IFDEF SUPPORT_ADO}
  {$IFDEF SUPPORTS_CROSS_PLATFORM} Data.Win.AdoConEd {$ELSE} AdoConEd {$ENDIF},
{$ENDIF}
{$IFDEF COMPILER6_UP}
  DesignIntf, DesignEditors,
{$ELSE}
  DsgnIntf,
{$ENDIF}
  CnCompRegister, {$IFNDEF COMPILER5}CnSQLAnalyzer, {$ENDIF} CnADOConPool, CnConsts,
  CnADOUpdateSQLEditor, CnADOUpdateSQL, CnPagedGrid {$IFDEF COMPILER6_UP},
  CnDHibernateConsts, CnDHibernateClasses, CnDHibernateMemData,
  CnDHibernateQueryAdv, CnDHibernateSubQuery, CnDhibernateSubQueryAdv,
  CnDHibernateAbout, CnDHibernateThread, CnDHibernateImport, CnDHibernateExport,
  CnDHibernateCalc, CnDHibernateBackupRestore, CnDHibernateNavigator,
  CnDHibernateBatchSQL{$ENDIF};

{$IFDEF SUPPORT_ADO}
type
  TADOConStringProperty = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

{$IFDEF COMPILER6_UP}
  TCnDHAboutEditor = class(TStringProperty)
  public
    procedure Edit; override;
    function GetValue: string; override;
    function GetAttributes: TPropertyAttributes; override;
  end;
{$ENDIF}

{$ENDIF}

procedure Register;
{* 控件、组件编辑器、属性编辑器注册过程}

implementation

procedure Register;
begin
{$IFDEF SUPPORT_ADO}
{$IFNDEF COMPILER5}
  RegisterComponents(SCnDatabasePalette, [TCnSQLAnalyzer]);
  RegisterPropertyEditor(TypeInfo(string), TCnSQLAnalyzer,
    'ConnectionString', TADOConStringProperty);
{$ENDIF}
  RegisterComponents(SCnDatabasePalette, [TCnADOConPool]);
  RegisterPropertyEditor(TypeInfo(WideString), TCnADOConPool,
    'ConnectionString', TADOConStringProperty);
  RegisterComponents(SCnDatabasePalette, [TCnADOUpdateSQL]);
  RegisterComponentEditor(TCnADOUpdateSQL, TCnADOUpdateSQLEditor);

{$IFNDEF COMPILER5}
  RegisterComponents(SCnDatabasePalette, [
    TCnDHibernateQuery, TCnDHibernateQueryAdvance, {$IFNDEF DELPHI2009_UP}TCnDHibernateMemData, {$ENDIF}
      TCnDHibernateIdGenerator, TCnDHibernateSubQuery, TCnDHibernateSubQueryAdvance,
      TCnDHibernateThread, TCnDHibernateImport, TCnDHibernateExport,
      TCnDHibernateCalculator, TCnDHibernateBackupRestore, TCnDHibernateNavigator,
      TCnDHibernateBatchSQL]);

  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateQuery, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateQueryAdvance, 'About',
    TCnDHAboutEditor);

{$IFNDEF DELPHI2009_UP}
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateMemData, 'About',
    TCnDHAboutEditor);
{$ENDIF}

  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateIdGenerator, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateSubQuery, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateSubQueryAdvance, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateThread, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateImport, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateExport, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateCalculator, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateBackupRestore, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateNavigator, 'About',
    TCnDHAboutEditor);
  RegisterPropertyEditor(TypeInfo(string), TCnDHibernateBatchSQL, 'About',
    TCnDHAboutEditor);
{$ENDIF}
{$ENDIF}

{$IFDEF SUPPORT_DB}
  RegisterComponents(SCnDatabasePalette, [TCnPagedGrid]);
{$ENDIF}
end;

{ TADOConStringProperty }

{$IFDEF SUPPORT_ADO}
procedure TADOConStringProperty.Edit;
begin
  if EditConnectionString(GetComponent(0) as TComponent) then
    Modified;
end;

function TADOConStringProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

{$IFDEF COMPILER6_UP}

{ TCnDHAboutEditor }

procedure TCnDHAboutEditor.Edit;
begin
  inherited;
  with TCnFormDHibernateAbout.Create(nil) do
  begin
    ShowModal;
    Free;
  end;
end;

function TCnDHAboutEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paReadOnly, paDialog];
end;

function TCnDHAboutEditor.GetValue: string;
begin
  Result := 'CnPack';
end;

{$ENDIF}

{$ENDIF}

end.
