Skip to content

Commit

Permalink
[M] Edit/Delete base Menu. Scheme create/edit dialogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed May 5, 2016
1 parent e0d1d51 commit 59755df
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 81 deletions.
3 changes: 2 additions & 1 deletion ORDESY.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ uses
uHash in 'uHash.pas',
uWrap in 'uWrap.pas',
uBaseList in 'uBaseList.pas' {fmBaseList},
uSchemeList in 'uSchemeList.pas' {fmSchemeList};
uSchemeList in 'uSchemeList.pas' {fmSchemeList},
uSchemeDialog in 'uSchemeDialog.pas' {fmSchemeDialog};

{$R *.res}

Expand Down
7 changes: 5 additions & 2 deletions ORDESY.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<DCCReference Include="uSchemeList.pas">
<Form>fmSchemeList</Form>
</DCCReference>
<DCCReference Include="uSchemeDialog.pas">
<Form>fmSchemeDialog</Form>
</DCCReference>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down Expand Up @@ -90,7 +93,7 @@
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">866</VersionInfo>
<VersionInfo Name="Build">914</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
Expand All @@ -102,7 +105,7 @@
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.866</VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.914</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
Expand Down
Binary file modified ORDESY.res
Binary file not shown.
2 changes: 1 addition & 1 deletion uMain.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ object fmMain: TfmMain
Height = 347
Align = alClient
TabOrder = 3
object gbInfo: TGroupBox
object gbxInfo: TGroupBox
Left = 1
Top = 1
Width = 330
Expand Down
142 changes: 71 additions & 71 deletions uMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
btn - TButton
pnl - TPanel
lbl - TLabel
gpb - TGroupBox
gbx - TGroupBox
cbx - TComboBox
lbx - TListBox
spl - TSplitter
mmo - TMemo
tv - TTreeView
mm - TMainMenu
mi - TMenuItem
fm - TForm
cbx - TComboBox
lbx - TListBox
}
unit uMain;
Expand All @@ -24,7 +24,8 @@ interface
{$IFDEF Debug}
uLog,
{$ENDIF}
uORDESY, uExplode, uShellFuncs, uProjectDialogs, uOptions, uWrap, uBaseList,
uORDESY, uExplode, uShellFuncs, uOptions, uWrap,
uSchemeDialog, uBaseList, uSchemeList, uProjectDialogs, // Dialogs
// Delphi Modules
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, ComCtrls, ToolWin, ImgList, Buttons;
Expand Down Expand Up @@ -58,7 +59,7 @@ TfmMain = class(TForm)
miBase: TMenuItem;
miBaseList: TMenuItem;
ppmMain: TPopupMenu;
gbInfo: TGroupBox;
gbxInfo: TGroupBox;
edName: TEdit;
lblName: TLabel;
lblDescription: TLabel;
Expand Down Expand Up @@ -90,6 +91,7 @@ TfmMain = class(TForm)
procedure AddBase(Sender: TObject);
procedure OnEditBase(Sender: TObject);
procedure EditBase(aBase: TOraBase);
procedure DeleteBase(Sender: TObject);
procedure tvMainClick(Sender: TObject);
procedure miFileClick(Sender: TObject);
procedure miSavechangesClick(Sender: TObject);
Expand All @@ -114,6 +116,22 @@ implementation

{$R *.dfm}

