From 59755dff26a1dfeba3b12bae91ed8cb7a7585d2d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 May 2016 16:48:40 +0300 Subject: [PATCH] [M] Edit/Delete base Menu. Scheme create/edit dialogs. --- ORDESY.dpr | 3 +- ORDESY.dproj | 7 ++- ORDESY.res | Bin 5944 -> 5944 bytes uMain.dfm | 2 +- uMain.pas | 142 ++++++++++++++++++++++---------------------- uProjectDialogs.dfm | 4 +- uProjectDialogs.pas | 8 +-- uSchemeDialog.dfm | 112 ++++++++++++++++++++++++++++++++++ uSchemeDialog.pas | 85 ++++++++++++++++++++++++++ 9 files changed, 282 insertions(+), 81 deletions(-) create mode 100644 uSchemeDialog.dfm create mode 100644 uSchemeDialog.pas diff --git a/ORDESY.dpr b/ORDESY.dpr index 9a4828c..b75e9c1 100644 --- a/ORDESY.dpr +++ b/ORDESY.dpr @@ -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} diff --git a/ORDESY.dproj b/ORDESY.dproj index 1d1d576..c82731d 100644 --- a/ORDESY.dproj +++ b/ORDESY.dproj @@ -58,6 +58,9 @@
fmSchemeList
+ +
fmSchemeDialog
+
Base @@ -90,7 +93,7 @@ 1 0 0 - 866 + 914 False False False @@ -102,7 +105,7 @@ - 1.0.0.866 + 1.0.0.914 diff --git a/ORDESY.res b/ORDESY.res index 02fc91873fc1dd7a281aa42f805fd28edbed78e0..3c5f1c4647e53652d408b7786a96c36615d07ff6 100644 GIT binary patch delta 32 ncmdm?w?l8k7ZJ`$%nU%l$S`U0Uy '') 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 @@ -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 @@ -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 diff --git a/uProjectDialogs.dfm b/uProjectDialogs.dfm index 24cddf9..4db93a8 100644 --- a/uProjectDialogs.dfm +++ b/uProjectDialogs.dfm @@ -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 @@ -81,7 +81,7 @@ object fmProjectCreate: TfmProjectCreate TabOrder = 0 end end - object gpbDescription: TGroupBox + object gbxDescription: TGroupBox Left = 0 Top = 49 Width = 414 diff --git a/uProjectDialogs.pas b/uProjectDialogs.pas index 7d5bbdf..d7d36e8 100644 --- a/uProjectDialogs.pas +++ b/uProjectDialogs.pas @@ -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; @@ -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; @@ -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 diff --git a/uSchemeDialog.dfm b/uSchemeDialog.dfm new file mode 100644 index 0000000..6cd595d --- /dev/null +++ b/uSchemeDialog.dfm @@ -0,0 +1,112 @@ +object fmSchemeDialog: TfmSchemeDialog + Left = 0 + Top = 0 + BorderStyle = bsSizeToolWin + Caption = 'Add scheme' + ClientHeight = 138 + ClientWidth = 214 + Color = clBtnFace + Constraints.MinHeight = 162 + Constraints.MinWidth = 222 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poMainFormCenter + OnClose = FormClose + PixelsPerInch = 96 + TextHeight = 13 + object pnlMain: TPanel + Left = 0 + Top = 0 + Width = 214 + Height = 138 + Align = alClient + BevelOuter = bvNone + TabOrder = 0 + ExplicitHeight = 168 + DesignSize = ( + 214 + 138) + object gbxLogin: TGroupBox + Left = 0 + Top = 0 + Width = 214 + Height = 49 + Align = alTop + Caption = 'Login:' + TabOrder = 0 + ExplicitWidth = 426 + DesignSize = ( + 214 + 49) + object edtLogin: TEdit + Left = 7 + Top = 17 + Width = 200 + Height = 24 + Anchors = [akLeft, akTop, akRight] + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + ExplicitWidth = 234 + end + end + object gbxPass: TGroupBox + Left = 0 + Top = 49 + Width = 214 + Height = 49 + Align = alTop + Caption = 'Password:' + TabOrder = 1 + ExplicitLeft = 2 + ExplicitTop = 15 + ExplicitWidth = 230 + DesignSize = ( + 214 + 49) + object edtPass: TEdit + Left = 7 + Top = 17 + Width = 200 + Height = 24 + Anchors = [akLeft, akTop, akRight] + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + Font.Style = [] + ParentFont = False + TabOrder = 0 + end + end + object btnCancel: TButton + Left = 16 + Top = 104 + Width = 75 + Height = 25 + Anchors = [akRight, akBottom] + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 2 + end + object btnSave: TButton + Left = 120 + Top = 104 + Width = 75 + Height = 25 + Anchors = [akRight, akBottom] + Caption = 'Save' + ModalResult = 1 + TabOrder = 3 + OnClick = btnSaveClick + end + end +end diff --git a/uSchemeDialog.pas b/uSchemeDialog.pas new file mode 100644 index 0000000..fbb5521 --- /dev/null +++ b/uSchemeDialog.pas @@ -0,0 +1,85 @@ +unit uSchemeDialog; + +interface + +uses + // ORDESY Modules + {$IFDEF Debug} + uLog, + {$ENDIF} + uORDESY, + // Delphi Modules + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, ExtCtrls; + +type + TfmSchemeDialog = class(TForm) + pnlMain: TPanel; + gbxLogin: TGroupBox; + gbxPass: TGroupBox; + edtPass: TEdit; + edtLogin: TEdit; + btnCancel: TButton; + btnSave: TButton; + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure btnSaveClick(Sender: TObject); + end; + +function ShowSchemeCreateDialog(aProjectList: TORDESYProjectList): boolean; +function ShowSchemeEditDialog(aScheme: TOraScheme): boolean; + +implementation + +{$R *.dfm} + +function ShowSchemeCreateDialog(aProjectList: TORDESYProjectList): boolean; +begin + with TfmSchemeDialog.Create(Application) do + try + Caption:= 'Add scheme'; + if ShowModal = mrOk then + begin + aProjectList.AddOraScheme(TOraScheme.Create(aProjectList, aProjectList.GetFreeSchemeId, edtLogin.Text, edtPass.Text)); + end; + finally + Free; + end; +end; + +function ShowSchemeEditDialog(aScheme: TOraScheme): boolean; +begin + with TfmSchemeDialog.Create(Application) do + try + Caption:= 'Edit scheme'; + edtLogin.Text:= aScheme.Login; + edtPass.Text:= aScheme.Pass; + if ShowModal = mrOk then + begin + aScheme.Login:= edtLogin.Text; + aScheme.Pass:= edtPass.Text; + end; + finally + Free; + end; +end; + +procedure TfmSchemeDialog.btnSaveClick(Sender: TObject); +begin + if (edtLogin.Text = '') or (Length(edtLogin.Text) > 255) then + begin + ModalResult:= mrNone; + raise Exception.Create('Incorrect scheme name, empty or more than 255 characters!'); + end; + if (Length(edtPass.Text) > 255) then + begin + ModalResult:= mrNone; + raise Exception.Create('Incorrect scheme password, more than 255 characters!'); + end; +end; + +procedure TfmSchemeDialog.FormClose(Sender: TObject; var Action: TCloseAction); +begin + Action:= caFree; +end; + +end.