diff --git a/ORDESY.dpr b/ORDESY.dpr
index 11b3142..a02453a 100644
--- a/ORDESY.dpr
+++ b/ORDESY.dpr
@@ -7,7 +7,7 @@ uses
uLog in 'uLog.pas',
uExplode in 'uExplode.pas',
uShellFuncs in 'uShellFuncs.pas',
- uProject in 'uProject.pas' {fmProject},
+ uProjectDialogs in 'uProjectDialogs.pas' {fmProject},
uOptions in 'uOptions.pas',
uHash in 'uHash.pas',
uWrap in 'uWrap.pas' {fmWrap};
diff --git a/ORDESY.dproj b/ORDESY.dproj
index c137050..990851f 100644
--- a/ORDESY.dproj
+++ b/ORDESY.dproj
@@ -46,7 +46,7 @@
-
+
@@ -86,7 +86,7 @@
1
0
0
- 664
+ 764
False
False
False
@@ -98,7 +98,7 @@
- 1.0.0.664
+ 1.0.0.764
diff --git a/ORDESY.res b/ORDESY.res
index 586dc32..2518524 100644
Binary files a/ORDESY.res and b/ORDESY.res differ
diff --git a/uMain.dfm b/uMain.dfm
index 0d3e189..1008207 100644
--- a/uMain.dfm
+++ b/uMain.dfm
@@ -45,8 +45,12 @@ object fmMain: TfmMain
Width = 217
Height = 347
Align = alLeft
+ DoubleBuffered = True
+ HideSelection = False
Images = imlMain
Indent = 19
+ MultiSelectStyle = []
+ ParentDoubleBuffered = False
PopupMenu = ppmMain
ReadOnly = True
SortType = stText
@@ -184,58 +188,58 @@ object fmMain: TfmMain
end
object miProject: TMenuItem
Caption = 'Project'
- object miCreateProject: TMenuItem
- Caption = 'Create project'
- OnClick = miCreateProjectClick
+ object miAddProject: TMenuItem
+ Caption = 'Add project'
+ OnClick = AddProject
end
- object miProjectOptions: TMenuItem
- Caption = 'Project options'
+ object miEditProject: TMenuItem
+ Caption = 'Edit project'
+ end
+ object miModule: TMenuItem
+ Caption = 'Module'
+ object AddModule1: TMenuItem
+ Caption = 'Add Module'
+ end
+ object miModuleList: TMenuItem
+ Caption = 'Module List'
+ end
+ end
+ object miItem: TMenuItem
+ Caption = 'Item'
+ object miWrapItem: TMenuItem
+ Caption = 'Wrap item'
+ end
+ object miDeployItem: TMenuItem
+ Caption = 'Deploy Item'
+ end
+ object miItemList: TMenuItem
+ Caption = 'Item list'
+ end
end
object miShow: TMenuItem
- Caption = 'Show'
+ Caption = 'Show projects'
object miShowAll: TMenuItem
Caption = 'All'
Checked = True
end
end
end
- object miModule: TMenuItem
- Caption = 'Module'
- object miCreateModule: TMenuItem
- Caption = 'Create module'
- end
- object miEditModule: TMenuItem
- Caption = 'Module options'
- end
- end
object miBase: TMenuItem
Caption = 'Base'
- object miCreateBase: TMenuItem
- Caption = 'Create base'
+ object miAddBase: TMenuItem
+ Caption = 'Add base'
end
- object miEditBase: TMenuItem
- Caption = 'Base options'
+ object miBaseList: TMenuItem
+ Caption = 'Base list'
end
end
object miScheme: TMenuItem
Caption = 'Scheme'
- object miCreateScheme: TMenuItem
- Caption = 'Create scheme'
- end
- object miEditScheme: TMenuItem
- Caption = 'Scheme options'
- end
- end
- object miItem: TMenuItem
- Caption = 'Item'
- object miCreateItem: TMenuItem
- Caption = 'Create item'
- end
- object miEditItem: TMenuItem
- Caption = 'Object options'
+ object miAddScheme: TMenuItem
+ Caption = 'Add scheme'
end
- object miWrapItem: TMenuItem
- Caption = 'Wrap item'
+ object miSchemeList: TMenuItem
+ Caption = 'Scheme list'
end
end
object miLast: TMenuItem
diff --git a/uMain.pas b/uMain.pas
index 257fe99..2be5c2f 100644
--- a/uMain.pas
+++ b/uMain.pas
@@ -24,7 +24,7 @@ interface
{$IFDEF Debug}
uLog,
{$ENDIF}
- uORDESY, uExplode, uShellFuncs, uProject, uOptions, uWrap,
+ uORDESY, uExplode, uShellFuncs, uProjectDialogs, uOptions, uWrap,
// Delphi Modules
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, ComCtrls, ToolWin, ImgList, Buttons;
@@ -43,27 +43,20 @@ TfmMain = class(TForm)
edtUserName: TEdit;
lblUserName: TLabel;
miProject: TMenuItem;
- miCreateProject: TMenuItem;
+ miAddProject: TMenuItem;
miOptions: TMenuItem;
miShow: TMenuItem;
miShowAll: TMenuItem;
miScheme: TMenuItem;
- miCreateScheme: TMenuItem;
- miEditScheme: TMenuItem;
- miProjectOptions: TMenuItem;
- miItem: TMenuItem;
- miCreateItem: TMenuItem;
- miEditItem: TMenuItem;
+ miAddScheme: TMenuItem;
+ miSchemeList: TMenuItem;
+ miEditProject: TMenuItem;
miLast: TMenuItem;
miAbout: TMenuItem;
miHelp: TMenuItem;
splMain: TSplitter;
miBase: TMenuItem;
- miCreateBase: TMenuItem;
- miModule: TMenuItem;
- miEditBase: TMenuItem;
- miCreateModule: TMenuItem;
- miEditModule: TMenuItem;
+ miBaseList: TMenuItem;
ppmMain: TPopupMenu;
gbInfo: TGroupBox;
edName: TEdit;
@@ -71,27 +64,36 @@ TfmMain = class(TForm)
lblDescription: TLabel;
mmoDesc: TMemo;
miSavechanges: TMenuItem;
+ miModule: TMenuItem;
+ miModuleList: TMenuItem;
+ AddModule1: TMenuItem;
+ miAddBase: TMenuItem;
+ miItem: TMenuItem;
+ miItemList: TMenuItem;
miWrapItem: TMenuItem;
+ miDeployItem: TMenuItem;
procedure miExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure tvMainGetImageIndex(Sender: TObject; Node: TTreeNode);
procedure splMainMoved(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure WMWindowPosChanged(var aMessage: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
- procedure miCreateProjectClick(Sender: TObject);
procedure ViewProjects(aTreeView: TTreeView);
procedure ppmMainPopup(Sender: TObject);
+ procedure AddProject(Sender: TObject);
procedure EditProject(Sender: TObject);
procedure DeleteProject(Sender: TObject);
procedure WrapItem(Sender: TObject);
- procedure AddBase(Sender: TObject);
+ procedure AddModule(Sender: TObject);
+ procedure EditModule(Sender: TObject);
+ procedure DeleteModule(Sender: TObject);
procedure tvMainClick(Sender: TObject);
procedure miFileClick(Sender: TObject);
procedure miSavechangesClick(Sender: TObject);
private
AppOptions: TOptions;
ProjectList: TORDESYProjectList;
- function CanPopup(const aTag: integer; aObject: TObject): boolean;
+ function CanPopup(const aTag: integer; aObject: Pointer): boolean;
procedure PrepareGUI;
procedure UpdateGUI;
procedure PrepareOptions;
@@ -108,6 +110,22 @@ implementation
{$R *.dfm}
+procedure TfmMain.DeleteModule(Sender: TObject);
+var
+ reply: word;
+ Project: TORDESYProject;
+begin
+ Project:= TORDESYProject(TORDESYModule(tvMain.Selected.Data).ProjectRef);
+ reply:= MessageBox(Handle, PChar('Delete module?' + #13#10), PChar('Confirm'), 36);
+ if reply = IDYES then
+ begin
+ tvMain.Deselect(tvMain.Selected);
+ Project.RemoveModuleById(TORDESYModule(tvMain.Selected.Data).Id);
+ tvMain.Selected.Data:= nil;
+ UpdateGUI;
+ end;
+end;
+
procedure TfmMain.DeleteProject(Sender: TObject);
var
reply: word;
@@ -117,17 +135,23 @@ procedure TfmMain.DeleteProject(Sender: TObject);
reply:= MessageBox(Handle, PChar('Delete project?' + #13#10), PChar('Confirm'), 36);
if reply = IDYES then
begin
+ tvMain.Deselect(tvMain.Selected);
ProjectList.RemoveProjectById(Project.Id);
+ tvMain.Selected.Data:= nil;
UpdateGUI;
end;
end;
+procedure TfmMain.EditModule(Sender: TObject);
+begin
+ if ShowModuleEditDialog(TORDESYModule(tvMain.Selected.Data)) then
+ UpdateGUI;
+end;
+
procedure TfmMain.EditProject(Sender: TObject);
begin
if ShowProjectEditDialog(TORDESYProject(tvMain.Selected.Data)) then
- begin
UpdateGUI;
- end;
end;
procedure TfmMain.FormClose(Sender: TObject; var Action: TCloseAction);
@@ -192,31 +216,57 @@ procedure TfmMain.InitApp;
procedure TfmMain.ViewProjects(aTreeView: TTreeView);
- function GetBaseItem(const aProjectId, aModuleId, aBaseId: integer): TTreeNode;
+ function BaseInModule(const aProjectId, aModuleId, aBaseId: integer): TTreeNode;
var
- i, ip1, ip2: integer;
+ iP, iM, iB: integer;
Parent1, Parent2: TTreeNode;
begin
Result:= nil;
- for i := 0 to aTreeView.Items.Count - 1 do
+ for iP := 0 to aTreeView.Items.Count - 1 do
begin
- if (TObject(aTreeView.Items[i].Data) is TORDESYProject) and (TORDESYProject(aTreeView.Items[i].Data).Id = aProjectId) then
+ if (TObject(aTreeView.Items[iP].Data) is TORDESYProject) and (TORDESYProject(aTreeView.Items[iP].Data).Id = aProjectId) then
begin
- Parent1:= aTreeView.Items[i];
- for ip1 := 0 to Parent1.Count - 1 do
- if (TObject(Parent1.Item[ip1].Data) is TORDESYModule) and (TORDESYModule(Parent1.Item[ip1].Data).Id = aModuleId) then
+ Parent1:= aTreeView.Items[iP];
+ for iM := 0 to Parent1.Count - 1 do
+ if (TObject(Parent1.Item[iM].Data) is TORDESYModule) and (TORDESYModule(Parent1.Item[iM].Data).Id = aModuleId) then
begin
- Parent2:= Parent1.Item[ip1];
- for ip2 := 0 to Parent2.Count - 1 do
- if (TObject(Parent2.Item[ip2].Data) is TOraBase) and (TOraBase(Parent2.Item[ip2].Data).Id = aBaseId) then
- Result:= Parent2.Item[ip2];
+ Parent2:= Parent1.Item[iM];
+ for iB := 0 to Parent2.Count - 1 do
+ if (TObject(Parent2.Item[iB].Data) is TOraBase) and (TOraBase(Parent2.Item[iB].Data).Id = aBaseId) then
+ Result:= Parent2.Item[iB];
+ end;
+ end;
+ end;
+ end;
+
+ function SchemeInBase(const aProjectId, aModuleId, aBaseId, aSchemeId: integer): TTreeNode;
+ var
+ iP, iM, iB, iSc: integer;
+ Parent1, Parent2, Parent3: TTreeNode;
+ begin
+ Result:= nil;
+ for iP := 0 to aTreeView.Items.Count - 1 do
+ begin
+ if (TObject(aTreeView.Items[iP].Data) is TORDESYProject) and (TORDESYProject(aTreeView.Items[iP].Data).Id = aProjectId) then
+ begin
+ Parent1:= aTreeView.Items[iP];
+ for iM := 0 to Parent1.Count - 1 do
+ if (TObject(Parent1.Item[iM].Data) is TORDESYModule) and (TORDESYModule(Parent1.Item[iM].Data).Id = aModuleId) then
+ begin
+ Parent2:= Parent1.Item[iM];
+ for iB := 0 to Parent2.Count - 1 do
+ if (TObject(Parent2.Item[iB].Data) is TOraBase) and (TOraBase(Parent2.Item[iB].Data).Id = aBaseId) then
+ Parent3:= Parent2.Item[iB];
+ for iSc := 0 to Parent3.Count - 1 do
+ if (TObject(Parent3.Item[iSc].Data) is TOraScheme) and (TOraScheme(Parent3.Item[iSc].Data).Id = aSchemeId) then
+ Result:= Parent3.Item[iSc];
end;
end;
end;
end;
var
- iPL, iM, iB, iSc, Ii: integer;
+ iPL, iM, iB, iSc, iI: integer;
iProject: TORDESYProject;
iModule: TORDESYModule;
iBase: TOraBase;
@@ -224,39 +274,48 @@ procedure TfmMain.ViewProjects(aTreeView: TTreeView);
iItem: TOraItem;
ProjectAdded, ModuleAdded, BaseAdded, SchemeAdded, ItemAdded: TTreeNode;
begin
- if ProjectList.Count <= 0 then
+ aTreeView.Items.Clear;
+ if ProjectList.ProjectCount <= 0 then
Exit;
aTreeView.Items.BeginUpdate;
- aTreeView.Items.Clear;
- for iPL := 0 to ProjectList.Count - 1 do
+ for iPL := 0 to ProjectList.ProjectCount - 1 do
begin
iProject:= ProjectList.GetProjectByIndex(iPL);
- ProjectAdded:= tvMain.Items.AddObject(nil, iProject.Name, iProject);
+ ProjectAdded:= aTreeView.Items.AddObject(nil, iProject.Name, iProject);
for iM := 0 to iProject.ModuleCount - 1 do
begin
iModule:= iProject.GetModuleByIndex(iM);
- ModuleAdded:= tvMain.Items.AddChildObject(ProjectAdded, iModule.Name, iModule);
- for iSc := 0 to iProject.OraSchemeCount - 1 do
+ ModuleAdded:= aTreeView.Items.AddChildObject(ProjectAdded, iModule.Name, iModule);
+ for iI := 0 to iModule.OraItemCount - 1 do
begin
- iScheme:= iProject.GetOraSchemeByIndex(iSc);
- if iScheme.ModuleId = iModule.Id then
+ iItem:= iModule.GetOraItemByIndex(iI);
+ iBase:= ProjectList.GetOraBaseById(iItem.BaseId);
+ iScheme:= ProjectList.GetOraSchemeById(iItem.SchemeId);
+ if iBase <> nil then
begin
- for iB := 0 to iProject.OraBaseCount - 1 do
+ BaseAdded:= BaseInModule(iProject.Id, iModule.Id, iItem.BaseId);
+ if BaseAdded = nil then
+ BaseAdded:= aTreeView.Items.AddChildObject(ModuleAdded, iBase.Name, iBase);
+ if iScheme <> nil then
begin
- iBase:= iProject.GetOraBaseByIndex(iB);
- if iScheme.BaseId = iBase.Id then
- begin
- BaseAdded:= GetBaseItem(iProject.Id, iModule.Id, iBase.Id);
- if not Assigned(BaseAdded) then
- BaseAdded:= tvMain.Items.AddChildObject(ModuleAdded, iBase.Name, iBase);
- SchemeAdded:= tvMain.Items.AddChildObject(BaseAdded, iScheme.Login, iScheme);
- end;
- end;
- for Ii := 0 to iProject.OraItemCount - 1 do
+ SchemeAdded:= SchemeInBase(iProject.Id, iModule.Id, iItem.BaseId, iItem.SchemeId);
+ if SchemeAdded = nil then
+ SchemeAdded:= aTreeView.Items.AddChildObject(BaseAdded, iScheme.Login, iScheme);
+ ItemAdded:= aTreeView.Items.AddChildObject(SchemeAdded, iItem.Name, iItem);
+ end
+ else
begin
- iItem:= iProject.GetOraItemByIndex(Ii);
- ItemAdded:= tvMain.Items.AddChildObject(SchemeAdded, iItem.Name, iItem);
+ // No such scheme in project
+ SchemeAdded:= aTreeView.Items.AddChildObject(BaseAdded, '?', nil);
+ ItemAdded:= aTreeView.Items.AddChildObject(SchemeAdded, iItem.Name, iItem);
end;
+ end
+ else
+ begin
+ // No such base in project
+ BaseAdded:= aTreeView.Items.AddChildObject(ModuleAdded, '?', nil);
+ SchemeAdded:= aTreeView.Items.AddChildObject(BaseAdded, '?', nil);
+ ItemAdded:= aTreeView.Items.AddChildObject(SchemeAdded, iItem.Name, iItem);
end;
end;
end;
@@ -264,12 +323,22 @@ procedure TfmMain.ViewProjects(aTreeView: TTreeView);
aTreeView.Items.EndUpdate;
end;
-procedure TfmMain.miCreateProjectClick(Sender: TObject);
+procedure TfmMain.AddModule(Sender: TObject);
+var
+ iProject: TORDESYProject;
+begin
+ if TObject(tvMain.Selected.Data) is TORDESYProject then
+ iProject:= TORDESYProject(tvMain.Selected.Data)
+ else if TObject(tvMain.Selected.Data) is TORDESYModule then
+ iProject:= TORDESYProject(TORDESYModule((tvMain.Selected.Data)).ProjectRef);
+ if ShowModuleCreateDialog(iProject) then
+ UpdateGUI;
+end;
+
+procedure TfmMain.AddProject(Sender: TObject);
begin
if ShowProjectCreateDialog(AppOptions.UserName, ProjectList) then
- begin
UpdateGUI;
- end;
end;
procedure TfmMain.miExitClick(Sender: TObject);
@@ -290,7 +359,7 @@ procedure TfmMain.miSavechangesClick(Sender: TObject);
ProjectList.SaveToFile();
end;
-procedure TfmMain.AddBase(Sender: TObject);
+(*procedure TfmMain.AddBase(Sender: TObject);
var
BaseName: string;
begin
@@ -318,44 +387,53 @@ procedure TfmMain.AddBase(Sender: TObject);
{$ENDIF}
end;
end;
-end;
+end;*)
-function TfmMain.CanPopup(const aTag: integer; aObject: TObject): boolean;
+function TfmMain.CanPopup(const aTag: integer; aObject: Pointer): boolean;
begin
Result:= false;
if aObject <> nil then
begin
- if (aObject is TORDESYProject) and (aTag >= 1) and (aTag <= 10) then
+ if (TObject(aObject) is TORDESYProject) and (aTag >= 0) and (aTag <= 10) then
Result:= true;
- if (aObject is TORDESYModule) and (aTag >= 11) and (aTag <= 20) then
+ if (TObject(aObject) is TORDESYModule) and (aTag >= 5) and (aTag <= 15) then
Result:= true;
- if (aObject is TOraBase) and (aTag >= 21) and (aTag <= 30) then
+ if (TObject(aObject) is TOraBase) and (aTag >= 10) and (aTag <= 20) then
Result:= true;
- if (aObject is TOraScheme) and (aTag >= 31) and (aTag <= 40) then
+ if (TObject(aObject) is TOraScheme) and (aTag >= 15) and (aTag <= 25) then
Result:= True;
- if (aObject is TOraItem) and (aTag >= 41) and (aTag <= 50) then
+ if (TObject(aObject) is TOraItem) and (aTag >= 20) and (aTag <= 30) then
Result:= true;
- end;
+ end
+ else
+ if aTag = 0 then
+ Result:= True;
end;
procedure TfmMain.ppmMainPopup(Sender: TObject);
var
- i: integer;
+ i, n: integer;
begin
for i := 0 to ppmMain.Items.Count - 1 do
begin
- if Assigned(tvMain.Selected) and (tvMain.Selected.Data <> nil) then
- begin
- if CanPopup(ppmMain.Items[i].Tag , TObject(tvMain.Selected.Data)) then
- ppmMain.Items[i].Visible:= true
+ for n := 0 to ppmMain.Items[i].Count - 1 do
+ if Assigned(tvMain.Selected) then
+ begin
+ ppmMain.Items[i].Visible:= CanPopup(ppmMain.Items[i].Tag , tvMain.Selected.Data);
+ ppmMain.Items[i].Items[n].Visible:= CanPopup(ppmMain.Items[i].Items[n].Tag , tvMain.Selected.Data);
+ end
else
- ppmMain.Items[i].Visible:= false;
- end;
+ begin
+ ppmMain.Items[i].Visible:= CanPopup(ppmMain.Items[i].Tag , nil);
+ ppmMain.Items[i].Items[n].Visible:= CanPopup(ppmMain.Items[i].Items[n].Tag , nil);
+ end;
end;
end;
procedure TfmMain.PrepareGUI;
var
+ ProjectMenu: TMenuItem;
+ ModuleMenu: TMenuItem;
MenuItem: TMenuItem;
begin
try
@@ -364,35 +442,60 @@ procedure TfmMain.PrepareGUI;
fmMain.Width:= strtoint(AppOptions.GetOption('GUI', 'FormWidth'));
fmMain.Height:= strtoint(AppOptions.GetOption('GUI', 'FormHeight'));
// -----------------------------------------Project Popup 1-10
- MenuItem:= TMenuItem.Create(ppmMain);
- MenuItem.OnClick:= miCreateProject.OnClick;
- MenuItem.Caption:= 'Create project';
- MenuItem.Tag:= 1;
- MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
+ ProjectMenu:= TMenuItem.Create(ppmMain);
+ ProjectMenu.Caption:= 'Project';
+ ProjectMenu.Tag:= 0;
+ ppmMain.Items.Add(ProjectMenu);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= AddProject;
+ MenuItem.Caption:= 'Add project';
+ MenuItem.Tag:= 0;
+ ProjectMenu.Add(MenuItem);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= EditProject;
+ MenuItem.Caption:= 'Edit project';
+ MenuItem.Tag:= 1;
+ ProjectMenu.Add(MenuItem);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= DeleteProject;
+ MenuItem.Caption:= 'Delete project';
+ MenuItem.Tag:= 1;
+ ProjectMenu.Add(MenuItem);
//
- MenuItem:= TMenuItem.Create(ppmMain);
- MenuItem.OnClick:= EditProject;
- MenuItem.Caption:= 'Edit project';
- MenuItem.Tag:= 2;
- MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
- //
- MenuItem:= TMenuItem.Create(ppmMain);
- MenuItem.OnClick:= DeleteProject;
- MenuItem.Caption:= 'Delete project';
- MenuItem.Tag:= 3;
- MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
+ ModuleMenu:= TMenuItem.Create(ppmMain);
+ ModuleMenu.Caption:= 'Module';
+ ModuleMenu.Tag:= 5;
+ ppmMain.Items.Add(ModuleMenu);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= AddModule;
+ MenuItem.Caption:= 'Add module';
+ MenuItem.Tag:= 5;
+ ModuleMenu.Add(MenuItem);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= EditModule;
+ MenuItem.Caption:= 'Edit module';
+ MenuItem.Tag:= 11;
+ ModuleMenu.Add(MenuItem);
+ //
+ MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= DeleteModule;
+ MenuItem.Caption:= 'Delete module';
+ MenuItem.Tag:= 11;
+ ModuleMenu.Add(MenuItem);
// -----------------------------------------Module popup 11-20
- MenuItem:= TMenuItem.Create(ppmMain);
- MenuItem.OnClick:= AddBase;
+ {MenuItem:= TMenuItem.Create(ppmMain);
+ MenuItem.OnClick:= AddModule;
MenuItem.Caption:= 'Add base';
MenuItem.Tag:= 11;
MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
+ ppmMain.Items.Add(MenuItem);}
// -----------------------------------------Base popup 21-30
- MenuItem:= TMenuItem.Create(ppmMain);
+ {MenuItem:= TMenuItem.Create(ppmMain);
MenuItem.OnClick:= AddBase;
MenuItem.Caption:= 'Add base';
MenuItem.Tag:= 21;
@@ -411,9 +514,9 @@ procedure TfmMain.PrepareGUI;
MenuItem.Caption:= 'Delete base';
MenuItem.Tag:= 23;
MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
+ ppmMain.Items.Add(MenuItem);}
// -----------------------------------------Scheme popup 31-40
- MenuItem:= TMenuItem.Create(ppmMain);
+ {MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= miCreateProject.OnClick;
MenuItem.Caption:= 'Add scheme';
MenuItem.Tag:= 31;
@@ -439,7 +542,7 @@ procedure TfmMain.PrepareGUI;
MenuItem.Caption:= 'Delete scheme';
MenuItem.Tag:= 34;
MenuItem.Visible:= false;
- ppmMain.Items.Add(MenuItem);
+ ppmMain.Items.Add(MenuItem);}
except
on E: Exception do
begin
@@ -494,22 +597,29 @@ procedure TfmMain.PrepareProjects;
//
//TEST
{iProject:= TORDESYProject.Create(ProjectList.GetFreeProjectId, 'BIG PROJECT');
- //ShowMessage(BoolToStr(Assigned(iProject), true));
iProject.AddModule(TORDESYModule.Create(iProject, iProject.GetFreeModuleId, 'Little Module1', 'DESCRIPTION1'));
iProject.AddModule(TORDESYModule.Create(iProject, iProject.GetFreeModuleId, 'Little Module2', 'DESCRIPTION2'));
iProject.AddModule(TORDESYModule.Create(iProject, iProject.GetFreeModuleId, 'Little Module3', 'DESCRIPTION3'));
- iProject.AddModule(TORDESYModule.Create(iProject, iProject.GetFreeModuleId, 'Little Module4', 'DESCRIPTION4'));
- iProject.AddOraBase(TOraBase.Create(iProject.GetFreeBaseId, 'Some BASE _ 1'));
- iProject.AddOraBase(TOraBase.Create(iProject.GetFreeBaseId, 'Some BASE _ 2'));
- iProject.AddOraScheme(TOraScheme.Create(iProject, iProject.GetFreeSchemeId, 'Scheme of SOME BASE', 'pass', iProject.GetFreeBaseId - 1, iProject.GetFreeModuleId - 1));
- iProject.AddOraItem(TOraItem.Create(iProject.GetFreeItemId, iProject.GetFreeSchemeId - 1, 'PROC_1', 'procedure', OraProcedure));
- iProject.AddOraItem(TOraItem.Create(iProject.GetFreeItemId, iProject.GetFreeSchemeId - 1, 'FUNC_1', 'function', OraFunction));
- iProject.AddOraItem(TOraItem.Create(iProject.GetFreeItemId, iProject.GetFreeSchemeId - 1, 'PACK_1', 'package', OraPackage));
+ iModule:= TORDESYModule.Create(iProject, iProject.GetFreeModuleId, 'Little Module4', 'DESCRIPTION4');
+ iProject.AddModule(iModule);
+
+ ProjectList.AddOraBase(TOraBase.Create(ProjectList ,ProjectList.GetFreeBaseId, 'Some BASE _ 1'));
+ iBase:= TOraBase.Create(ProjectList ,ProjectList.GetFreeBaseId, 'Some BASE _ 2');
+ ProjectList.AddOraBase(iBase);
+ iScheme:= TOraScheme.Create(ProjectList, ProjectList.GetFreeSchemeId, 'Scheme of SOME BASE', 'pass');
+ ProjectList.AddOraScheme(iScheme);
+
+ iModule.AddOraItem(TOraItem.Create(iModule, iModule.GetFreeItemId, iBase.Id, iScheme.Id, 'PROC_1', 'procedure', OraProcedure));
+ iModule.AddOraItem(TOraItem.Create(iModule, iModule.GetFreeItemId, iBase.Id, iScheme.Id, 'FUNC_1', 'function', OraFunction));
+ iModule.AddOraItem(TOraItem.Create(iModule, iModule.GetFreeItemId, iBase.Id, iScheme.Id, 'PACK_1', 'package', OraPackage));
+
ProjectList.AddProject(iProject);}
- //ShowMessage(inttostr(ProjectList.GetProjectByIndex(0).OraBaseCount));
+
+ //ShowMessage(ProjectList.GetProjectByIndex(0).GetModuleByIndex(2).GetOraItemByIndex(2).Name);
+ //ShowMessage(inttostr(ProjectList.GetProjectByIndex(0).GetModuleByIndex(3).OraItemCount));
//END TEST
ViewProjects(tvMain);
- ShowMessage(ProjectList.GetProjectByIndex(0).GetOraItemByIndex(0).Name);
+ //ShowMessage(ProjectList.GetProjectByIndex(0).GetOraItemByIndex(0).Name);
except
on E: Exception do
begin
@@ -530,7 +640,7 @@ procedure TfmMain.splMainMoved(Sender: TObject);
procedure TfmMain.tvMainClick(Sender: TObject);
begin
- if Assigned(tvMain.Selected) then
+ if Assigned(tvMain.Selected) and (tvMain.Selected.Data <> nil) then
if TObject(tvMain.Selected.Data) is TORDESYProject then
begin
edName.Text:= TORDESYProject(tvMain.Selected.Data).Name;
@@ -595,7 +705,9 @@ procedure TfmMain.tvMainGetImageIndex(Sender: TObject; Node: TTreeNode);
if Node.HasChildren and Node.Expanded then
Node.ImageIndex:= 59
else
- Node.ImageIndex:= 58;
+ Node.ImageIndex:= 58
+ else if (Node.Data = nil) and (Node.Text = '?') then
+ Node.ImageIndex:= 0;
except
on E: Exception do
begin
@@ -625,10 +737,13 @@ procedure TfmMain.WMWindowPosChanged(var aMessage: TWMWindowPosChanged);
end;
procedure TfmMain.WrapItem(Sender: TObject);
+var
+ iModule: TORDESYModule;
begin
- with TOraScheme(tvMain.Selected.Data) do
+ iModule:= TORDESYModule(tvMain.Selected.Data);
+ with iModule do
begin
- if ShowWrapDialog(Id, ProjectList.GetProjectById(GetProjectId(ProjectList))) then
+ if ShowWrapDialog(iModule, ProjectList) then
end;
end;
diff --git a/uORDESY.pas b/uORDESY.pas
index b08d782..1ea03d8 100644
--- a/uORDESY.pas
+++ b/uORDESY.pas
@@ -4,9 +4,9 @@ interface
uses
// ORDESY Modules
- {$IFDEF Debug}
+{$IFDEF Debug}
uLog,
- {$ENDIF}
+{$ENDIF}
uExplode, uConnection, uShellFuncs, uHash,
// Delphi Modules
Generics.Collections, SysUtils, Forms, Windows, Classes, Controls;
@@ -36,35 +36,41 @@ TOraItemHead = class
TOraItem = class
private
- FId : integer;
+ FId: integer;
FSchemeId: integer;
+ FBaseId: integer;
FHash: integer;
FType: TOraItemType;
FValid: boolean;
FName: string;
FBody: WideString;
FOnChange: TNotifyEvent;
+ FModuleRef: Pointer;
procedure SetName(const Value: string);
procedure SetType(const Value: TOraItemType);
- procedure SetBody(const Value: widestring);
+ procedure SetBody(const Value: WideString);
procedure SetSchemeId(const Value: integer);
- //FLastChange: TDatetime;
+ procedure SetBaseId(const Value: integer);
public
- constructor Create(const aId, aSchemeId: integer; const aName: string; const aBody: WideString = ''; const aType: TOraItemType = OraProcedure; const aValid: boolean = false);
+ constructor Create(aModuleRef: Pointer; const aId, aBaseId,
+ aSchemeId: integer; const aName: string; const aBody: WideString = '';
+ const aType: TOraItemType = OraProcedure; const aValid: boolean = false);
class function GetItemSqlType(const aType: TOraItemType): string;
class function GetItemType(const aType: string): TOraItemType;
- procedure UpdateStatus(var aProject: TORDESYProject);
- {function Wrap(var aProject: TORDESYProject):boolean;
- function Deploy(var aProject: TORDESYProject): boolean;
- function SaveToProject(var aProject: TORDESYProject): boolean;}
+ procedure UpdateStatus;
+ { function Wrap(var aProject: TORDESYProject):boolean;
+ function Deploy(var aProject: TORDESYProject): boolean;
+ function SaveToProject(var aProject: TORDESYProject): boolean; }
property Id: integer read FId;
property Name: string read FName write SetName;
property ItemType: TOraItemType read FType write SetType;
property Valid: boolean read FValid;
- property ItemBody: widestring read FBody write SetBody;
+ property ItemBody: WideString read FBody write SetBody;
property SchemeId: integer read FSchemeId write SetSchemeId;
+ property BaseId: integer read FBaseId write SetBaseId;
property Hash: integer read FHash;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
+ property ModuleRef: Pointer read FModuleRef;
end;
TOraBase = class
@@ -72,46 +78,43 @@ TOraBase = class
FId: integer;
FName: string;
FOnChange: TNotifyEvent;
+ FProjectListRef: Pointer;
procedure SetName(const Value: string);
public
- constructor Create(const aId: integer; const aName: string);
+ constructor Create(aProjectListRef: Pointer; const aId: integer;
+ const aName: string);
property Id: integer read FId;
property Name: string read FName write SetName;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
+ property ProjectListRef: Pointer read FProjectListRef;
end;
TOraScheme = class
private
FId: integer;
- FBaseId: integer;
- FModuleId: integer;
FLogin: string;
FPass: string;
FConnection: TConnection;
FConnected: boolean;
FItemList: array of TOraItemHead;
FOnChange: TNotifyEvent;
- FProjectRef: Pointer;
- procedure SetBaseId(const Value: integer);
+ FProjectListRef: Pointer;
procedure SetLogin(const Value: string);
- procedure SetModuleId(const Value: integer);
procedure SetPass(const Value: string);
public
- constructor Create(aProjectRef: Pointer; const aId: integer; const aLogin, aPass: string; const aBaseId, aModuleId: integer);
+ constructor Create(aProjectListRef: Pointer; const aId: integer;
+ const aLogin, aPass: string);
destructor Destroy; override;
- procedure Connect(var aProject: TORDESYProject);
+ procedure Connect(const BaseId: integer);
procedure Disconnect;
procedure GetItemList(const aItemType: TOraItemType; aList: TStrings);
- function GetProjectId(var aProjectList: TORDESYProjectList): integer;
property Id: integer read FId;
- property ModuleId: integer read FModuleId write SetModuleId;
- property BaseId: integer read FBaseId write SetBaseId;
property Login: string read FLogin write SetLogin;
property Pass: string read FPass write SetPass;
property Connection: TConnection read FConnection write FConnection;
property Connected: boolean read FConnected;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
- property ProjectRef: Pointer read FProjectRef;
+ property ProjectListRef: Pointer read FProjectListRef;
end;
TORDESYModule = class
@@ -119,17 +122,29 @@ TORDESYModule = class
FId: integer;
FName: string;
FDescription: WideString;
+ FOraItems: array of TOraItem;
FOnChange: TNotifyEvent;
FProjectRef: Pointer;
- procedure SetDescription(const Value: widestring);
+ function GetOraItemCount: integer;
+ procedure SetDescription(const Value: WideString);
procedure SetName(const Value: string);
public
- constructor Create(aProjectRef: Pointer; const aId: integer; const aName: string = 'New Module'; const aDescription: WideString = '');
+ constructor Create(aProjectRef: Pointer; const aId: integer;
+ const aName: string = 'New Module'; const aDescription: WideString = '');
+ destructor Destroy; override;
+ // Item
+ function GetFreeItemId: integer;
+ procedure AddOraItem(aItem: TOraItem);
+ function GetOraItemById(const aId: integer): TOraItem;
+ function GetOraItemByIndex(const aIndex: integer): TOraItem;
+ function GetOraItemName(const aIndex: integer): string;
+ //
property Id: integer read FId;
property Name: string read FName write SetName;
- property Description: widestring read FDescription write SetDescription;
+ property Description: WideString read FDescription write SetDescription;
+ property OraItemCount: integer read GetOraItemCount;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
- property ProjectRef: Pointer read FProjectRef write FProjectRef;
+ property ProjectRef: Pointer read FProjectRef;
end;
TORDESYProject = class
@@ -140,46 +155,27 @@ TORDESYProject = class
FCreator: string;
FDateCreate: TDateTime;
FORDESYModules: array of TORDESYModule;
- FOraBases: array of TOraBase;
- FOraSchemes: array of TOraScheme;
- FOraItems: array of TOraItem;
FOnChange: TNotifyEvent;
- function GetOraItemCount: integer;
+ FProjectListRef: Pointer;
function GetModuleCount: integer;
- function GetOraBaseCount: integer;
- function GetOraSchemeCount: integer;
procedure SetName(const Value: string);
procedure SetCreator(const Value: string);
procedure SetDescription(const Value: string);
public
- constructor Create(const aId: integer; const aName: string = 'New Project'; const aDescription: string = 'About new project...'; const aCreator: string = 'nobody'; const aDateCreate: TDateTime = 0);
+ constructor Create(const aId: integer; const aName: string = 'New Project';
+ const aDescription: string = 'About new project...';
+ const aCreator: string = 'nobody'; const aDateCreate: TDateTime = 0);
destructor Destroy; override;
- function GetFreeModuleId: integer;
- function GetFreeBaseId: integer;
- function GetFreeSchemeId: integer;
- function GetFreeItemId: integer;
- // Item
- procedure AddOraItem(aItem: TOraItem);
- function GetOraItemById(const aId: integer): TOraItem;
- function GetOraItemByIndex(const aIndex: integer): TOraItem;
- function GetOraItemName(const aIndex: integer): string;
- // Base
- procedure AddOraBase(aBase: TOraBase);
- function GetOraBaseById(const aId: integer): TOraBase;
- function GetOraBaseByIndex(const aIndex: integer): TOraBase;
- function GetOraBaseName(const aIndex: integer): string;
- // Scheme
- procedure AddOraScheme(aScheme: TOraScheme);
- function GetOraSchemeById(const aId: integer): TOraScheme;
- function GetOraSchemeByIndex(const aIndex: integer): TOraScheme;
- function GetOraSchemeLogin(const aIndex: integer): string;
// Module
+ function GetFreeModuleId: integer;
procedure AddModule(aModule: TORDESYModule);
function GetModuleById(const aId: integer): TORDESYModule;
function GetModuleByIndex(const aIndex: integer): TORDESYModule;
function GetModuleName(const aIndex: integer): string;
+ function RemoveModuleById(const aId: integer): boolean;
// WRAP DEPLOY!
- procedure WrapItem(const aSchemeId: integer; const aName: string; const aType: TOraItemType);
+ procedure WrapItem(const aModuleId, aBaseId, aSchemeId: integer;
+ const aName: string; const aType: TOraItemType);
procedure DeployItem(const aItemId: integer);
property Id: integer read FId;
@@ -189,54 +185,78 @@ TORDESYProject = class
property DateCreate: TDateTime read FDateCreate;
//
property ModuleCount: integer read GetModuleCount;
- property OraBaseCount: integer read GetOraBaseCount;
- property OraSchemeCount: integer read GetOraSchemeCount;
- property OraItemCount: integer read GetOraItemCount;
//
property OnChange: TNotifyEvent read FOnChange write FOnChange;
+ property ProjectListRef: Pointer read FProjectListRef;
end;
TORDESYProjectList = class
private
FProjects: array of TORDESYProject;
+ FOraBases: array of TOraBase;
+ FOraSchemes: array of TOraScheme;
FSaved: boolean;
FOnProjectAdd: TNotifyEvent;
FOnProjectRemove: TNotifyEvent;
+ FOnChange: TNotifyEvent;
procedure Clear;
function GetProjectsCount: integer;
- procedure OnChange(Sender: TObject);
+ function GetOraBaseCount: integer;
+ function GetOraSchemeCount: integer;
+ procedure OnProjectListChange(Sender: TObject);
public
constructor Create;
destructor Destroy; override;
procedure AddProject(aProject: TORDESYProject);
- procedure RemoveProjectById(const aId: integer);
+ function RemoveProjectById(const aId: integer): boolean;
+ // Base
+ procedure AddOraBase(aBase: TOraBase);
+ function GetOraBaseById(const aId: integer): TOraBase;
+ function GetOraBaseByIndex(const aIndex: integer): TOraBase;
+ function GetOraBaseName(const aIndex: integer): string;
+ // Scheme
+ procedure AddOraScheme(aScheme: TOraScheme);
+ function GetOraSchemeById(const aId: integer): TOraScheme;
+ function GetOraSchemeByIndex(const aIndex: integer): TOraScheme;
+ function GetOraSchemeLogin(const aIndex: integer): string;
+ //
function GetFreeProjectId: integer;
+ function GetFreeBaseId: integer;
+ function GetFreeSchemeId: integer;
function GetProjectByIndex(const aIndex: integer): TORDESYProject;
function GetProjectById(const aId: integer): TORDESYProject;
function LoadFromFile(const aFileName: string = 'ORDESY.data'): boolean;
function SaveToFile(const aFileName: string = 'ORDESY.data'): boolean;
- property Count: integer read GetProjectsCount;
+ property ProjectCount: integer read GetProjectsCount;
property Saved: boolean read FSaved;
published
property OnProjectAdd: TNotifyEvent read FOnProjectAdd write FOnProjectAdd;
- property OnProjectRemove: TNotifyEvent read FOnProjectRemove write FOnProjectRemove;
+ property OnProjectRemove
+ : TNotifyEvent read FOnProjectRemove write FOnProjectRemove;
+ property OnChange: TNotifyEvent read FOnChange write FOnChange;
+ property OraBaseCount: integer read GetOraBaseCount;
+ property OraSchemeCount: integer read GetOraSchemeCount;
end;
implementation
{ TDBItem }
-constructor TOraItem.Create(const aId, aSchemeId: integer; const aName: string; const aBody: WideString = ''; const aType: TOraItemType = OraProcedure; const aValid: boolean = false);
+constructor TOraItem.Create(aModuleRef: Pointer; const aId, aBaseId,
+ aSchemeId: integer; const aName: string; const aBody: WideString = '';
+ const aType: TOraItemType = OraProcedure; const aValid: boolean = false);
begin
inherited Create;
- FId:= aId;
- FType:= aType;
- FValid:= aValid;
- FName:= aName;
- FBody:= aBody;
- //FHash:= GetSimpleHash(PChar(FBody));
- FHash:= MurmurHash2(PAnsiChar(FBody));
- FSchemeId:= aSchemeId;
+ FId := aId;
+ FType := aType;
+ FValid := aValid;
+ FName := aName;
+ FBody := aBody;
+ // FHash:= GetSimpleHash(PChar(FBody));
+ FHash := MurmurHash2(PAnsiChar(FBody));
+ FSchemeId := aSchemeId;
+ FBaseId := aBaseId;
+ FModuleRef := aModuleRef;
end;
{ TORDESYProject }
@@ -251,12 +271,12 @@ procedure TORDESYProject.AddModule(aModule: TORDESYModule);
Exit;
end;
SetLength(FORDESYModules, length(FORDESYModules) + 1);
- FORDESYModules[high(FORDESYModules)]:= aModule;
+ FORDESYModules[ high(FORDESYModules)] := aModule;
if Assigned(FOnChange) then
OnChange(Self);
end;
-procedure TORDESYProject.AddOraBase(aBase: TOraBase);
+procedure TORDESYProjectList.AddOraBase(aBase: TOraBase);
var
i: integer;
begin
@@ -266,12 +286,12 @@ procedure TORDESYProject.AddOraBase(aBase: TOraBase);
Exit;
end;
SetLength(FOraBases, length(FOraBases) + 1);
- FOraBases[high(FOraBases)]:= aBase;
+ FOraBases[ high(FOraBases)] := aBase;
if Assigned(FOnChange) then
OnChange(Self);
end;
-procedure TORDESYProject.AddOraItem(aItem: TOraItem);
+procedure TORDESYModule.AddOraItem(aItem: TOraItem);
var
i: integer;
begin
@@ -281,12 +301,12 @@ procedure TORDESYProject.AddOraItem(aItem: TOraItem);
Exit;
end;
SetLength(FOraItems, length(FOraItems) + 1);
- FOraItems[high(FOraItems)]:= aItem;
+ FOraItems[ high(FOraItems)] := aItem;
if Assigned(FOnChange) then
OnChange(Self);
end;
-procedure TORDESYProject.AddOraScheme(aScheme: TOraScheme);
+procedure TORDESYProjectList.AddOraScheme(aScheme: TOraScheme);
var
i: integer;
begin
@@ -296,22 +316,24 @@ procedure TORDESYProject.AddOraScheme(aScheme: TOraScheme);
Exit;
end;
SetLength(FOraSchemes, length(FOraSchemes) + 1);
- FOraSchemes[high(FOraSchemes)]:= aScheme;
+ FOraSchemes[ high(FOraSchemes)] := aScheme;
if Assigned(FOnChange) then
OnChange(Self);
end;
-constructor TORDESYProject.Create(const aId: integer; const aName: string; const aDescription: string; const aCreator: string; const aDateCreate: TDateTime);
+constructor TORDESYProject.Create(const aId: integer; const aName: string;
+ const aDescription: string; const aCreator: string;
+ const aDateCreate: TDateTime);
begin
inherited Create;
- FId:= aId;
- FName:= aName;
- FDescription:= aDescription;
- FCreator:= aCreator;
+ FId := aId;
+ FName := aName;
+ FDescription := aDescription;
+ FCreator := aCreator;
if aDateCreate = 0 then
- FDateCreate:= Date + Time
+ FDateCreate := Date + Time
else
- FDateCreate:= aDateCreate;
+ FDateCreate := aDateCreate;
end;
procedure TORDESYProject.DeployItem(const aItemId: integer);
@@ -323,17 +345,6 @@ destructor TORDESYProject.Destroy;
var
i: integer;
begin
- for i := 0 to high(FOraItems) do
- FOraItems[i].Free;
- SetLength(FOraItems, 0);
-
- for i := 0 to high(FOraSchemes) do
- FOraSchemes[i].Free;
- SetLength(FOraSchemes, 0);
-
- for i := 0 to high(FOraBases) do
- FOraBases[i].Free;
- SetLength(FOraBases, 0);
for i := 0 to high(FORDESYModules) do
FORDESYModules[i].Free;
@@ -342,14 +353,13 @@ destructor TORDESYProject.Destroy;
inherited Destroy;
end;
-function TORDESYProject.GetFreeBaseId: integer;
+function TORDESYProjectList.GetFreeBaseId: integer;
var
i, NewId: integer;
-label
- Restart;
+label Restart;
begin
- NewId:= 0;
- Restart:
+ NewId := 0;
+Restart :
for i := 0 to high(FOraBases) do
begin
if FOraBases[i].Id = NewId then
@@ -358,17 +368,16 @@ function TORDESYProject.GetFreeBaseId: integer;
goto Restart;
end;
end;
- Result:= NewId;
+ Result := NewId;
end;
-function TORDESYProject.GetFreeItemId: integer;
+function TORDESYModule.GetFreeItemId: integer;
var
i, NewId: integer;
-label
- Restart;
+label Restart;
begin
- NewId:= 0;
- Restart:
+ NewId := 0;
+Restart :
for i := 0 to high(FOraItems) do
begin
if FOraItems[i].Id = NewId then
@@ -377,17 +386,16 @@ function TORDESYProject.GetFreeItemId: integer;
goto Restart;
end;
end;
- Result:= NewId;
+ Result := NewId;
end;
function TORDESYProject.GetFreeModuleId: integer;
var
i, NewId: integer;
-label
- Restart;
+label Restart;
begin
- NewId:= 0;
- Restart:
+ NewId := 0;
+Restart :
for i := 0 to high(FORDESYModules) do
begin
if FORDESYModules[i].Id = NewId then
@@ -396,17 +404,16 @@ function TORDESYProject.GetFreeModuleId: integer;
goto Restart;
end;
end;
- Result:= NewId;
+ Result := NewId;
end;
-function TORDESYProject.GetFreeSchemeId: integer;
+function TORDESYProjectList.GetFreeSchemeId: integer;
var
i, NewId: integer;
-label
- Restart;
+label Restart;
begin
- NewId:= 0;
- Restart:
+ NewId := 0;
+Restart :
for i := 0 to high(FOraSchemes) do
begin
if FOraSchemes[i].Id = NewId then
@@ -415,49 +422,79 @@ function TORDESYProject.GetFreeSchemeId: integer;
goto Restart;
end;
end;
- Result:= NewId;
+ Result := NewId;
end;
function TORDESYProject.GetModuleById(const aId: integer): TORDESYModule;
var
i: integer;
begin
+ Result := nil;
for i := 0 to high(FORDESYModules) do
begin
if FORDESYModules[i].FId = aId then
begin
- Result:= FORDESYModules[i];
+ Result := FORDESYModules[i];
Exit;
end;
end;
- Result:= nil;
end;
function TORDESYProject.GetModuleByIndex(const aIndex: integer): TORDESYModule;
begin
- Result:= nil;
- if (aIndex >= 0) and (aIndex<= high(FORDESYModules)) then
- Result:= FORDESYModules[aIndex]
+ Result := nil;
+ if (aIndex >= 0) and (aIndex <= high(FORDESYModules)) then
+ Result := FORDESYModules[aIndex]
else
- raise Exception.Create('Incorrect module index. Max value is: ' + IntToStr(high(FORDESYModules)));
+ raise Exception.Create('Incorrect module index. Max value is: ' + IntToStr
+ ( high(FORDESYModules)));
end;
function TORDESYProject.GetModuleCount: integer;
begin
- Result:= length(FORDESYModules);
+ Result := length(FORDESYModules);
end;
function TORDESYProject.GetModuleName(const aIndex: integer): string;
var
i: integer;
begin
- Result:= 'NULL';
+ Result := '';
for i := 0 to high(FORDESYModules) do
if FORDESYModules[i].FId = aIndex then
- Result:= FORDESYModules[i].Name;
+ Result := FORDESYModules[i].Name;
+end;
+
+function TORDESYProject.RemoveModuleById(const aId: integer): boolean;
+begin
+ Result := false;
+ try
+ if GetModuleById(aId) <> nil then
+ begin
+ FORDESYModules[aId].Free;
+ FORDESYModules[aId] := FORDESYModules[High(FORDESYModules)];
+ SetLength(FORDESYModules, length(FORDESYModules) - 1);
+ if Assigned(FOnChange) then
+ OnChange(Self);
+ Result:= true;
+ end;
+ except
+ on E: Exception do
+ begin
+{$IFDEF Debug}
+ AddToLog(ClassName + ' | RemoveModuleById | ' + E.Message);
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | RemoveModuleById | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
+ end;
+ end;
end;
-function TORDESYProject.GetOraBaseById(const aId: integer): TOraBase;
+function TORDESYProjectList.GetOraBaseById(const aId: integer): TOraBase;
var
i: integer;
begin
@@ -465,38 +502,39 @@ function TORDESYProject.GetOraBaseById(const aId: integer): TOraBase;
begin
if FOraBases[i].FId = aId then
begin
- Result:= FOraBases[i];
+ Result := FOraBases[i];
Exit;
end;
end;
- Result:= nil;
+ Result := nil;
end;
-function TORDESYProject.GetOraBaseByIndex(const aIndex: integer): TOraBase;
+function TORDESYProjectList.GetOraBaseByIndex(const aIndex: integer): TOraBase;
begin
- Result:= nil;
+ Result := nil;
if (aIndex >= 0) and (aIndex <= high(FOraBases)) then
- Result:= FOraBases[aIndex]
+ Result := FOraBases[aIndex]
else
- raise Exception.Create('Incorrect base index. Max value is: ' + IntToStr(high(FOraBases)));
+ raise Exception.Create('Incorrect base index. Max value is: ' + IntToStr
+ ( high(FOraBases)));
end;
-function TORDESYProject.GetOraBaseCount: integer;
+function TORDESYProjectList.GetOraBaseCount: integer;
begin
- Result:= Length(FOraBases);
+ Result := length(FOraBases);
end;
-function TORDESYProject.GetOraBaseName(const aIndex: integer): string;
+function TORDESYProjectList.GetOraBaseName(const aIndex: integer): string;
var
i: integer;
begin
- Result:= 'NULL';
+ Result := '';
for i := 0 to high(FOraBases) do
if FOraBases[i].FId = aIndex then
- Result:= FOraBases[i].Name;
+ Result := FOraBases[i].Name;
end;
-function TORDESYProject.GetOraItemById(const aId: integer): TOraItem;
+function TORDESYModule.GetOraItemById(const aId: integer): TOraItem;
var
i: integer;
begin
@@ -504,38 +542,39 @@ function TORDESYProject.GetOraItemById(const aId: integer): TOraItem;
begin
if FOraItems[i].FId = aId then
begin
- Result:= FOraItems[i];
+ Result := FOraItems[i];
Exit;
end;
end;
- Result:= nil;
+ Result := nil;
end;
-function TORDESYProject.GetOraItemByIndex(const aIndex: integer): TOraItem;
+function TORDESYModule.GetOraItemByIndex(const aIndex: integer): TOraItem;
begin
- Result:= nil;
- if (aIndex >= 0) and (aIndex<= high(FOraItems)) then
- Result:= FOraItems[aIndex]
+ Result := nil;
+ if (aIndex >= 0) and (aIndex <= high(FOraItems)) then
+ Result := FOraItems[aIndex]
else
- raise Exception.Create('Incorrect item index. Max value is: ' + IntToStr(high(FOraItems)));
+ raise Exception.Create('Incorrect item index. Max value is: ' + IntToStr
+ ( high(FOraItems)));
end;
-function TORDESYProject.GetOraItemCount: integer;
+function TORDESYModule.GetOraItemCount: integer;
begin
- Result:= length(FOraItems);
+ Result := length(FOraItems);
end;
-function TORDESYProject.GetOraItemName(const aIndex: integer): string;
+function TORDESYModule.GetOraItemName(const aIndex: integer): string;
var
i: integer;
begin
- Result:= 'NULL';
+ Result := '';
for i := 0 to high(FOraItems) do
if FOraItems[i].FId = aIndex then
- Result:= FOraItems[i].Name;
+ Result := FOraItems[i].Name;
end;
-function TORDESYProject.GetOraSchemeById(const aId: integer): TOraScheme;
+function TORDESYProjectList.GetOraSchemeById(const aId: integer): TOraScheme;
var
i: integer;
begin
@@ -543,35 +582,37 @@ function TORDESYProject.GetOraSchemeById(const aId: integer): TOraScheme;
begin
if FOraSchemes[i].FId = aId then
begin
- Result:= FOraSchemes[i];
+ Result := FOraSchemes[i];
Exit;
end;
end;
- Result:= nil;
+ Result := nil;
end;
-function TORDESYProject.GetOraSchemeByIndex(const aIndex: integer): TOraScheme;
+function TORDESYProjectList.GetOraSchemeByIndex(const aIndex: integer)
+ : TOraScheme;
begin
- Result:= nil;
- if (aIndex >= 0) and (aIndex<= high(FOraSchemes)) then
- Result:= FOraSchemes[aIndex]
+ Result := nil;
+ if (aIndex >= 0) and (aIndex <= high(FOraSchemes)) then
+ Result := FOraSchemes[aIndex]
else
- raise Exception.Create('Incorrect scheme index. Max value is: ' + IntToStr(high(FOraSchemes)));
+ raise Exception.Create('Incorrect scheme index. Max value is: ' + IntToStr
+ ( high(FOraSchemes)));
end;
-function TORDESYProject.GetOraSchemeCount: integer;
+function TORDESYProjectList.GetOraSchemeCount: integer;
begin
- Result:= Length(FOraSchemes);
+ Result := length(FOraSchemes);
end;
-function TORDESYProject.GetOraSchemeLogin(const aIndex: integer): string;
+function TORDESYProjectList.GetOraSchemeLogin(const aIndex: integer): string;
var
i: integer;
begin
- Result:= 'NULL';
+ Result := '';
for i := 0 to high(FOraSchemes) do
if FOraSchemes[i].FId = aIndex then
- Result:= FOraSchemes[i].Login;
+ Result := FOraSchemes[i].Login;
end;
procedure TORDESYProject.SetCreator(const Value: string);
@@ -595,92 +636,103 @@ procedure TORDESYProject.SetName(const Value: string);
OnChange(Self);
end;
-procedure TORDESYProject.WrapItem(const aSchemeId: integer; const aName: string;
- const aType: TOraItemType);
+procedure TORDESYProject.WrapItem(const aModuleId, aBaseId, aSchemeId: integer;
+ const aName: string; const aType: TOraItemType);
var
iModule: TORDESYModule;
iBase: TOraBase;
iScheme: TOraScheme;
iItem: TOraItem;
firstItem: boolean;
+ ItemBody: WideString;
begin
try
- iScheme:= GetOraSchemeById(aSchemeId);
- iModule:= GetModuleById(iScheme.ModuleId);
- iBase:= GetOraBaseById(iScheme.BaseId);
- if (not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase)) then
+ iScheme := TORDESYProjectList(FProjectListRef).GetOraSchemeById(aSchemeId);
+ iModule := GetModuleById(aModuleId);
+ iBase := TORDESYProjectList(FProjectListRef).GetOraBaseById(aBaseId);
+ if (not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase))
+ then
raise Exception.Create('Some of objects not created!');
if not iScheme.Connected then
- iScheme.Connect(Self);
+ iScheme.Connect(aBaseId);
with iScheme.Connection do
begin
- Query.Active:= false;
- Query.SQL.Text:= 'select text from sys.all_sources where ' +
- 'owner = ''' + iScheme.Login + '''' +
- 'name = ''' + Name + '''' +
- 'type = ''' + TOraItem.GetItemSqlType(aType) + ''' ' +
- 'order by line';
- Query.Active:= true;
- firstItem:= true;
- iItem:= TOraItem.Create(GetFreeItemId ,aSchemeId, aName, '', aType);
+ Query.Active := false;
+ Query.SQL.Text :=
+ 'select text from sys.all_sources where ' + 'owner = ''' +
+ iScheme.Login + '''' + 'name = ''' + Name + '''' + 'type = ''' +
+ TOraItem.GetItemSqlType(aType) + ''' ' + 'order by line';
+ Query.Active := true;
+ firstItem := true;
while not Query.Eof do
begin
if firstItem then
- iItem.ItemBody:= iItem.ItemBody + 'CREATE OR REPLACE ' + Query.Fields[0].AsString + #13#10;
- iItem.ItemBody:= iItem.ItemBody + Query.Fields[0].AsString + #13#10;
- firstItem:= false;
+ ItemBody := ItemBody + 'CREATE OR REPLACE ' + Query.Fields[0]
+ .AsString + #13#10;
+ ItemBody := ItemBody + Query.Fields[0].AsString + #13#10;
+ firstItem := false;
end;
- AddOraItem(iItem);
+ iItem := TOraItem.Create(iModule, iModule.GetFreeItemId, aBaseId,
+ aSchemeId, aName, ItemBody, aType);
+ iModule.AddOraItem(iItem);
end;
except
on E: Exception do
- begin
- {$IFDEF Debug}
+ begin
+{$IFDEF Debug}
AddToLog(ClassName + ' | WrapItem | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | WrapItem | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | WrapItem | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
end;
end;
end;
{ TOraScheme }
-procedure TOraScheme.Connect(var aProject: TORDESYProject);
+procedure TOraScheme.Connect(const BaseId: integer);
begin
try
- if not FConnected then
+ if not Connected then
begin
if not Assigned(FConnection) then
- FConnection:= TConnection.Create(aProject.GetOraBaseName(FBaseId), FLogin, FPass, connstrORA);
+ FConnection := TConnection.Create(TORDESYProjectList(FProjectListRef)
+ .GetOraBaseName(BaseId), FLogin, FPass, connstrORA);
FConnection.Connect;
- FConnected:= FConnection.Connected;
+ FConnected := FConnection.Connected;
+ if FConnection.LastError <> '' then
+ raise Exception.Create(FConnection.LastError);
end;
except
on E: Exception do
begin
- FConnected:= false;
- {$IFDEF Debug}
- AddToLog(E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
+ FConnected := false;
+{$IFDEF Debug}
+ AddToLog(ClassName + ' | Connect | ' + E.Message);
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | Connect | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
end;
end;
end;
-constructor TOraScheme.Create(aProjectRef: Pointer; const aId: integer; const aLogin, aPass: string; const aBaseId, aModuleId: integer);
+constructor TOraScheme.Create(aProjectListRef: Pointer; const aId: integer;
+ const aLogin, aPass: string);
begin
inherited Create;
- FId:= aId;
- FLogin:= aLogin;
- FPass:= aPass;
- FBaseId:= aBaseId;
- FModuleId:= aModuleId;
- FConnected:= false;
- FProjectRef:= aProjectRef;
+ FId := aId;
+ FLogin := aLogin;
+ FPass := aPass;
+ FConnected := false;
+ FProjectListRef := aProjectListRef;
end;
destructor TOraScheme.Destroy;
@@ -702,10 +754,11 @@ procedure TOraScheme.Disconnect;
begin
if Assigned(FConnection) and (FConnected) then
FConnection.Disconnect;
- FConnected:= FConnection.Connected;
+ FConnected := FConnection.Connected;
end;
-procedure TOraScheme.GetItemList(const aItemType: TOraItemType; aList: TStrings);
+procedure TOraScheme.GetItemList(const aItemType: TOraItemType;
+ aList: TStrings);
begin
try
SetLength(FItemList, 0);
@@ -717,63 +770,43 @@ procedure TOraScheme.GetItemList(const aItemType: TOraItemType; aList: TStrings)
begin
aList.BeginUpdate;
aList.Clear;
- Active:= false;
- SQL.Text:= 'select object_name, status from sys.all_objects where owner = user and subobject_name is null and object_name not like ''BIN$%'' and object_type = ''' + TOraItem.GetItemSqlType(aItemType) + '''';
- Active:= true;
+ Active := false;
+ SQL.Text :=
+ 'select object_name, status from sys.all_objects where owner = user and subobject_name is null and object_name not like ''BIN$%'' and object_type = ''' + TOraItem.GetItemSqlType(aItemType) + '''';
+ Active := true;
if RecordCount = 0 then
raise Exception.Create('Error while getting items list.');
while not Eof do
begin
SetLength(FItemList, length(FItemList) + 1);
- FItemList[High(FItemList)] := TOraItemHead.Create;
- FItemList[High(FItemList)].Name:= Fields[0].AsString;
+ FItemList[ High(FItemList)] := TOraItemHead.Create;
+ FItemList[ High(FItemList)].Name := Fields[0].AsString;
if Fields[1].AsString = 'VALID' then
- FItemList[High(FItemList)].Valid:= true
+ FItemList[ High(FItemList)].Valid := true
else
- FItemList[High(FItemList)].Valid:= false;
- FItemList[High(FItemList)].ItemType:= aItemType;
- aList.AddObject(FItemList[High(FItemList)].Name, FItemList[High(FItemList)]);
+ FItemList[ High(FItemList)].Valid := false;
+ FItemList[ High(FItemList)].ItemType := aItemType;
+ aList.AddObject(FItemList[ High(FItemList)].Name,
+ FItemList[ High(FItemList)]);
end;
aList.EndUpdate;
end;
except
on E: Exception do
begin
- {$IFDEF Debug}
+{$IFDEF Debug}
AddToLog(ClassName + ' | GetItemList | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | GetItemList | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
- end;
- end;
-end;
-
-function TOraScheme.GetProjectId(var aProjectList: TORDESYProjectList): integer;
-var
- i, n: integer;
-begin
- Result:= 0;
- for i := 0 to aProjectList.Count - 1 do
- begin
- with aProjectList.GetProjectByIndex(i) do
- begin
- for n := 0 to OraSchemeCount - 1 do
- begin
- if GetOraSchemeByIndex(n) = Self then
- Result:= i;
- end;
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | GetItemList | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
end;
end;
end;
-procedure TOraScheme.SetBaseId(const Value: integer);
-begin
- FBaseId := Value;
- if Assigned(FOnChange) then
- OnChange(Self);
-end;
-
procedure TOraScheme.SetLogin(const Value: string);
begin
FLogin := Value;
@@ -781,13 +814,6 @@ procedure TOraScheme.SetLogin(const Value: string);
OnChange(Self);
end;
-procedure TOraScheme.SetModuleId(const Value: integer);
-begin
- FModuleId := Value;
- if Assigned(FOnChange) then
- OnChange(Self);
-end;
-
procedure TOraScheme.SetPass(const Value: string);
begin
FPass := Value;
@@ -797,42 +823,48 @@ procedure TOraScheme.SetPass(const Value: string);
{ TOraBase }
-constructor TOraBase.Create(const aId: integer; const aName: string);
+constructor TOraBase.Create(aProjectListRef: Pointer; const aId: integer;
+ const aName: string);
begin
inherited Create;
- FId:= aId;
- FName:= aName;
+ FId := aId;
+ FName := aName;
+ FProjectListRef := aProjectListRef;
end;
-(*function TOraItem.Deploy(var aProject: TORDESYProject): boolean;
-begin
+(* function TOraItem.Deploy(var aProject: TORDESYProject): boolean;
+ begin
-end;*)
+ end; *)
class function TOraItem.GetItemSqlType(const aType: TOraItemType): string;
begin
case aType of
- OraProcedure: Result:= 'PROCEDURE';
- OraFunction: Result:= 'FUNCTION';
- OraPackage: Result:= 'PACKAGE'
- else Result:= 'PROCEDURE';
+ OraProcedure:
+ Result := 'PROCEDURE';
+ OraFunction:
+ Result := 'FUNCTION';
+ OraPackage:
+ Result := 'PACKAGE'
+ else
+ Result := 'PROCEDURE';
end;
end;
class function TOraItem.GetItemType(const aType: string): TOraItemType;
begin
- Result:= OraProcedure;
+ Result := OraProcedure;
if aType = 'FUNCTION' then
- Result:= OraFunction
+ Result := OraFunction
else if aType = 'PACKAGE' then
- Result:= OraPackage;
+ Result := OraPackage;
end;
-procedure TOraItem.SetBody(const Value: widestring);
+procedure TOraItem.SetBody(const Value: WideString);
begin
FBody := Value;
- //FHash:= GetSimpleHash(PChar(FBody));
- FHash:= MurmurHash2(PAnsiChar(FBody));
+ // FHash:= GetSimpleHash(PChar(FBody));
+ FHash := MurmurHash2(PAnsiChar(FBody));
OnChange(Self);
end;
@@ -850,6 +882,13 @@ procedure TOraItem.SetSchemeId(const Value: integer);
OnChange(Self);
end;
+procedure TOraItem.SetBaseId(const Value: integer);
+begin
+ FBaseId := Value;
+ if Assigned(FOnChange) then
+ OnChange(Self);
+end;
+
procedure TOraItem.SetType(const Value: TOraItemType);
begin
FType := Value;
@@ -857,32 +896,38 @@ procedure TOraItem.SetType(const Value: TOraItemType);
OnChange(Self);
end;
-procedure TOraItem.UpdateStatus(var aProject: TORDESYProject);
+procedure TOraItem.UpdateStatus;
var
iScheme: TOraScheme;
begin
try
try
Screen.Cursor := crSQLWait;
- iScheme:= aProject.GetOraSchemeById(SchemeId);
+ iScheme := TORDESYProjectList
+ (TORDESYProject(TORDESYModule(ModuleRef).ProjectRef).FProjectListRef)
+ .GetOraSchemeById(SchemeId);
if not Assigned(iScheme) then
- raise Exception.Create('Error while connecting throw item scheme. SchemeId = ' + IntToStr(SchemeId));
+ raise Exception.Create(
+ 'Error while connecting throw item scheme. SchemeId = ' + IntToStr
+ (SchemeId));
if not iScheme.Connected then
- iScheme.Connect(aProject);
+ iScheme.Connect(BaseId);
with iScheme.Connection.Query do
begin
- Active:= false;
- SQL.Text:= 'select created, last_ddl_time, status from sys.all_objects where owner = user and object_name not like ''BIN$%'' and subobjectname is null and object_type = ''' + TOraItem.GetItemSqlType(ItemType) + '''' + ' and objectname = ''' + Name + '''';
- Active:= true;
+ Active := false;
+ SQL.Text :=
+ 'select created, last_ddl_time, status from sys.all_objects where owner = user and object_name not like ''BIN$%'' and subobjectname is null and object_type = ''' + TOraItem.GetItemSqlType(ItemType) + '''' + ' and objectname = ''' + Name + '''';
+ Active := true;
if RecordCount = 0 then
- raise Exception.Create('The item not deployed yet or deleted manualy. Can''t get status.')
+ raise Exception.Create(
+ 'The item not deployed yet or deleted manualy. Can''t get status.')
else
begin
First;
if Fields[2].ToString = 'VALID' then
- FValid:= true
+ FValid := true
else
- FValid:= false;
+ FValid := false;
end;
end;
finally
@@ -891,94 +936,97 @@ procedure TOraItem.UpdateStatus(var aProject: TORDESYProject);
except
on E: Exception do
begin
- {$IFDEF Debug}
+{$IFDEF Debug}
AddToLog(ClassName + ' | UpdateStatus | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | UpdateStatus | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | UpdateStatus | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
end;
end;
end;
-(*function TOraItem.SaveToProject(var aProject: TORDESYProject): boolean;
-var
+(* function TOraItem.SaveToProject(var aProject: TORDESYProject): boolean;
+ var
iFileName: string;
iFile: textfile;
iScheme: TOraScheme;
iModule: TORDESYModule;
iBase: TOraBase;
reply: word;
-begin
+ begin
aProject.GetOraScheme(FSchemeId, iScheme);
aProject.GetModule(iScheme.FModuleId, iModule);
aProject.GetOraBase(iScheme.FBaseId, iBase);
// Проверка на создание объектов
//Assert(not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase));
if (not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase)) then
- raise Exception.Create('TOraItem.SaveToProject|Some of objects not created!');
+ raise Exception.Create('TOraItem.SaveToProject|Some of objects not created!');
// Сохранение
iFileName:= ExtractFilePath(ParamStr(0)) + 'Projects\' + aProject.Name + '\' + iModule.Name + '\' + iScheme.Login + '\' + Name + '.sql';
if FileExists(iFileName) then
begin
- reply := MessageBox(Application.Handle, PChar('Заменить файл:' + #13#10 + iFileName + '?'), PChar('Файл уже существует.'), 36);
- if reply = IDNO then
- Exit;
+ reply := MessageBox(Application.Handle, PChar('Заменить файл:' + #13#10 + iFileName + '?'), PChar('Файл уже существует.'), 36);
+ if reply = IDNO then
+ Exit;
end;
try
- AssignFile(iFile, iFileName);
- Rewrite(iFile);
- Write(iFile, FBody);
+ AssignFile(iFile, iFileName);
+ Rewrite(iFile);
+ Write(iFile, FBody);
finally
- CloseFile(iFile);
+ CloseFile(iFile);
end;
-end;*)
+ end; *)
-(*function TOraItem.Wrap(var aProject: TORDESYProject): boolean;
-var
+(* function TOraItem.Wrap(var aProject: TORDESYProject): boolean;
+ var
iScheme: TOraScheme;
iModule: TORDESYModule;
iBase: TOraBase;
firstItem: boolean;
-begin
+ begin
try
- aProject.GetOraScheme(FSchemeId, iScheme);
- aProject.GetModule(iScheme.FModuleId, iModule);
- aProject.GetOraBase(iScheme.FBaseId, iBase);
- if (not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase)) then
- raise Exception.Create('TOraItem.SaveToProject|Some of objects not created!');
- if not iScheme.Connected then
- iScheme.Connect(aProject);
- with iScheme.FConnection do
- begin
- Query.Active:= false;
- Query.SQL.Text:= 'select text from sys.all_sources where ' +
- 'owner = ''' + iScheme.Login + '''' +
- 'name = ''' + Name + '''' +
- 'type = ''' + GetItemSqlType(FType) + ''' ' +
- 'order by line';
- Query.Active:= true;
- firstItem:= true;
- while not Query.Eof do
- begin
- if firstItem then
- FBody:= FBody + 'CREATE OR REPLACE ' + Query.Fields[0].AsString + #13#10;
- FBody:= FBody + Query.Fields[0].AsString + #13#10;
- firstItem:= false;
- end;
- end;
+ aProject.GetOraScheme(FSchemeId, iScheme);
+ aProject.GetModule(iScheme.FModuleId, iModule);
+ aProject.GetOraBase(iScheme.FBaseId, iBase);
+ if (not Assigned(iScheme) or not Assigned(iModule) or not Assigned(iBase)) then
+ raise Exception.Create('TOraItem.SaveToProject|Some of objects not created!');
+ if not iScheme.Connected then
+ iScheme.Connect(aProject);
+ with iScheme.FConnection do
+ begin
+ Query.Active:= false;
+ Query.SQL.Text:= 'select text from sys.all_sources where ' +
+ 'owner = ''' + iScheme.Login + '''' +
+ 'name = ''' + Name + '''' +
+ 'type = ''' + GetItemSqlType(FType) + ''' ' +
+ 'order by line';
+ Query.Active:= true;
+ firstItem:= true;
+ while not Query.Eof do
+ begin
+ if firstItem then
+ FBody:= FBody + 'CREATE OR REPLACE ' + Query.Fields[0].AsString + #13#10;
+ FBody:= FBody + Query.Fields[0].AsString + #13#10;
+ firstItem:= false;
+ end;
+ end;
except
- on E: Exception do
- begin
- {$IFDEF Debug}
- AddToLog(ClassName + ' | Wrap | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | Wrap | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
- end;
+ on E: Exception do
+ begin
+ {$IFDEF Debug}
+ AddToLog(ClassName + ' | Wrap | ' + E.Message);
+ MessageBox(Application.Handle, PChar(ClassName + ' | Wrap | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
+ {$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
+ {$ENDIF}
+ end;
end;
-end;*)
+ end; *)
procedure TOraBase.SetName(const Value: string);
begin
@@ -998,8 +1046,8 @@ procedure TORDESYProjectList.AddProject(aProject: TORDESYProject);
Exit;
end;
SetLength(FProjects, length(FProjects) + 1);
- FProjects[high(FProjects)]:= aProject;
- FSaved:= false;
+ FProjects[ high(FProjects)] := aProject;
+ FSaved := false;
if Assigned(FOnProjectAdd) then
FOnProjectAdd(Self);
end;
@@ -1011,12 +1059,13 @@ procedure TORDESYProjectList.Clear;
for i := 0 to high(FProjects) do
FProjects[i].Free;
SetLength(FProjects, 0);
- FSaved:= false;
+ FSaved := false;
end;
constructor TORDESYProjectList.Create;
begin
inherited Create;
+ OnChange := OnProjectListChange;
end;
destructor TORDESYProjectList.Destroy;
@@ -1027,17 +1076,24 @@ destructor TORDESYProjectList.Destroy;
FProjects[i].Free;
SetLength(FProjects, 0);
+ for i := 0 to high(FOraSchemes) do
+ FOraSchemes[i].Free;
+ SetLength(FOraSchemes, 0);
+
+ for i := 0 to high(FOraBases) do
+ FOraBases[i].Free;
+ SetLength(FOraBases, 0);
+
inherited Destroy;
end;
function TORDESYProjectList.GetFreeProjectId: integer;
var
i, NewId: integer;
-label
- Restart;
+label Restart;
begin
- NewId:= 0;
- Restart:
+ NewId := 0;
+Restart :
for i := 0 to high(FProjects) do
begin
if FProjects[i].Id = NewId then
@@ -1046,45 +1102,43 @@ function TORDESYProjectList.GetFreeProjectId: integer;
goto Restart;
end;
end;
- Result:= NewId;
+ Result := NewId;
end;
function TORDESYProjectList.GetProjectById(const aId: integer): TORDESYProject;
var
i: integer;
begin
- Result:= nil;
+ Result := nil;
for i := 0 to high(FProjects) do
begin
if FProjects[i].Id = aId then
- Result:= FProjects[i];
+ Result := FProjects[i];
end;
end;
-function TORDESYProjectList.GetProjectByIndex(
- const aIndex: integer): TORDESYProject;
+function TORDESYProjectList.GetProjectByIndex(const aIndex: integer)
+ : TORDESYProject;
begin
- Result:= nil;
+ Result := nil;
if (aIndex >= 0) and (aIndex <= high(FProjects)) then
- Result:= FProjects[aIndex];
+ Result := FProjects[aIndex];
end;
function TORDESYProjectList.GetProjectsCount: integer;
begin
- Result:= Length(FProjects);
+ Result := length(FProjects);
end;
function TORDESYProjectList.LoadFromFile(const aFileName: string): boolean;
var
iHandle: integer;
- iP, iM, iB, iSc, Ii, iId, ModuleId, BaseId, SchemeId,
- charSize, strSize, NameSize, DescSize, CreatorSize, BodySize,
- LoginSize, PassSize,
- iProjectCount, iModuleCount, iBaseCount, iSchemeCount, iItemCount: integer;
+ iP, iM, iB, iSc, Ii, iId, ModuleId, BaseId, SchemeId, charSize, strSize,
+ NameSize, DescSize, CreatorSize, BodySize, LoginSize, PassSize,
+ iProjectCount, iModuleCount, iBaseCount, iSchemeCount, iItemCount: integer;
iItemType: TOraItemType;
- iFileHeader, iFileVersion,
- iName, iDescription, iCreator,
- iLogin, iPass, iBody: String;
+ iFileHeader, iFileVersion, iName, iDescription, iCreator, iLogin, iPass,
+ iBody: String;
iDateCreate: TDateTime;
IItemValid: boolean;
iProject: TORDESYProject;
@@ -1093,191 +1147,198 @@ function TORDESYProjectList.LoadFromFile(const aFileName: string): boolean;
iScheme: TOraScheme;
iItem: TOraItem;
begin
- Result:= false;
+ Result := false;
try
if not FileExists(aFileName) then
begin
- Result:= true;
+ Result := true;
Exit;
end;
Clear;
try
- iHandle:= FileOpen(aFileName, fmOpenRead);
+ iHandle := FileOpen(aFileName, fmOpenRead);
if iHandle = -1 then
raise Exception.Create(SysErrorMessage(GetLastError));
- charSize:= SizeOf(Char);
+ charSize := SizeOf(Char);
SetLength(iFileHeader, length(ORDESYNAME));
SetLength(iFileVersion, length(ORDESYVERSION));
- FileRead(iHandle, iFileHeader[1], length(ORDESYNAME) * charSize); // Reading header
- FileRead(iHandle, iFileVersion[1], length(ORDESYVERSION) * charSize); // Reading version
- //MessageBox(Application.Handle, PChar(iFileHeader + ' - ' + iFileVersion), PChar('warning'), 0);
+ FileRead(iHandle, iFileHeader[1], length(ORDESYNAME) * charSize);
+ // Reading header
+ FileRead(iHandle, iFileVersion[1], length(ORDESYVERSION) * charSize);
+ // Reading version
+ // MessageBox(Application.Handle, PChar(iFileHeader + ' - ' + iFileVersion), PChar('warning'), 0);
if (iFileHeader <> ORDESYNAME) or (iFileVersion <> ORDESYVERSION) then
- raise Exception.Create('Incorrect project version! Need: ' + ORDESYNAME + ' ' + ORDESYVERSION);
+ raise Exception.Create
+ ('Incorrect project version! Need: ' + ORDESYNAME + ' ' +
+ ORDESYVERSION);
SetLength(iFileHeader, 0);
SetLength(iFileVersion, 0);
- FileRead(iHandle, iProjectCount, sizeof(iProjectCount)); // PROJECT COUNT
- for iP:= 0 to iProjectCount - 1 do
+ FileRead(iHandle, iProjectCount, SizeOf(iProjectCount)); // PROJECT COUNT
+ for iP := 0 to iProjectCount - 1 do
begin
// Id
- FileRead(iHandle, iId, sizeof(iId));
+ FileRead(iHandle, iId, SizeOf(iId));
// Name
- FileRead(iHandle, strSize, sizeof(strSize)); // Name length
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Name length
SetLength(iName, strSize);
FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
// Desc
- FileRead(iHandle, strSize, sizeof(strSize)); // Desc length
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Desc length
SetLength(iDescription, strSize);
FileRead(iHandle, iDescription[1], strSize * charSize); // Getting Desc
// Creator
- FileRead(iHandle, strSize, sizeof(strSize)); // Creator length
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Creator length
SetLength(iCreator, strSize);
FileRead(iHandle, iCreator[1], strSize * charSize); // Getting creator
// Datecreate
FileRead(iHandle, iDateCreate, SizeOf(iDateCreate));
// Creating project
- iProject:= TORDESYProject.Create(iId, iName, iDescription, iCreator, iDateCreate);
- iProject.OnChange:= OnChange;
+ iProject := TORDESYProject.Create(iId, iName, iDescription, iCreator,
+ iDateCreate);
+ iProject.OnChange := OnChange;
// Free
SetLength(iName, 0);
SetLength(iDescription, 0);
SetLength(iCreator, 0);
- //--- MODULES
- FileRead(iHandle, iModuleCount, sizeof(iModuleCount)); // MODULE COUNT
+ // --- MODULES
+ FileRead(iHandle, iModuleCount, SizeOf(iModuleCount)); // MODULE COUNT
for iM := 0 to iModuleCount - 1 do
begin
// Id
- FileRead(iHandle, iId, sizeof(iId));
+ FileRead(iHandle, iId, SizeOf(iId));
// Name
- FileRead(iHandle, strSize, sizeof(strSize)); // Name length
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Name length
SetLength(iName, strSize);
FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
// Desc
- FileRead(iHandle, strSize, sizeof(strSize)); // Desc length
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Desc length
SetLength(iDescription, strSize);
- FileRead(iHandle, iDescription[1], strSize * charSize); // Getting Desc
+ FileRead(iHandle, iDescription[1], strSize * charSize);
+ // Getting Desc
// Adding
- iProject.AddModule(TORDESYModule.Create(iProject ,iId, iName, iDescription));
+ iModule := TORDESYModule.Create(iProject, iId, iName, iDescription);
+ iProject.AddModule(iModule);
// Free
SetLength(iName, 0);
SetLength(iDescription, 0);
- end;
- //--- BASES
- FileRead(iHandle, iBaseCount, sizeof(iBaseCount)); // BASE COUNT
- //MessageBox(Application.Handle, PChar('base loaded count = ' + inttostr(iBaseCount)), PChar('warning'), 0);
- for iB := 0 to iBaseCount - 1 do
- begin
- // Id
- FileRead(iHandle, iId, sizeof(iId));
- // Name
- FileRead(iHandle, strSize, sizeof(strSize)); // Name length
- SetLength(iName, strSize);
- FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
- // Adding
- iProject.AddOraBase(TOraBase.Create(iId, iName));
- // Free
- SetLength(iName, 0);
- end;
- //--- SCHEMES
- FileRead(iHandle, iSchemeCount, sizeof(iSchemeCount)); // SCHEME COUNT
- //MessageBox(Application.Handle, PChar('scheme loaded count = ' + inttostr(iSchemeCount)), PChar('warning'), 0);
- for iSc := 0 to iSchemeCount - 1 do
- begin
- // Id
- FileRead(iHandle, iId, sizeof(iId));
- // Login
- FileRead(iHandle, strSize, sizeof(strSize)); // Login length
- SetLength(iLogin, strSize);
- FileRead(iHandle, iLogin[1], strSize * charSize); // Getting Login
- // Pass
- FileRead(iHandle, strSize, sizeof(strSize)); // Pass length
- SetLength(iPass, strSize);
- FileRead(iHandle, iPass[1], strSize * charSize); // Getting Login
- // ModuleId
- FileRead(iHandle, ModuleId, sizeof(ModuleId));
- // BaseId
- FileRead(iHandle, BaseId, sizeof(BaseId));
- // Adding
- iProject.AddOraScheme(TOraScheme.Create(iProject, iId, iLogin, iPass, BaseId, ModuleId));
- // Free
- SetLength(iLogin, 0);
- SetLength(iPass, 0);
- end;
- //--- ITEMS
- FileRead(iHandle, iItemCount, sizeof(iItemCount)); // ITEM COUNT
- //MessageBox(Application.Handle, PChar('item loaded count = ' + inttostr(iItemCount)), PChar('warning'), 0);
- for Ii := 0 to iItemCount - 1 do
- begin
- // Id
- FileRead(iHandle, iId, sizeof(iId));
- // ShemeId
- FileRead(iHandle, SchemeId, sizeof(SchemeId));
- // Name
- FileRead(iHandle, strSize, sizeof(strSize)); // Name length
- SetLength(iName, strSize);
- FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
- // Type
- FileRead(iHandle, iItemType, sizeof(iItemType));
- // Valid
- FileRead(iHandle, iItemValid, sizeof(iItemValid));
- // Body
- FileRead(iHandle, strSize, sizeof(strSize)); // Body length
- SetLength(iBody, strSize);
- FileRead(iHandle, iBody[1], strSize * charSize); // Getting Name
- // Adding
- iProject.AddOraItem(TOraItem.Create(iId, SchemeId, iName, iBody, iItemType, IItemValid));
- // Free
- SetLength(iName, 0);
- SetLength(iBody, 0);
+ //
+ // --- ITEMS
+ FileRead(iHandle, iItemCount, SizeOf(iItemCount)); // ITEM COUNT
+ // MessageBox(Application.Handle, PChar('item loaded count = ' + inttostr(iItemCount)), PChar('warning'), 0);
+ for Ii := 0 to iItemCount - 1 do
+ begin
+ // Id
+ FileRead(iHandle, iId, SizeOf(iId));
+ // BaseId
+ FileRead(iHandle, BaseId, SizeOf(BaseId));
+ // ShemeId
+ FileRead(iHandle, SchemeId, SizeOf(SchemeId));
+ // Name
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Name length
+ SetLength(iName, strSize);
+ FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
+ // Type
+ FileRead(iHandle, iItemType, SizeOf(iItemType));
+ // Valid
+ FileRead(iHandle, IItemValid, SizeOf(IItemValid));
+ // Body
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Body length
+ SetLength(iBody, strSize);
+ FileRead(iHandle, iBody[1], strSize * charSize); // Getting Name
+ // Adding
+ iModule.AddOraItem(TOraItem.Create(iModule, iId, BaseId, SchemeId,
+ iName, iBody, iItemType, IItemValid));
+ // Free
+ SetLength(iName, 0);
+ SetLength(iBody, 0);
+ end;
end;
// ADD PROJECT
AddProject(iProject);
end;
- FSaved:= true;
- Result:= true;
+ // --- BASES
+ FileRead(iHandle, iBaseCount, SizeOf(iBaseCount)); // BASE COUNT
+ // MessageBox(Application.Handle, PChar('base loaded count = ' + inttostr(iBaseCount)), PChar('warning'), 0);
+ for iB := 0 to iBaseCount - 1 do
+ begin
+ // Id
+ FileRead(iHandle, iId, SizeOf(iId));
+ // Name
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Name length
+ SetLength(iName, strSize);
+ FileRead(iHandle, iName[1], strSize * charSize); // Getting Name
+ // Adding
+ AddOraBase(TOraBase.Create(Self, iId, iName));
+ // Free
+ SetLength(iName, 0);
+ end;
+ // --- SCHEMES
+ FileRead(iHandle, iSchemeCount, SizeOf(iSchemeCount)); // SCHEME COUNT
+ // MessageBox(Application.Handle, PChar('scheme loaded count = ' + inttostr(iSchemeCount)), PChar('warning'), 0);
+ for iSc := 0 to iSchemeCount - 1 do
+ begin
+ // Id
+ FileRead(iHandle, iId, SizeOf(iId));
+ // Login
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Login length
+ SetLength(iLogin, strSize);
+ FileRead(iHandle, iLogin[1], strSize * charSize); // Getting Login
+ // Pass
+ FileRead(iHandle, strSize, SizeOf(strSize)); // Pass length
+ SetLength(iPass, strSize);
+ FileRead(iHandle, iPass[1], strSize * charSize); // Getting Login
+ // Adding
+ AddOraScheme(TOraScheme.Create(Self, iId, iLogin, iPass));
+ // Free
+ SetLength(iLogin, 0);
+ SetLength(iPass, 0);
+ end;
+ FSaved := true;
+ Result := true;
finally
FileClose(iHandle);
end;
except
on E: Exception do
begin
- {$IFDEF Debug}
+{$IFDEF Debug}
AddToLog(ClassName + ' | LoadFromFile | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | LoadFromFile | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
- {$ENDIF}
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | LoadFromFile | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ELSE}
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
+{$ENDIF}
end;
end;
end;
-procedure TORDESYProjectList.OnChange(Sender: TObject);
+procedure TORDESYProjectList.OnProjectListChange(Sender: TObject);
begin
- FSaved:= false;
+ FSaved := false;
end;
-procedure TORDESYProjectList.RemoveProjectById(const aId: integer);
-var
- i: integer;
- LastItem: TORDESYProject;
+function TORDESYProjectList.RemoveProjectById(const aId: integer): boolean;
begin
- for i := 0 to high(FProjects) do
+ Result:= false;
+ if GetProjectById(aId) <> nil then
begin
- if FProjects[i].Id = aId then
- begin
- FProjects[i].Free;
- LastItem:= FProjects[high(FProjects)];
- FProjects[i]:= LastItem;
- SetLength(FProjects, length(FProjects) - 1);
- FSaved:= false;
- if Assigned(FOnProjectRemove) then
- FOnProjectRemove(Self);
- end;
+ FProjects[aId].Free;
+ FProjects[aId]:= FProjects[ high(FProjects)];
+ SetLength(FProjects, length(FProjects) - 1);
+ FSaved := false;
+ if Assigned(FOnProjectRemove) then
+ OnProjectRemove(Self);
+ if Assigned(FOnChange) then
+ OnChange(Self);
+ Result:= true;
end;
end;
function TORDESYProjectList.SaveToFile(const aFileName: string): boolean;
var
- iP, iM, iB, iSc, iI, charSize, strSize, i: integer;
+ iP, iM, iB, iSc, Ii, charSize, strSize, i: integer;
iHandle: integer;
iProjectCount, iModuleCount, iBaseCount, iSchemeCount, iItemCount: integer;
iProject: TORDESYProject;
@@ -1285,117 +1346,113 @@ function TORDESYProjectList.SaveToFile(const aFileName: string): boolean;
iBase: TOraBase;
iScheme: TOraScheme;
iItem: TOraItem;
- Buffer: PChar;
begin
- Result:= false;
- FSaved:= false;
+ Result := false;
+ FSaved := false;
try
try
- iProjectCount:= Count;
- charSize:= sizeof(Char);
- iHandle:= FileCreate(aFileName);
- FileWrite(iHandle, ORDESYNAME[1], Length(ORDESYNAME) * charSize);
- FileWrite(iHandle, ORDESYVERSION[1], Length(ORDESYVERSION) * charSize);
- //--- PROJECTS
- iProjectCount:= GetProjectsCount;
- FileWrite(iHandle, iProjectCount, sizeof(iProjectCount));
+ charSize := SizeOf(Char);
+ iHandle := FileCreate(aFileName);
+ FileWrite(iHandle, ORDESYNAME[1], length(ORDESYNAME) * charSize);
+ FileWrite(iHandle, ORDESYVERSION[1], length(ORDESYVERSION) * charSize);
+ // --- PROJECTS
+ iProjectCount := ProjectCount;
+ FileWrite(iHandle, iProjectCount, SizeOf(iProjectCount));
for iP := 0 to iProjectCount - 1 do
begin
- iProject:= GetProjectByIndex(iP);
+ iProject := GetProjectByIndex(iP);
// Id
- FileWrite(iHandle, iProject.Id, sizeof(iProject.Id));
+ FileWrite(iHandle, iProject.Id, SizeOf(iProject.Id));
// Name
- strSize:= Length(iProject.Name);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Name length
+ strSize := length(iProject.Name);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Name length
FileWrite(iHandle, iProject.Name[1], strSize * charSize); // Name
// Desc
- strSize:= Length(iProject.Description);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Desc length
+ strSize := length(iProject.Description);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Desc length
FileWrite(iHandle, iProject.Description[1], strSize * charSize); // Desc
// Creator
- strSize:= Length(iProject.Creator);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Creator length
+ strSize := length(iProject.Creator);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Creator length
FileWrite(iHandle, iProject.Creator[1], strSize * charSize); // Creator
// Datecreate
- FileWrite(iHandle, iProject.DateCreate, sizeof(iProject.DateCreate));
- //--- MODULES
- iModuleCount:= iProject.ModuleCount;
- FileWrite(iHandle, iModuleCount, sizeof(iModuleCount));
+ FileWrite(iHandle, iProject.DateCreate, SizeOf(iProject.DateCreate));
+ // --- MODULES
+ iModuleCount := iProject.ModuleCount;
+ FileWrite(iHandle, iModuleCount, SizeOf(iModuleCount));
for iM := 0 to iModuleCount - 1 do
begin
- iModule:= iProject.GetModuleByIndex(iM);
+ iModule := iProject.GetModuleByIndex(iM);
// Id
- FileWrite(iHandle, iModule.Id, sizeof(iModule.Id));
+ FileWrite(iHandle, iModule.Id, SizeOf(iModule.Id));
// Name
- strSize:= Length(iModule.Name);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Name length
+ strSize := length(iModule.Name);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Name length
FileWrite(iHandle, iModule.Name[1], strSize * charSize); // Name
// Desc
- strSize:= Length(iModule.Description);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Desc length
- FileWrite(iHandle, iModule.Description[1], strSize * charSize); // Desc
- end;
- //--- BASES
- iBaseCount:= iProject.OraBaseCount;
- MessageBox(Application.Handle, PChar('base count = ' + inttostr(iBaseCount)), PChar('warning'), 0);
- FileWrite(iHandle, iBaseCount, sizeof(iBaseCount));
- for iB := 0 to iBaseCount - 1 do
- begin
- iBase:= iProject.GetOraBaseByIndex(iB);
- // Id
- FileWrite(iHandle, iBase.Id, sizeof(iBase.Id));
- // Name
- strSize:= Length(iBase.Name);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Name length
- FileWrite(iHandle, iBase.Name[1], strSize * charSize); // Name
- end;
- //--- SCHEMES
- iSchemeCount:= iProject.OraSchemeCount;
- FileWrite(iHandle, iSchemeCount, sizeof(iSchemeCount));
- for iSc := 0 to iSchemeCount - 1 do
- begin
- iScheme:= iProject.GetOraSchemeByIndex(iSc);
- // Id
- FileWrite(iHandle, iScheme.Id, sizeof(iScheme.Id));
- // Login
- strSize:= Length(iScheme.Login);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Login length
- FileWrite(iHandle, iScheme.Login[1], strSize * charSize); // Login
- // Pass
- strSize:= Length(iScheme.Pass);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Pass length
- FileWrite(iHandle, iScheme.Pass[1], strSize * charSize); // Pass
- // ModuleId
- FileWrite(iHandle, iScheme.ModuleId, sizeof(iScheme.ModuleId));
- // BaseId
- FileWrite(iHandle, iScheme.BaseId, sizeof(iScheme.BaseId));
- end;
- //--- ITEMS
- iItemCount:= iProject.OraItemCount;
- FileWrite(iHandle, iItemCount, sizeof(iItemCount));
- for iI := 0 to iItemCount - 1 do
- begin
- iItem:= iProject.GetOraItemByIndex(iI);
- // Id
- FileWrite(iHandle, iItem.Id, sizeof(iItem.Id));
- // SchemeId
- FileWrite(iHandle, iItem.SchemeId, sizeof(iItem.SchemeId));
- // Name
- strSize:= Length(iItem.Name);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Name length
- FileWrite(iHandle, iItem.Name[1], strSize * charSize); // Name
- // Type
- FileWrite(iHandle, iItem.ItemType, sizeof(iItem.ItemType));
- // Valid
- FileWrite(iHandle, iItem.Valid, sizeof(iItem.Valid));
- // Body
- strSize:= Length(iItem.ItemBody);
- FileWrite(iHandle, strSize, sizeof(strSize)); // Body length
- FileWrite(iHandle, iItem.ItemBody[1], strSize * charSize); // Body
+ strSize := length(iModule.Description);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Desc length
+ FileWrite(iHandle, iModule.Description[1], strSize * charSize);
+ // Desc
+ // --- ITEMS
+ iItemCount := iModule.OraItemCount;
+ FileWrite(iHandle, iItemCount, SizeOf(iItemCount));
+ for Ii := 0 to iItemCount - 1 do
+ begin
+ iItem := iModule.GetOraItemByIndex(Ii);
+ // Id
+ FileWrite(iHandle, iItem.Id, SizeOf(iItem.Id));
+ // BaseId
+ FileWrite(iHandle, iItem.BaseId, SizeOf(iItem.BaseId));
+ // SchemeId
+ FileWrite(iHandle, iItem.SchemeId, SizeOf(iItem.SchemeId));
+ // Name
+ strSize := length(iItem.Name);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Name length
+ FileWrite(iHandle, iItem.Name[1], strSize * charSize); // Name
+ // Type
+ FileWrite(iHandle, iItem.ItemType, SizeOf(iItem.ItemType));
+ // Valid
+ FileWrite(iHandle, iItem.Valid, SizeOf(iItem.Valid));
+ // Body
+ strSize := length(iItem.ItemBody);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Body length
+ FileWrite(iHandle, iItem.ItemBody[1], strSize * charSize); // Body
+ end;
end;
end;
- FSaved:= true;
- Result:= true;
+ // --- BASES
+ iBaseCount := OraBaseCount;
+ FileWrite(iHandle, iBaseCount, SizeOf(iBaseCount));
+ for iB := 0 to iBaseCount - 1 do
+ begin
+ iBase := GetOraBaseByIndex(iB);
+ // Id
+ FileWrite(iHandle, iBase.Id, SizeOf(iBase.Id));
+ // Name
+ strSize := length(iBase.Name);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Name length
+ FileWrite(iHandle, iBase.Name[1], strSize * charSize); // Name
+ end;
+ // --- SCHEMES
+ iSchemeCount := OraSchemeCount;
+ FileWrite(iHandle, iSchemeCount, SizeOf(iSchemeCount));
+ for iSc := 0 to iSchemeCount - 1 do
+ begin
+ iScheme := GetOraSchemeByIndex(iSc);
+ // Id
+ FileWrite(iHandle, iScheme.Id, SizeOf(iScheme.Id));
+ // Login
+ strSize := length(iScheme.Login);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Login length
+ FileWrite(iHandle, iScheme.Login[1], strSize * charSize); // Login
+ // Pass
+ strSize := length(iScheme.Pass);
+ FileWrite(iHandle, strSize, SizeOf(strSize)); // Pass length
+ FileWrite(iHandle, iScheme.Pass[1], strSize * charSize); // Pass
+ end;
+ FSaved := true;
+ Result := true;
finally
FileClose(iHandle);
end;
@@ -1404,9 +1461,12 @@ function TORDESYProjectList.SaveToFile(const aFileName: string): boolean;
begin
{$IFDEF Debug}
AddToLog(ClassName + ' | SaveToFile | ' + E.Message);
- MessageBox(Application.Handle, PChar(ClassName + ' | SaveToFile | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
+ MessageBox(Application.Handle, PChar
+ (ClassName + ' | SaveToFile | ' + E.Message), PChar
+ (Application.Title + ' - Error'), 48);
{$ELSE}
- MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
+ MessageBox(Application.Handle, PChar(E.Message), PChar
+ (Application.Title + ' - Error'), 48);
{$ENDIF}
end;
end;
@@ -1414,16 +1474,28 @@ function TORDESYProjectList.SaveToFile(const aFileName: string): boolean;
{ TORDESYModule }
-constructor TORDESYModule.Create(aProjectRef: Pointer; const aId: integer; const aName: string = 'New Module'; const aDescription: WideString = '');
+constructor TORDESYModule.Create(aProjectRef: Pointer; const aId: integer;
+ const aName: string = 'New Module'; const aDescription: WideString = '');
begin
inherited Create;
- FId:= aId;
- FName:= aName;
- FDescription:= aDescription;
- FProjectRef:= aProjectRef;
+ FId := aId;
+ FName := aName;
+ FDescription := aDescription;
+ FProjectRef := aProjectRef;
+end;
+
+destructor TORDESYModule.Destroy;
+var
+ i: integer;
+begin
+ for i := 0 to high(FOraItems) do
+ FOraItems[i].Free;
+ SetLength(FOraItems, 0);
+
+ inherited Destroy;
end;
-procedure TORDESYModule.SetDescription(const Value: widestring);
+procedure TORDESYModule.SetDescription(const Value: WideString);
begin
FDescription := Value;
if Assigned(FOnChange) then
diff --git a/uProject.dfm b/uProjectDialogs.dfm
similarity index 98%
rename from uProject.dfm
rename to uProjectDialogs.dfm
index 781fd32..24cddf9 100644
--- a/uProject.dfm
+++ b/uProjectDialogs.dfm
@@ -3,7 +3,7 @@ object fmProjectCreate: TfmProjectCreate
Top = 0
BorderIcons = [biSystemMenu]
BorderStyle = bsSizeToolWin
- Caption = 'Create Project'
+ Caption = 'Add Project'
ClientHeight = 281
ClientWidth = 414
Color = clBtnFace
diff --git a/uProject.pas b/uProjectDialogs.pas
similarity index 70%
rename from uProject.pas
rename to uProjectDialogs.pas
index 4b87389..d42d7fd 100644
--- a/uProject.pas
+++ b/uProjectDialogs.pas
@@ -1,4 +1,4 @@
-unit uProject;
+unit uProjectDialogs;
interface
@@ -27,6 +27,8 @@ TfmProjectCreate = class(TForm)
function ShowProjectCreateDialog(const aCreator: string; var aProjectList: TORDESYProjectList): boolean;
function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
+function ShowModuleCreateDialog(aProject: TORDESYProject): boolean;
+function ShowModuleEditDialog(aModule: TORDESYModule): boolean;
implementation
@@ -45,10 +47,6 @@ function ShowProjectCreateDialog(const aCreator: string; var aProjectList: TORDE
dTimer.OnTimer:= UpdateCurrentDateTime;
if ShowModal = mrOk then
begin
- if (edtProjectName.Text = '') or (length(edtProjectName.Text) > 255) then
- raise Exception.Create('Incorrect project name, empty or more than 255 characters!');
- if (length(mmDescription.Text) > 1000) then
- raise Exception.Create('Incorrect project description, more than 1000 characters!');
aProjectList.AddProject(TORDESYProject.Create(aProjectList.GetFreeProjectId, edtProjectName.Text, mmDescription.Text, lblCreator.Caption));
Result:= true;
end;
@@ -59,8 +57,6 @@ function ShowProjectCreateDialog(const aCreator: string; var aProjectList: TORDE
end;
function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
-label
- check;
begin
with TfmProjectCreate.Create(Application) do
try
@@ -72,7 +68,6 @@ function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
lblDateCreate.Caption:= FormatDateTime('c', aProject.DateCreate);
lblDateCreate.Visible:= true;
btnCreate.Caption:= 'Save';
- check:
if ShowModal = mrOk then
begin
aProject.Name:= edtProjectName.Text;
@@ -85,6 +80,46 @@ function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
end;
end;
+function ShowModuleCreateDialog(aProject: TORDESYProject): boolean;
+begin
+ with TfmProjectCreate.Create(Application) do
+ try
+ Result:= false;
+ Caption:= 'Add module';
+ lblCreatorHead.Visible:= false;
+ lblDate.Visible:= false;
+ if ShowModal = mrOk then
+ begin
+ aProject.AddModule(TORDESYModule.Create(aProject, aProject.GetFreeModuleId, edtProjectName.Text, mmDescription.Text));
+ Result:= true;
+ end;
+ finally
+ Free;
+ end;
+end;
+
+function ShowModuleEditDialog(aModule: TORDESYModule): boolean;
+begin
+ with TfmProjectCreate.Create(Application) do
+ try
+ Result:= false;
+ Caption:= 'Edit module';
+ edtProjectName.Text:= aModule.Name;
+ mmDescription.Text:= aModule.Description;
+ lblCreator.Visible:= false;
+ lblDate.Visible:= false;
+ btnCreate.Caption:= 'Save';
+ if ShowModal = mrOk then
+ begin
+ aModule.Name:= edtProjectName.Text;
+ aModule.Description:= mmDescription.Text;
+ Result:= true;
+ end;
+ finally
+ Free;
+ end;
+end;
+
procedure TfmProjectCreate.btnCreateClick(Sender: TObject);
begin
if (edtProjectName.Text = '') or (length(edtProjectName.Text) > 255) then
diff --git a/uWrap.dfm b/uWrap.dfm
index 0a76ed8..405cbb0 100644
--- a/uWrap.dfm
+++ b/uWrap.dfm
@@ -2,9 +2,11 @@ object fmWrap: TfmWrap
Left = 0
Top = 0
Caption = 'Wrap item'
- ClientHeight = 490
- ClientWidth = 535
+ ClientHeight = 421
+ ClientWidth = 445
Color = clBtnFace
+ Constraints.MinHeight = 400
+ Constraints.MinWidth = 400
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
@@ -17,16 +19,18 @@ object fmWrap: TfmWrap
object pnlMain: TPanel
Left = 0
Top = 0
- Width = 535
- Height = 490
+ Width = 445
+ Height = 421
Align = alClient
BevelOuter = bvNone
TabOrder = 0
+ ExplicitWidth = 526
+ ExplicitHeight = 539
DesignSize = (
- 535
- 490)
+ 445
+ 421)
object lblItemType: TLabel
- Left = 8
+ Left = 319
Top = 8
Width = 28
Height = 13
@@ -34,7 +38,7 @@ object fmWrap: TfmWrap
end
object lblProject: TLabel
Left = 8
- Top = 415
+ Top = 346
Width = 38
Height = 13
Anchors = [akLeft, akBottom]
@@ -43,7 +47,7 @@ object fmWrap: TfmWrap
end
object lblModule: TLabel
Left = 8
- Top = 434
+ Top = 365
Width = 38
Height = 13
Anchors = [akLeft, akBottom]
@@ -52,7 +56,7 @@ object fmWrap: TfmWrap
end
object lblBase: TLabel
Left = 8
- Top = 453
+ Top = 384
Width = 27
Height = 13
Anchors = [akLeft, akBottom]
@@ -61,17 +65,31 @@ object fmWrap: TfmWrap
end
object lblScheme: TLabel
Left = 8
- Top = 472
+ Top = 403
Width = 41
Height = 13
Anchors = [akLeft, akBottom]
Caption = 'Scheme:'
ExplicitTop = 471
end
- object cbxItemType: TComboBox
+ object lblBaseList: TLabel
Left = 8
- Top = 24
- Width = 518
+ Top = 8
+ Width = 43
+ Height = 13
+ Caption = 'BaseList:'
+ end
+ object lblSchemeList: TLabel
+ Left = 164
+ Top = 8
+ Width = 57
+ Height = 13
+ Caption = 'SchemeList:'
+ end
+ object cbxItemType: TComboBox
+ Left = 318
+ Top = 27
+ Width = 118
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
@@ -82,20 +100,23 @@ object fmWrap: TfmWrap
'PROCEDURE'
'FUNCTION'
'PACKAGE')
+ ExplicitWidth = 257
end
object lbxList: TListBox
Left = 8
Top = 51
- Width = 518
- Height = 360
+ Width = 428
+ Height = 283
Anchors = [akLeft, akTop, akRight, akBottom]
ItemHeight = 13
TabOrder = 1
OnDrawItem = lbxListDrawItem
+ ExplicitWidth = 541
+ ExplicitHeight = 401
end
object btnUpdate: TButton
- Left = 289
- Top = 457
+ Left = 199
+ Top = 388
Width = 75
Height = 25
Anchors = [akRight, akBottom]
@@ -103,10 +124,12 @@ object fmWrap: TfmWrap
ModalResult = 4
TabOrder = 2
OnClick = btnUpdateClick
+ ExplicitLeft = 289
+ ExplicitTop = 457
end
object btnWrap: TButton
- Left = 370
- Top = 457
+ Left = 280
+ Top = 388
Width = 75
Height = 25
Anchors = [akRight, akBottom]
@@ -114,10 +137,12 @@ object fmWrap: TfmWrap
Default = True
ModalResult = 1
TabOrder = 3
+ ExplicitLeft = 370
+ ExplicitTop = 457
end
object btnClose: TButton
- Left = 451
- Top = 457
+ Left = 361
+ Top = 388
Width = 75
Height = 25
Anchors = [akRight, akBottom]
@@ -125,6 +150,25 @@ object fmWrap: TfmWrap
ModalResult = 11
TabOrder = 4
OnClick = btnCloseClick
+ ExplicitLeft = 451
+ ExplicitTop = 457
+ end
+ object cbxBaseList: TComboBox
+ Left = 8
+ Top = 27
+ Width = 150
+ Height = 21
+ Style = csDropDownList
+ TabOrder = 5
+ OnSelect = cbxBaseListSelect
+ end
+ object cbxSchemeList: TComboBox
+ Left = 162
+ Top = 27
+ Width = 150
+ Height = 21
+ Style = csDropDownList
+ TabOrder = 6
end
end
end
diff --git a/uWrap.pas b/uWrap.pas
index 9542fd5..b40e0f4 100644
--- a/uWrap.pas
+++ b/uWrap.pas
@@ -25,20 +25,26 @@ TfmWrap = class(TForm)
lblModule: TLabel;
lblBase: TLabel;
lblScheme: TLabel;
+ cbxBaseList: TComboBox;
+ cbxSchemeList: TComboBox;
+ lblBaseList: TLabel;
+ lblSchemeList: TLabel;
procedure btnCloseClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnUpdateClick(Sender: TObject);
procedure lbxListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect;
State: TOwnerDrawState);
+ procedure cbxBaseListSelect(Sender: TObject);
private
- SchemeId: integer;
CurrentProject: TORDESYProject;
+ CurrentBase: TOraBase;
+ CurrentScheme: TOraScheme;
end;
var
fmWrap: TfmWrap;
-function ShowWrapDialog(const aSchemeId: integer; aProject: TORDESYProject): boolean;
+function ShowWrapDialog(aModule: TORDESYModule; aProjectList: TORDESYProjectList): boolean;
implementation
@@ -47,24 +53,27 @@ implementation
uses
uMain;
-function ShowWrapDialog(const aSchemeId: integer; aProject: TORDESYProject): boolean;
+function ShowWrapDialog(aModule: TORDESYModule; aProjectList: TORDESYProjectList): boolean;
var
iScheme: TOraScheme;
+ i: integer;
begin
with TfmWrap.Create(Application) do
try
Result:= false;
- CurrentProject:= aProject;
- SchemeId:= aSchemeId;
- lblProject.Caption:= 'Project: ' + aProject.Name;
+ CurrentProject:= TORDESYProject(aModule.ProjectRef);
+ for i := 0 to aProjectList.OraBaseCount - 1 do
+ cbxBaseList.Items.AddObject(aProjectList.GetOraBaseByIndex(i).Name, aProjectList.GetOraBaseByIndex(i));
+ for i := 0 to aProjectList.OraSchemeCount - 1 do
+ cbxSchemeList.Items.AddObject(aProjectList.GetOraSchemeByIndex(i).Login, aProjectList.GetOraSchemeByIndex(i));
+ {lblProject.Caption:= 'Project: ' + aProject.Name;
lblModule.Caption:= 'Module: ' + aProject.GetModuleById(aProject.GetOraSchemeById(SchemeId).ModuleId).Name;
lblBase.Caption:= 'Base: ' + aProject.GetOraBaseById(aProject.GetOraSchemeById(SchemeId).BaseId).Name;
- lblScheme.Caption:= 'Scheme: ' + aProject.GetOraSchemeById(SchemeId).Login;
- btnUpdateClick(nil);
+ lblScheme.Caption:= 'Scheme: ' + aProject.GetOraSchemeById(SchemeId).Login;}
if ShowModal = mrOk then
begin
try
- CurrentProject.WrapItem(aSchemeId, lbxList.Items.Strings[lbxList.ItemIndex], TOraItem.GetItemType(cbxItemType.Items[cbxItemType.ItemIndex]));
+ CurrentProject.WrapItem(aModule.Id, TOraBase(cbxBaseList.Items.Objects[cbxBaseList.ItemIndex]).Id, TOraScheme(cbxSchemeList.Items.Objects[cbxSchemeList.ItemIndex]).Id, lbxList.Items.Strings[lbxList.ItemIndex], TOraItem.GetItemType(cbxItemType.Items[cbxItemType.ItemIndex]));
Result:= true;
except
on E: Exception do
@@ -90,13 +99,19 @@ procedure TfmWrap.btnCloseClick(Sender: TObject);
procedure TfmWrap.btnUpdateClick(Sender: TObject);
begin
- if Assigned(CurrentProject) then
+ if Assigned(CurrentProject) and Assigned(CurrentBase) and Assigned(CurrentScheme) then
begin
- CurrentProject.GetOraSchemeById(SchemeId).Connect(CurrentProject);
- CurrentProject.GetOraSchemeById(SchemeId).GetItemList(TOraItem.GetItemType(cbxItemType.Items[cbxItemType.ItemIndex]), lbxList.Items);
+ CurrentScheme.Connect(CurrentBase.Id);
+ CurrentScheme.GetItemList(TOraItem.GetItemType(cbxItemType.Items[cbxItemType.ItemIndex]), lbxList.Items);
end;
end;
+procedure TfmWrap.cbxBaseListSelect(Sender: TObject);
+begin
+ if (cbxBaseList.Items.Count > 0) and (cbxBaseList.Items.Objects[cbxBaseList.ItemIndex] <> nil) and (TObject(cbxBaseList.Items.Objects[cbxBaseList.ItemIndex]) is TOraBase) then
+ CurrentBase:= TOraBase(cbxBaseList.Items.Objects[cbxBaseList.ItemIndex]);
+end;
+
procedure TfmWrap.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:= caFree;