procedure TfmMain.DeleteBase(Sender: TObject);
var
reply: word;
ProjectList: TORDESYProjectList;
begin
ProjectList:= TORDESYProjectList(TOraBase(tvMain.Selected.Data).ProjectListRef);
reply:= MessageBox(Handle, PChar('Delete base?' + #13#10 + 'Deleting base will affect on all projects.'), PChar('Confirm'), 36);
if reply = IDYES then
begin
ProjectList.RemoveBaseById(TOraBase(tvMain.Selected.Data).Id);
tvMain.Selected.Data:= nil;
tvMain.Deselect(tvMain.Selected);
UpdateGUI;
end;
end;

procedure TfmMain.DeleteModule(Sender: TObject);
var
reply: word;
Expand All @@ -123,9 +141,9 @@ procedure TfmMain.DeleteModule(Sender: TObject);
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;
tvMain.Deselect(tvMain.Selected);
UpdateGUI;
end;
end;
Expand All @@ -139,9 +157,9 @@ 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;
tvMain.Deselect(tvMain.Selected);
UpdateGUI;
end;
end;
Expand Down Expand Up @@ -396,22 +414,54 @@ procedure TfmMain.miSavechangesClick(Sender: TObject);
end;

procedure TfmMain.OnEditBase(Sender: TObject);
var
BaseName: string;
label
retry;
begin
//
try
retry:
BaseName:= TOraBase(tvMain.Selected.Data).Name;
if InputQuery('Edit base', 'Change base name:', BaseName) then
begin
if (BaseName <> '') and (Length(BaseName) <= 255) then
begin
TOraBase(tvMain.Selected.Data).Name:= BaseName;
UpdateGUI;
end
else
goto retry;
end;
except
on E: Exception do
begin
{$IFDEF Debug}
AddToLog(ClassName + ' | AddBase | ' + E.Message);
MessageBox(Application.Handle, PChar(ClassName + ' | AddBase | ' + E.Message), PChar(Application.Title + ' - Error'), 48);
{$ELSE}
MessageBox(Application.Handle, PChar(E.Message), PChar(Application.Title + ' - Error'), 48);
{$ENDIF}
end;
end;
end;

procedure TfmMain.AddBase(Sender: TObject);
var
BaseName: string;
label
retry;
begin
try
retry:
if InputQuery('Add base', 'Enter base name:', BaseName) then
begin
if (BaseName <> '') and (Length(BaseName) <= 255) then
begin
ProjectList.AddOraBase(TOraBase.Create(ProjectList ,ProjectList.GetFreeBaseId, BaseName));
UpdateGUI;
end;
end
else
goto retry;
end;
except
on E: Exception do
Expand All @@ -431,15 +481,15 @@ function TfmMain.CanPopup(const aTag: integer; aObject: Pointer): boolean;
Result:= false;
if aObject <> nil then
begin
if (TObject(aObject) is TORDESYProject) and (aTag >= 0) and (aTag <= 10) then
if (TObject(aObject) is TORDESYProject) and (aTag >= 1) and (aTag <= 10) or (aTag = 0) then
Result:= true;
if (TObject(aObject) is TORDESYModule) and (aTag >= 5) and (aTag <= 15) then
if (TObject(aObject) is TORDESYModule) and (aTag >= 5) and (aTag <= 15) or (aTag = 0) then
Result:= true;
if (TObject(aObject) is TOraBase) and (aTag >= 10) and (aTag <= 20) then
if (TObject(aObject) is TOraBase) and (aTag >= 10) and (aTag <= 20) or (aTag = 0) then
Result:= true;
if (TObject(aObject) is TOraScheme) and (aTag >= 15) and (aTag <= 25) then
if (TObject(aObject) is TOraScheme) and (aTag >= 15) and (aTag <= 25) or (aTag = 0) then
Result:= True;
if (TObject(aObject) is TOraItem) and (aTag >= 20) and (aTag <= 30) then
if (TObject(aObject) is TOraItem) and (aTag >= 20) and (aTag <= 30) or (aTag = 0) then
Result:= true;
end
else
Expand Down Expand Up @@ -544,66 +594,16 @@ procedure TfmMain.PrepareGUI;
BaseMenu.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= EditBase;
MenuItem.OnClick:= OnEditBase;
MenuItem.Caption:= 'Edit base';
MenuItem.Tag:= 16;
BaseMenu.Add(MenuItem);
// -----------------------------------------Module popup 11-20
{MenuItem:= TMenuItem.Create(ppmMain);
MenuItem.OnClick:= AddModule;
MenuItem.Caption:= 'Add base';
MenuItem.Tag:= 11;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);}
// -----------------------------------------Base popup 21-30
{MenuItem:= TMenuItem.Create(ppmMain);
MenuItem.OnClick:= AddBase;
MenuItem.Caption:= 'Add base';
MenuItem.Tag:= 21;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= miCreateProject.OnClick;
MenuItem.Caption:= 'Edit base';
MenuItem.Tag:= 22;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= miCreateProject.OnClick;
MenuItem.Caption:= 'Delete base';
MenuItem.Tag:= 23;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);}
// -----------------------------------------Scheme popup 31-40
{MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= miCreateProject.OnClick;
MenuItem.Caption:= 'Add scheme';
MenuItem.Tag:= 31;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= EditScheme
MenuItem.Caption:= 'Edit scheme';
MenuItem.Tag:= 32;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
MenuItem.OnClick:= WrapItem;
MenuItem.Caption:= 'Wrap item';
MenuItem.Tag:= 33;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);
//
MenuItem:= TMenuItem.Create(ppmMain);
//MenuItem.OnClick:= EditScheme
MenuItem.Caption:= 'Delete scheme';
MenuItem.Tag:= 34;
MenuItem.Visible:= false;
ppmMain.Items.Add(MenuItem);}
//
MenuItem:= TMenuItem.Create(ppmMain);
MenuItem.OnClick:= DeleteBase;
MenuItem.Caption:= 'Delete base';
MenuItem.Tag:= 16;
BaseMenu.Add(MenuItem);
except
on E: Exception do
begin
Expand Down
4 changes: 2 additions & 2 deletions uProjectDialogs.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object fmProjectCreate: TfmProjectCreate
Anchors = [akLeft, akBottom]
Caption = 'Date:'
end
object gpbProjectName: TGroupBox
object gbxProjectName: TGroupBox
Left = 0
Top = 0
Width = 414
Expand All @@ -81,7 +81,7 @@ object fmProjectCreate: TfmProjectCreate
TabOrder = 0
end
end
object gpbDescription: TGroupBox
object gbxDescription: TGroupBox
Left = 0
Top = 49
Width = 414
Expand Down
8 changes: 4 additions & 4 deletions uProjectDialogs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ interface
type
TfmProjectCreate = class(TForm)
pnlMain: TPanel;
gpbProjectName: TGroupBox;
gbxProjectName: TGroupBox;
edtProjectName: TEdit;
gpbDescription: TGroupBox;
gbxDescription: TGroupBox;
mmDescription: TMemo;
lblCreatorHead: TLabel;
lblCreator: TLabel;
Expand All @@ -25,7 +25,7 @@ TfmProjectCreate = class(TForm)
procedure btnCreateClick(Sender: TObject);
end;

function ShowProjectCreateDialog(const aCreator: string; var aProjectList: TORDESYProjectList): boolean;
function ShowProjectCreateDialog(const aCreator: string; aProjectList: TORDESYProjectList): boolean;
function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
function ShowModuleCreateDialog(aProject: TORDESYProject): boolean;
function ShowModuleEditDialog(aModule: TORDESYModule): boolean;
Expand All @@ -34,7 +34,7 @@ implementation

{$R *.dfm}

function ShowProjectCreateDialog(const aCreator: string; var aProjectList: TORDESYProjectList): boolean;
function ShowProjectCreateDialog(const aCreator: string; aProjectList: TORDESYProjectList): boolean;
var
dTimer: TTimer;
begin
Expand Down
Loading

0 comments on commit 59755df

Please sign in to comment.