📄 eerreverseengineering.pas
字号:
unit EERReverseEngineering;
//----------------------------------------------------------------------------------------------------------------------
//
// This file is part of fabFORCE DBDesigner4.
// Copyright (C) 2002 Michael G. Zinner, www.fabFORCE.net
//
// DBDesigner4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// DBDesigner4 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with DBDesigner4; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//----------------------------------------------------------------------------------------------------------------------
//
// Unit EERReverseEngineering
// --------------------------
// Version 1.0, 13.03.2003, Mike
// Description
// Contains a graphical user interface for the reverse engineering functions
//
// Changes:
// Version 1.0, 13.03.2003, Mike
// initial version
//
//----------------------------------------------------------------------------------------------------------------------
interface
uses
SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs,
QStdCtrls, QButtons, QExtCtrls, QComCtrls, EERModel, QCheckLst, Qt, IniFiles,
QMenus, QTypes;
type
TEERReverseEngineeringForm = class(TForm)
StatusPnl: TPanel;
StatusLbl: TLabel;
ConnectionSBtn: TSpeedButton;
OptionPnl: TPanel;
Bevel1: TBevel;
SubmitBtn: TSpeedButton;
CancelBtn: TSpeedButton;
GroupBox1: TGroupBox;
TblCountEd: TEdit;
RevEngTypeCBox: TComboBox;
Label5: TLabel;
ImportSchemaCBox: TCheckBox;
CollapseTablesCBox: TCheckBox;
RelGroupBox: TGroupBox;
BuildRelPrimKeyRBtn: TRadioButton;
BuildRelTblNamesRBtn: TRadioButton;
UseNativeRelationsRBtn: TRadioButton;
BuildRelationsCBox: TCheckBox;
DataTypeSubstGroupBox: TGroupBox;
SubstCBox: TComboBox;
SubstMemo: TMemo;
UseSubstCBox: TCheckBox;
StdInsertsGroupBox: TGroupBox;
LimitStdInsCBox: TCheckBox;
LimitStdInsEd: TEdit;
CreateStdInsertsCBox: TCheckBox;
TopPnl: TPanel;
Label1: TLabel;
DBConnEd: TEdit;
GetDBConnSBtn: TSpeedButton;
Label2: TLabel;
Label4: TLabel;
SchemaPnl: TPanel;
SchemaLeftSepPnl: TPanel;
TablesLBox: TCheckListBox;
SchemaLookupPnl: TPanel;
SchemaCBox: TComboBox;
TablesPopupMenu: TPopupMenu;
SelectallTables1: TMenuItem;
DeselectallTables1: TMenuItem;
GroupBox2: TGroupBox;
Label3: TLabel;
PutDefValsInQuotesCBox: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
function SetData(theModel: TEERModel): Boolean;
procedure GetDBConnSBtnClick(Sender: TObject);
procedure SubmitBtnClick(Sender: TObject);
procedure SelAllTablesSBtnClick(Sender: TObject);
procedure DeselectAllTablesSBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SubstCBoxCloseUp(Sender: TObject);
procedure UseSubstCBoxClick(Sender: TObject);
procedure SchemaCBoxCloseUp(Sender: TObject);
procedure GetTranslations;
procedure GetSubstNames;
procedure CreateStdInsertsCBoxClick(Sender: TObject);
procedure BuildRelationsCBoxClick(Sender: TObject);
procedure RevEngTypeCBoxCloseUp(Sender: TObject);
private
{ Private-Deklarationen }
//Use flag because of InvisibleForm error
CheckORCLFuncCBox: Boolean;
AllTables: TStringList;
public
{ Public-Deklarationen }
EERModel: TEERModel;
end;
var
EERReverseEngineeringForm: TEERReverseEngineeringForm;
implementation
uses MainDM, EERDM, DBDM, DBEERDM;
{$R *.xfm}
procedure TEERReverseEngineeringForm.FormCreate(Sender: TObject);
begin
DMMain.InitForm(self);
CheckORCLFuncCBox:=False;
AllTables:=TStringList.Create;
GetTranslations;
//Remove SQLite functions for the moment
//RevEngTypeCBox.Items.Delete(RevEngTypeCBox.Items.Count-1);
end;
procedure TEERReverseEngineeringForm.GetTranslations;
var theStrings: TStringList;
begin
theStrings:=TStringList.Create;
try
//Translate Methods
RevEngTypeCBox.Items.Clear;
DMMain.GetFormResourceStrings(self, 'RevEngMethod', theStrings);
RevEngTypeCBox.Items.Assign(theStrings);
if(RevEngTypeCBox.Items.Count=0)then
begin
RevEngTypeCBox.Items.Add('Use general functions (ODBC)');
RevEngTypeCBox.Items.Add('Use MySQL specific functions');
RevEngTypeCBox.Items.Add('Use Oracle specific functions');
RevEngTypeCBox.Items.Add('Use SQLite specific functions');
RevEngTypeCBox.Items.Add('Use MSSQL specific functions');
end;
finally
end;
end;
procedure TEERReverseEngineeringForm.FormDestroy(Sender: TObject);
begin
AllTables.Free;
end;
procedure TEERReverseEngineeringForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//After work, close connection
DMDB.DisconnectFromDB;
end;
procedure TEERReverseEngineeringForm.FormShow(Sender: TObject);
begin
SubstCBoxCloseUp(self);
SetFocus;
end;
procedure TEERReverseEngineeringForm.GetDBConnSBtnClick(Sender: TObject);
var SelDBConn: TDBConn;
SelDBConnName, s: string;
theTables: TStringList;
i: integer;
begin
SelDBConnName:='';
DBConnEd.Text:='';
DMDB.DisconnectFromDB;
StatusLbl.Caption:=DMMain.GetTranslatedMessage('Not connected to a Database', 27);
ConnectionSBtn.Enabled:=False;
SubmitBtn.Enabled:=False;
//do until a successful connection is established or the user selects abort
while(1=1)do
begin
//Let the User choose connection
SelDBConn:=DMDB.GetUserSelectedDBConn('');
if(SelDBConn<>nil)then
begin
SelDBConnName:=SelDBConn.Name;
//Try to connect to the DB
try
DMDB.ConnectToDB(SelDBConn);
except
on x: Exception do
begin
MessageDlg(DMMain.GetTranslatedMessage('Connection to database failed.'+#13#10#13#10+'%s', 121,
x.Message), mtError, [mbOK], 0);
continue;
end;
end;
ConnectionSBtn.Enabled:=True;
SubmitBtn.Enabled:=True;
DBConnEd.Text:=DMDB.CurrentDBConn.Name;
StatusLbl.Caption:=DMMain.GetTranslatedMessage('Connected to Database %s', 28,
DMDB.CurrentDBConn.Params.Values['User_Name']+'@'+
DMDB.CurrentDBConn.Params.Values['Database']);
theTables:=TStringList.Create;
try
DMDB.GetDBTables(theTables);
//Ignore DBDesigner4 table
if(theTables.IndexOf('DBDesigner4')<>-1)then
theTables.Delete(theTables.IndexOf('DBDesigner4'));
TablesLBox.Items.Assign(theTables);
finally
theTables.Free;
end;
AllTables.Assign(TablesLBox.Items);
//Fill Schema CBox
SchemaCBox.Items.Clear;
SchemaCBox.Items.Add('All');
for i:=0 to TablesLBox.Items.Count-1 do
begin
s:=TablesLBox.Items[i];
if(Copy(s, 1, 1)='"')then
s:=Copy(s, 2, Length(s)-2);
if(Copy(s, 1, 3)<>'SYS')and
(Copy(s, 1, 6)<>'CTXSYS')and
(Copy(s, 1, 5)<>'MDSYS')and
(Copy(s, 1, 3)<>'ODM')and
(Copy(s, 1, 7)<>'OLAPSYS')and
(Copy(s, 1, 2)<>'QS')and
(Copy(s, 1, 5)<>'WKSYS')and
(Copy(s, 1, 6)<>'CTXSYS')then
if(SchemaCBox.Items.IndexOf(Copy(TablesLBox.Items[i], 1, Pos('.', TablesLBox.Items[i])-1))=-1)then
SchemaCBox.Items.Add(Copy(TablesLBox.Items[i], 1, Pos('.', TablesLBox.Items[i])-1));
end;
SchemaCBox.ItemIndex:=0;
SelAllTablesSBtnClick(self);
//Do for Access, unselect all tables starting with MSys
for i:=0 to TablesLBox.Items.Count-1 do
if(Copy(TablesLBox.Items[i], 2, 4)='MSys')then
TablesLBox.Checked[i]:=False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -