newvaluedlg.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. // newvaluedlg.cpp : implementation file
  14. //
  15. #include "stdafx.h"
  16. #include "treeview.h"
  17. #include "newvaluedlg.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CNewValueDlg dialog
  25. CNewValueDlg::CNewValueDlg(NewValue_t nvt, LPCSTR initName, LPCSTR initValue, CWnd* pParent) : CDialog(CNewValueDlg::IDD, pParent)
  26. {
  27. //{{AFX_DATA_INIT(CNewValueDlg)
  28. // NOTE: the ClassWizard will add member initialization here
  29. //}}AFX_DATA_INIT
  30. NewValueType = nvt;
  31. Name = initName;
  32. Value = initValue;
  33. }
  34. void CNewValueDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CNewValueDlg)
  38. // NOTE: the ClassWizard will add DDX and DDV calls here
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CNewValueDlg, CDialog)
  42. //{{AFX_MSG_MAP(CNewValueDlg)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CNewValueDlg message handlers
  47. BOOL CNewValueDlg::OnInitDialog()
  48. {
  49. CDialog::OnInitDialog();
  50. switch(NewValueType)
  51. {
  52. case NVT_property: SetWindowText("New Property Details"); break;
  53. case NVT_attribute: SetWindowText("New Attribute Details"); break;
  54. }
  55. CEdit * edt = static_cast <CEdit *> (GetDlgItem(IDC_NEWNAMEEDIT));
  56. edt->SetWindowText(Name);
  57. edt = static_cast <CEdit *> (GetDlgItem(IDC_NEWVALUEEDIT));
  58. edt->SetWindowText(Value);
  59. return TRUE;
  60. }
  61. LPCSTR CNewValueDlg::GetName()
  62. {
  63. return Name;
  64. }
  65. LPCSTR CNewValueDlg::GetValue()
  66. {
  67. return Value;
  68. }
  69. void CNewValueDlg::OnOK()
  70. {
  71. CEdit * edt = static_cast <CEdit *> (GetDlgItem(IDC_NEWNAMEEDIT));
  72. edt->GetWindowText(Name);
  73. edt = static_cast <CEdit *> (GetDlgItem(IDC_NEWVALUEEDIT));
  74. edt->GetWindowText(Value);
  75. if(Validate())
  76. {
  77. CDialog::OnOK();
  78. }
  79. }
  80. bool CNewValueDlg::Validate()
  81. {
  82. if(!Name.GetLength())
  83. {
  84. MessageBox(NewValueType == NVT_property ? "A property must have a name" : "An attribute must have a name", "Name Required", MB_OK);
  85. return false;
  86. }
  87. return true;
  88. }