CreateDirectory.cpp 4.1 KB

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