CreateDirectory.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //---------------------------------------------------------------------
  2. #include <FormsPCH.h>
  3. #pragma hdrstop
  4. #include <RemoteFiles.h>
  5. #include "CreateDirectory.h"
  6. //---------------------------------------------------------------------
  7. #pragma link "Rights"
  8. #pragma resource "*.dfm"
  9. //---------------------------------------------------------------------
  10. bool __fastcall DoCreateDirectoryDialog(UnicodeString & Directory,
  11. TRemoteProperties * Properties, int AllowedChanges, bool & SaveSettings)
  12. {
  13. bool Result;
  14. TCreateDirectoryDialog * Dialog = new TCreateDirectoryDialog(Application, AllowedChanges, (Properties != NULL));
  15. try
  16. {
  17. Result = Dialog->Execute(Directory, Properties, SaveSettings);
  18. }
  19. __finally
  20. {
  21. delete Dialog;
  22. }
  23. return Result;
  24. }
  25. //---------------------------------------------------------------------
  26. __fastcall TCreateDirectoryDialog::TCreateDirectoryDialog(TComponent * AOwner, int AllowedChanges, bool Remote):
  27. TForm(AOwner)
  28. {
  29. UseSystemSettings(this);
  30. RightsFrame->AllowAddXToDirectories = false;
  31. FAllowedChanges = AllowedChanges;
  32. if (!Remote)
  33. {
  34. AttributesGroup->Visible = false;
  35. ClientHeight = ClientHeight - AttributesGroup->Height;
  36. }
  37. }
  38. //---------------------------------------------------------------------
  39. __fastcall TCreateDirectoryDialog::~TCreateDirectoryDialog()
  40. {
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TCreateDirectoryDialog::ControlChange(TObject * /*Sender*/)
  44. {
  45. UpdateControls();
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TCreateDirectoryDialog::UpdateControls()
  49. {
  50. EnableControl(OKBtn, !DirectoryEdit->Text.Trim().IsEmpty());
  51. EnableControl(SetRightsCheck, FLAGSET(FAllowedChanges, cpMode));
  52. EnableControl(RightsFrame, SetRightsCheck->Enabled && SetRightsCheck->Checked);
  53. EnableControl(SaveSettingsCheck, (FAllowedChanges != 0));
  54. }
  55. //---------------------------------------------------------------------------
  56. bool __fastcall TCreateDirectoryDialog::Execute(UnicodeString & Directory,
  57. TRemoteProperties * Properties, bool & SaveSettings)
  58. {
  59. DirectoryEdit->Text = Directory;
  60. SaveSettingsCheck->Checked = SaveSettings;
  61. if (Properties != NULL)
  62. {
  63. bool SetRights = Properties->Valid.Contains(vpRights);
  64. SetRightsCheck->Checked = SetRights;
  65. // expect sensible value even if rights are not set valid
  66. RightsFrame->Rights = Properties->Rights;
  67. }
  68. bool Result = (ShowModal() == DefaultResult(this));
  69. if (Result)
  70. {
  71. Directory = DirectoryEdit->Text;
  72. SaveSettings = SaveSettingsCheck->Checked;
  73. if (Properties != NULL)
  74. {
  75. if (SetRightsCheck->Enabled && SetRightsCheck->Checked)
  76. {
  77. Properties->Valid = Properties->Valid << vpRights;
  78. Properties->Rights = RightsFrame->Rights;
  79. }
  80. else
  81. {
  82. Properties->Valid = Properties->Valid >> vpRights;
  83. }
  84. }
  85. }
  86. return Result;
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TCreateDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  90. {
  91. UpdateControls();
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TCreateDirectoryDialog::FormShow(TObject * /*Sender*/)
  95. {
  96. InstallPathWordBreakProc(DirectoryEdit);
  97. UpdateControls();
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TCreateDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  101. {
  102. FormHelp(this);
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TCreateDirectoryDialog::FormCloseQuery(TObject * /*Sender*/,
  106. bool & /*CanClose*/)
  107. {
  108. if (ModalResult == DefaultResult(this))
  109. {
  110. ExitActiveControl(this);
  111. }
  112. }
  113. //---------------------------------------------------------------------------