CreateDirectory.cpp 4.1 KB

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