CreateDirectory.cpp 4.1 KB

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