NonVisual.cpp 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "NonVisual.h"
  5. #include <Common.h>
  6. #include <CoreMain.h>
  7. #include <TextsWin.h>
  8. #include <Tools.h>
  9. #include <Setup.h>
  10. #include <Log.h>
  11. #include <Interface.h>
  12. #include "WinConfiguration.h"
  13. #include "TerminalManager.h"
  14. #include "TBX.hpp"
  15. #include "VCLCommon.h"
  16. #include <HistoryComboBox.hpp>
  17. //---------------------------------------------------------------------------
  18. #pragma package(smart_init)
  19. #pragma link "TB2Item"
  20. #pragma link "TBX"
  21. #pragma link "TB2ExtItems"
  22. #pragma link "TBXExtItems"
  23. #pragma link "TBXToolPals"
  24. #ifndef NO_RESOURCES
  25. #pragma resource "*.dfm"
  26. #endif
  27. TNonVisualDataModule *NonVisualDataModule;
  28. //---------------------------------------------------------------------------
  29. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  30. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  31. ((TCustomAction *)Action)->Enabled = (Condition); \
  32. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  33. Handled = true; } else
  34. #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
  35. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  36. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  37. #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
  38. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  39. Command; Handled = true; } else
  40. #define UPDACT(HandleAction, Command) \
  41. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  42. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  43. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  44. #define EXECOMP(COMP) EXE(COMP ## Action, \
  45. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  46. #define COLPROPS(SIDE) \
  47. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  48. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  49. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  50. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  51. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  52. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  53. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  54. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  55. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  56. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  57. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  58. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  59. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  60. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  61. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  62. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  63. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  64. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  65. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  66. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  67. #define EXESORTC(COL, LCOL, RCOL) \
  68. EXE(CurrentSortBy ## COL ## Action, \
  69. Integer NewSortCol = \
  70. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  71. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  72. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  73. else COLPROPS(Current)->SortColumn = NewSortCol \
  74. )
  75. #define UPDSHCOL(SIDE, PREFIX, COL) \
  76. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  77. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  78. #define EXESHCOL(SIDE, PREFIX, COL) \
  79. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  80. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  81. //---------------------------------------------------------------------------
  82. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  83. : TDataModule(Owner)
  84. {
  85. FListColumn = NULL;
  86. FSessionIdleTimerExecuting = false;
  87. FBusy = 0;
  88. QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
  89. }
  90. //---------------------------------------------------------------------------
  91. __fastcall TNonVisualDataModule::~TNonVisualDataModule()
  92. {
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TNonVisualDataModule::LogActionsUpdate(
  96. TBasicAction *Action, bool &Handled)
  97. {
  98. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  99. bool ValidLogMemo = LogMemo && LogMemo->Parent;
  100. UPD(LogClearAction, ValidLogMemo && LogMemo->Lines->Count)
  101. // removed potentially CPU intensive check for "all selected already"
  102. UPD(LogSelectAllAction, ValidLogMemo && LogMemo->Lines->Count)
  103. UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)
  104. UPD(LogPreferencesAction, true)
  105. ;
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TNonVisualDataModule::LogActionsExecute(
  109. TBasicAction *Action, bool &Handled)
  110. {
  111. {
  112. TAutoNestingCounter Counter(FBusy);
  113. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  114. assert(LogMemo && LogMemo->Parent);
  115. EXE(LogClearAction, LogMemo->SessionLog->Clear())
  116. EXE(LogSelectAllAction, LogMemo->SelectAll())
  117. EXE(LogCopyAction, LogMemo->CopyToClipboard())
  118. EXE(LogPreferencesAction, PreferencesDialog(pmLogging));
  119. ;
  120. }
  121. DoIdle();
  122. }
  123. //---------------------------------------------------------------------------
  124. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  125. TBasicAction *Action, bool &Handled)
  126. {
  127. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  128. {
  129. ((TAction *)Action)->Enabled = false;
  130. Handled = true;
  131. return;
  132. }
  133. void * Param;
  134. // CURRENT DIRVIEW
  135. #define EnabledSelectedOperation (ScpExplorer->EnableSelectedOperation[osCurrent])
  136. #define EnabledFocusedOperation (ScpExplorer->EnableFocusedOperation[osCurrent])
  137. #define EnabledSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osCurrent])
  138. #define EnabledFocusedFileOperation (ScpExplorer->EnableFocusedFileOperation[osCurrent])
  139. #define EnabledLocalSelectedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  140. #define EnabledLocalFocusedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableFocusedOperation[osLocal])
  141. #define EnabledLocalSelectedFileOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedFileOperation[osLocal])
  142. #define EnabledRemoteSelectedOperation (ScpExplorer->EnableSelectedOperation[osRemote])
  143. #define EnabledRemoteFocusedOperation (ScpExplorer->EnableFocusedOperation[osRemote])
  144. #define EnabledRemoteSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osRemote])
  145. // focused operation
  146. UPD(CurrentDeleteFocusedAction, EnabledFocusedOperation)
  147. UPD(CurrentPropertiesFocusedAction, EnabledFocusedOperation)
  148. UPD(CurrentEditFocusedAction, EnabledFocusedFileOperation &&
  149. !WinConfiguration->DisableOpenEdit)
  150. UPD(CurrentSystemMenuFocusedAction, EnabledFocusedOperation)
  151. UPD(CurrentEditWithFocusedAction, EnabledFocusedFileOperation &&
  152. !WinConfiguration->DisableOpenEdit)
  153. UPD(CurrentEditAlternativeFocusedAction, EnabledFocusedFileOperation &&
  154. !WinConfiguration->DisableOpenEdit)
  155. UPD(CurrentEditInternalFocusedAction, EnabledFocusedFileOperation &&
  156. !WinConfiguration->DisableOpenEdit)
  157. // file operation
  158. UPD(CurrentRenameAction, EnabledFocusedOperation &&
  159. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  160. ScpExplorer->Terminal->IsCapable[fcRename]))
  161. UPD(CurrentEditAction, EnabledSelectedFileOperation &&
  162. !WinConfiguration->DisableOpenEdit)
  163. UPD(CurrentEditAlternative2Action, EnabledSelectedFileOperation &&
  164. !WinConfiguration->DisableOpenEdit)
  165. UPD(CurrentEditInternalAction, EnabledSelectedFileOperation &&
  166. !WinConfiguration->DisableOpenEdit)
  167. UPD(CurrentEditWithAction, EnabledSelectedFileOperation &&
  168. !WinConfiguration->DisableOpenEdit)
  169. UPD(CurrentOpenAction, EnabledFocusedOperation &&
  170. !WinConfiguration->DisableOpenEdit)
  171. UPDEX1(CurrentAddEditLinkContextAction, ScpExplorer->CanAddEditLink(osCurrent),
  172. ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())
  173. UPD(NewLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  174. // selected operation
  175. UPD(CurrentDeleteAction, EnabledSelectedOperation)
  176. UPD(CurrentDeleteAlternativeAction, EnabledSelectedOperation)
  177. UPD(CurrentPropertiesAction, EnabledSelectedOperation)
  178. UPD(RemoteMoveToAction, EnabledSelectedOperation &&
  179. (DirView(osRemote) == DirView(osCurrent)) &&
  180. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  181. UPD(RemoteCopyToAction, EnabledSelectedOperation &&
  182. (DirView(osRemote) == DirView(osCurrent)))
  183. UPD(FileListToCommandLineAction, EnabledSelectedOperation)
  184. UPD(FileListToClipboardAction, EnabledSelectedOperation)
  185. UPD(FullFileListToClipboardAction, EnabledSelectedOperation)
  186. UPD(FileGenerateUrlAction, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  187. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT));
  188. UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  189. // local selected operation
  190. UPD(LocalCopyAction, EnabledLocalSelectedOperation)
  191. UPD(LocalRenameAction, EnabledLocalSelectedOperation)
  192. UPD(LocalEditAction, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  193. UPD(LocalMoveAction, EnabledLocalSelectedOperation)
  194. UPD(LocalCreateDirAction, true)
  195. UPD(LocalDeleteAction, EnabledLocalSelectedOperation)
  196. UPD(LocalPropertiesAction, EnabledLocalSelectedOperation)
  197. UPD(LocalAddEditLinkAction, ScpExplorer->CanAddEditLink(osLocal))
  198. // local focused operation
  199. UPD(LocalCopyFocusedAction, EnabledLocalFocusedOperation)
  200. UPD(LocalMoveFocusedAction, EnabledLocalFocusedOperation)
  201. // remote selected operation
  202. UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)
  203. UPD(RemoteRenameAction, EnabledRemoteSelectedOperation &&
  204. ScpExplorer->Terminal->IsCapable[fcRename])
  205. UPD(RemoteEditAction, EnabledRemoteSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  206. UPD(RemoteMoveAction, EnabledRemoteSelectedOperation)
  207. UPD(RemoteCreateDirAction, true)
  208. UPD(RemoteDeleteAction, EnabledRemoteSelectedOperation)
  209. UPD(RemotePropertiesAction, EnabledRemoteSelectedOperation)
  210. UPD(RemoteAddEditLinkAction, ScpExplorer->CanAddEditLink(osRemote))
  211. // remote focused operation
  212. UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)
  213. UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)
  214. UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&
  215. (DirView(osRemote) == DirView(osCurrent)) &&
  216. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  217. UPD(RemoteCopyToFocusedAction, EnabledFocusedOperation &&
  218. DirView(osRemote) == DirView(osCurrent))
  219. // directory
  220. UPD(CurrentCreateDirAction, true)
  221. UPD(NewDirAction, true)
  222. UPD(RemoteFindFilesAction, true)
  223. // selection
  224. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  225. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  226. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  227. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  228. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  229. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  230. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  231. UPD(PasteAction2, ScpExplorer->CanPasteFromClipBoard())
  232. UPD(LocalSelectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  233. UPD(LocalUnselectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount)
  234. UPD(LocalSelectAllAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  235. UPD(RemoteSelectAction, DirView(osRemote)->FilesCount)
  236. UPD(RemoteUnselectAction, DirView(osRemote)->SelCount)
  237. UPD(RemoteSelectAllAction, DirView(osRemote)->FilesCount)
  238. //style
  239. UPDACT(CurrentCycleStyleAction,
  240. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  241. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  242. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  243. STYLEACTION(Icon)
  244. STYLEACTION(SmallIcon)
  245. STYLEACTION(List)
  246. STYLEACTION(Report)
  247. #undef STYLEACTION
  248. // REMOTE+LOCAL
  249. // back/forward
  250. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  251. UPDEX(SIDE ## DIRECTION ## Action, (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  252. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  253. SIDE ## DIRECTION ## Action->Hint = L"")
  254. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  255. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  256. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  257. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  258. #undef HISTORYACTION
  259. #define PANEL_ACTIONS(SIDE) \
  260. UPD(SIDE ## ParentDirAction, !DirView(os ## SIDE)->IsRoot) \
  261. UPD(SIDE ## RootDirAction, !DirView(os ## SIDE)->IsRoot) \
  262. UPD(SIDE ## HomeDirAction, true) \
  263. UPD(SIDE ## RefreshAction, DirView(os ## SIDE)->DirOK) \
  264. UPD(SIDE ## OpenDirAction, true) \
  265. UPD(SIDE ## ChangePathAction, true) \
  266. UPD(SIDE ## AddBookmarkAction, true) \
  267. UPD(SIDE ## PathToClipboardAction, true) \
  268. UPDEX1(SIDE ## FilterAction, true, ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())
  269. PANEL_ACTIONS(Local)
  270. PANEL_ACTIONS(Remote)
  271. #undef PANEL_ACTIONS
  272. UPD(LocalExploreDirectoryAction, true)
  273. // HELP
  274. UPD(AboutAction, true)
  275. UPD(HomepageAction, true)
  276. UPD(HistoryPageAction, true)
  277. UPD(TableOfContentsAction, true)
  278. UPD(ForumPageAction, true)
  279. UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate())
  280. UPD(UpdatesPreferencesAction, true)
  281. UPD(DonatePageAction, true)
  282. UPD(DownloadPageAction, true)
  283. // VIEW
  284. UPDCOMP(SessionsTabs)
  285. UPDCOMP(StatusBar)
  286. UPDCOMP(ToolBar2)
  287. UPDCOMP(LocalStatusBar)
  288. UPDCOMP(RemoteStatusBar)
  289. UPDCOMP(CommandLinePanel)
  290. UPDCOMP(RemoteTree)
  291. UPDCOMP(LocalTree)
  292. UPDCOMP(ExplorerMenuBand)
  293. UPDCOMP(ExplorerAddressBand)
  294. UPDCOMP(ExplorerToolbarBand)
  295. UPDCOMP(ExplorerSelectionBand)
  296. UPDCOMP(ExplorerSessionBand)
  297. UPDCOMP(ExplorerPreferencesBand)
  298. UPDCOMP(ExplorerSortBand)
  299. UPDCOMP(ExplorerUpdatesBand)
  300. UPDCOMP(ExplorerTransferBand)
  301. UPDCOMP(ExplorerCustomCommandsBand)
  302. UPDCOMP(CommanderMenuBand)
  303. UPDCOMP(CommanderSessionBand)
  304. UPDCOMP(CommanderPreferencesBand)
  305. UPDCOMP(CommanderSortBand)
  306. UPDCOMP(CommanderCommandsBand)
  307. UPDCOMP(CommanderUpdatesBand)
  308. UPDCOMP(CommanderTransferBand)
  309. UPDCOMP(CommanderCustomCommandsBand)
  310. UPDCOMP(CommanderLocalHistoryBand)
  311. UPDCOMP(CommanderLocalNavigationBand)
  312. UPDCOMP(CommanderLocalFileBand)
  313. UPDCOMP(CommanderLocalSelectionBand)
  314. UPDCOMP(CommanderRemoteHistoryBand)
  315. UPDCOMP(CommanderRemoteNavigationBand)
  316. UPDCOMP(CommanderRemoteFileBand)
  317. UPDCOMP(CommanderRemoteSelectionBand)
  318. UPD(GoToCommandLineAction, true)
  319. UPD(GoToTreeAction, true)
  320. UPDEX(ViewLogAction, Configuration->Logging,
  321. ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),
  322. ViewLogAction->Checked = false )
  323. UPDEX(ShowHiddenFilesAction, true,
  324. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  325. UPDEX(FormatSizeBytesNoneAction, true,
  326. FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), )
  327. UPDEX(FormatSizeBytesKilobytesAction, true,
  328. FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), )
  329. UPDEX(FormatSizeBytesShortAction, true,
  330. FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), )
  331. UPDEX(AutoReadDirectoryAfterOpAction, true,
  332. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  333. UPD(PreferencesAction, true)
  334. UPD(PresetsPreferencesAction, true)
  335. UPDEX(LockToolbarsAction, true,
  336. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  337. UPDEX(SelectiveToolbarTextAction, true,
  338. SelectiveToolbarTextAction->Checked = WinConfiguration->SelectiveToolbarText, )
  339. UPDCOMP(CustomCommandsBand)
  340. UPD(ColorMenuAction, true)
  341. // SORT
  342. UPDSORTA(Local)
  343. UPDSORT(Local, dv, Name)
  344. UPDSORT(Local, dv, Ext)
  345. UPDSORT(Local, dv, Size)
  346. UPDSORT(Local, dv, Type)
  347. UPDSORT(Local, dv, Changed)
  348. UPDSORT(Local, dv, Attr)
  349. UPDSORTA(Remote)
  350. UPDSORT(Remote, uv, Name)
  351. UPDSORT(Remote, uv, Ext)
  352. UPDSORT(Remote, uv, Size)
  353. UPDSORT(Remote, uv, Changed)
  354. UPDSORT(Remote, uv, Rights)
  355. UPDSORT(Remote, uv, Owner)
  356. UPDSORT(Remote, uv, Group)
  357. UPDSORT(Remote, uv, Type)
  358. UPDSORTA(Current)
  359. UPDSORTC(dv, Name, uv, Name)
  360. UPDSORTC(dv, Ext, uv, Ext)
  361. UPDSORTC(dv, Size, uv, Size)
  362. UPDSORTC(dv, Type, uv, Type)
  363. UPDSORTC(dv, Changed, uv, Changed)
  364. UPDSORTC(dv, Attr, uv, Rights)
  365. UPDSORTC(dv, Name, uv, Owner)
  366. UPDSORTC(dv, Name, uv, Group)
  367. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  368. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  369. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  370. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  371. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  372. #undef COLVIEWPROPS
  373. // SHOW/HIDE COLUMN
  374. UPDSHCOL(Local, dv, Name)
  375. UPDSHCOL(Local, dv, Ext)
  376. UPDSHCOL(Local, dv, Size)
  377. UPDSHCOL(Local, dv, Type)
  378. UPDSHCOL(Local, dv, Changed)
  379. UPDSHCOL(Local, dv, Attr)
  380. UPDSHCOL(Remote, uv, Name)
  381. UPDSHCOL(Remote, uv, Ext)
  382. UPDSHCOL(Remote, uv, Size)
  383. UPDSHCOL(Remote, uv, Changed)
  384. UPDSHCOL(Remote, uv, Rights)
  385. UPDSHCOL(Remote, uv, Owner)
  386. UPDSHCOL(Remote, uv, Group)
  387. UPDSHCOL(Remote, uv, LinkTarget)
  388. UPDSHCOL(Remote, uv, Type)
  389. UPD(HideColumnAction, (ListColumn != NULL))
  390. UPD(BestFitColumnAction, (ListColumn != NULL))
  391. // SESSION
  392. UPD(NewSessionAction, true)
  393. UPD(SiteManagerAction, true)
  394. UPD(DuplicateSessionAction, true)
  395. UPD(CloseSessionAction, true)
  396. UPD(SavedSessionsAction2, true)
  397. UPD(WorkspacesAction, StoredSessions->HasAnyWorkspace())
  398. UPD(OpenedSessionsAction, true)
  399. UPD(SaveCurrentSessionAction2, true)
  400. UPD(SaveWorkspaceAction, true)
  401. // COMMAND
  402. UPD(CompareDirectoriesAction, true)
  403. UPD(SynchronizeAction, true)
  404. UPD(FullSynchronizeAction, true)
  405. UPD(ConsoleAction, ScpExplorer->Terminal->IsCapable[fcAnyCommand] || ScpExplorer->Terminal->IsCapable[fcSecondaryShell])
  406. UPD(PuttyAction, TTerminalManager::Instance()->CanOpenInPutty())
  407. UPD(SynchronizeBrowsingAction, true)
  408. UPD(CloseApplicationAction, true)
  409. UPD(FileSystemInfoAction, true)
  410. UPD(SessionGenerateUrlAction, true)
  411. UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
  412. UPD(NewFileAction, !WinConfiguration->DisableOpenEdit)
  413. UPD(EditorListCustomizeAction, true)
  414. // CUSTOM COMMANDS
  415. UPD(CustomCommandsAction, true)
  416. UPD(CustomCommandsEnterAction, true)
  417. UPD(CustomCommandsEnterFocusedAction, true)
  418. UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
  419. UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
  420. UPD(CustomCommandsCustomizeAction, true)
  421. // QUEUE
  422. UPDEX(QueueEnableAction, true, ((TAction *)Action)->Checked = ScpExplorer->GetQueueEnabled(), )
  423. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  424. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  425. UPDQUEUE(GoTo)
  426. UPDQUEUE(Preferences)
  427. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  428. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  429. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  430. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  431. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  432. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  433. UPDQUEUE(ItemDelete)
  434. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  435. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  436. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  437. !ScpExplorer->AllowQueueOperation(qoItemResume))
  438. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  439. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  440. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  441. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  442. UPDQUEUE(ItemUp)
  443. UPDQUEUE(ItemDown)
  444. UPDQUEUE(PauseAll)
  445. UPDQUEUE(ResumeAll)
  446. UPDQUEUE(DeleteAll)
  447. UPDQUEUE(DeleteAllDone)
  448. #undef UPDQUEUE
  449. UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),
  450. QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),
  451. QueueItemSpeedAction->Text = L"")
  452. UPDACT(QueueToggleShowAction,
  453. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  454. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  455. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  456. QUEUEACTION(Show)
  457. QUEUEACTION(HideWhenEmpty)
  458. QUEUEACTION(Hide)
  459. #undef QUEUEACTION
  460. UPDEX1(QueueCycleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty),
  461. QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
  462. QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
  463. UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  464. UPD(QueueDisconnectOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  465. UPD(QueueSuspendOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  466. UPD(QueueShutDownOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  467. UPDCOMP(CommanderPreferencesBand)
  468. UPDACT(QueueToolbarAction,
  469. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  470. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
  471. ;
  472. }
  473. //---------------------------------------------------------------------------
  474. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  475. TBasicAction *Action, bool &Handled)
  476. {
  477. assert(ScpExplorer);
  478. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  479. {
  480. Handled = true;
  481. return;
  482. }
  483. ScpExplorer->BeforeAction();
  484. bool ShortCutAction = (Action->ActionComponent == NULL);
  485. {
  486. TAutoNestingCounter Counter(FBusy);
  487. // focused operation
  488. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true))
  489. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true))
  490. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  491. EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu())
  492. EXE(CurrentEditWithFocusedAction, ScpExplorer->ExecuteCurrentFileWith(true))
  493. EXE(CurrentEditAlternativeFocusedAction, CreateEditorListMenu(CurrentEditAlternativeFocusedAction, true))
  494. EXE(CurrentEditInternalFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, true))
  495. // operation
  496. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  497. EXE(CurrentEditAlternative2Action, CreateEditorListMenu(CurrentEditAlternative2Action, false))
  498. EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false))
  499. EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith(false))
  500. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  501. EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false))
  502. EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false))
  503. EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true))
  504. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false))
  505. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false))
  506. EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true))
  507. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false))
  508. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  509. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  510. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  511. EXE(FileGenerateUrlAction, ScpExplorer->FileGenerateUrl())
  512. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  513. // local selected operation
  514. EXE(LocalCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, ShortCutAction))
  515. EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false))
  516. EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false))
  517. EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false))
  518. EXE(LocalCreateDirAction, ScpExplorer->CreateDirectory(osLocal))
  519. EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false))
  520. EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false))
  521. EXE(LocalAddEditLinkAction, ScpExplorer->AddEditLink(osLocal, false))
  522. // local focused operation
  523. EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, ShortCutAction))
  524. EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true))
  525. // remote selected operation
  526. EXE(RemoteCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, ShortCutAction))
  527. EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false))
  528. EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false))
  529. EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false))
  530. EXE(RemoteCreateDirAction, ScpExplorer->CreateDirectory(osRemote))
  531. EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false))
  532. EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false))
  533. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false))
  534. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false))
  535. EXE(RemoteAddEditLinkAction, ScpExplorer->AddEditLink(osRemote, false))
  536. // remote focused operation
  537. EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, ShortCutAction))
  538. EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true))
  539. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true))
  540. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true))
  541. // directory
  542. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  543. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  544. EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles())
  545. //selection
  546. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  547. EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
  548. EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
  549. EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
  550. EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
  551. EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
  552. EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())
  553. EXE(LocalSelectAction, DirView(osLocal)->DoSelectByMask(true))
  554. EXE(LocalUnselectAction, DirView(osLocal)->DoSelectByMask(false))
  555. EXE(LocalSelectAllAction, DirView(osLocal)->SelectAll(smAll))
  556. EXE(RemoteSelectAction, DirView(osRemote)->DoSelectByMask(true))
  557. EXE(RemoteUnselectAction, DirView(osRemote)->DoSelectByMask(false))
  558. EXE(RemoteSelectAllAction, DirView(osRemote)->SelectAll(smAll))
  559. EXE(PasteAction2, ScpExplorer->PasteFromClipBoard())
  560. // style
  561. EXE(CurrentCycleStyleAction,
  562. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  563. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  564. )
  565. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  566. DirView(osCurrent)->ViewStyle = vs ## Style)
  567. STYLEACTION(Icon)
  568. STYLEACTION(SmallIcon)
  569. STYLEACTION(List)
  570. STYLEACTION(Report)
  571. #undef STYLEACTION
  572. #define PANEL_ACTIONS(SIDE) \
  573. EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \
  574. EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \
  575. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  576. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  577. EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
  578. EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
  579. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  580. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  581. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  582. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
  583. EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))
  584. PANEL_ACTIONS(Local)
  585. PANEL_ACTIONS(Remote)
  586. #undef PANEL_ACTIONS
  587. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  588. //HELP
  589. EXE(AboutAction, DoAboutDialog(Configuration))
  590. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  591. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  592. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  593. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  594. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  595. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  596. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  597. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  598. // VIEW
  599. EXECOMP(SessionsTabs)
  600. EXECOMP(StatusBar)
  601. EXECOMP(ToolBar2)
  602. EXECOMP(LocalStatusBar)
  603. EXECOMP(RemoteStatusBar)
  604. EXECOMP(ExplorerMenuBand)
  605. EXECOMP(ExplorerAddressBand)
  606. EXECOMP(ExplorerToolbarBand)
  607. EXECOMP(ExplorerSelectionBand)
  608. EXECOMP(ExplorerSessionBand)
  609. EXECOMP(ExplorerPreferencesBand)
  610. EXECOMP(ExplorerSortBand)
  611. EXECOMP(ExplorerUpdatesBand)
  612. EXECOMP(ExplorerTransferBand)
  613. EXECOMP(ExplorerCustomCommandsBand)
  614. EXECOMP(CommanderMenuBand)
  615. EXECOMP(CommanderSessionBand)
  616. EXECOMP(CommanderPreferencesBand)
  617. EXECOMP(CommanderSortBand)
  618. EXECOMP(CommanderCommandsBand)
  619. EXECOMP(CommanderUpdatesBand)
  620. EXECOMP(CommanderTransferBand)
  621. EXECOMP(CommanderCustomCommandsBand)
  622. EXECOMP(CommanderLocalHistoryBand)
  623. EXECOMP(CommanderLocalNavigationBand)
  624. EXECOMP(CommanderLocalFileBand)
  625. EXECOMP(CommanderLocalSelectionBand)
  626. EXECOMP(CommanderRemoteHistoryBand)
  627. EXECOMP(CommanderRemoteNavigationBand)
  628. EXECOMP(CommanderRemoteFileBand)
  629. EXECOMP(CommanderRemoteSelectionBand)
  630. EXECOMP(CommandLinePanel)
  631. EXECOMP(RemoteTree)
  632. EXECOMP(LocalTree)
  633. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  634. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  635. EXE(ViewLogAction, WinConfiguration->LogView =
  636. (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
  637. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  638. EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone))
  639. EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes))
  640. EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort))
  641. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  642. EXE(PreferencesAction, PreferencesDialog(::pmDefault) )
  643. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  644. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  645. EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText)
  646. EXECOMP(CustomCommandsBand)
  647. EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction));
  648. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  649. // SORT
  650. EXESORTA(Local)
  651. EXESORT(Local, dv, Name)
  652. EXESORT(Local, dv, Ext)
  653. EXESORT(Local, dv, Size)
  654. EXESORT(Local, dv, Type)
  655. EXESORT(Local, dv, Changed)
  656. EXESORT(Local, dv, Attr)
  657. EXESORTA(Remote)
  658. EXESORT(Remote, uv, Name)
  659. EXESORT(Remote, uv, Ext)
  660. EXESORT(Remote, uv, Size)
  661. EXESORT(Remote, uv, Changed)
  662. EXESORT(Remote, uv, Rights)
  663. EXESORT(Remote, uv, Owner)
  664. EXESORT(Remote, uv, Group)
  665. EXESORT(Remote, uv, Type)
  666. EXESORTA(Current)
  667. EXESORTC(Name, dvName, uvName)
  668. EXESORTC(Ext, dvExt, uvExt)
  669. EXESORTC(Size, dvSize, uvSize)
  670. EXESORTC(Type, dvType, uvType)
  671. EXESORTC(Changed, dvChanged, uvChanged)
  672. EXESORTC(Rights, dvAttr, uvRights)
  673. EXESORTC(Owner, dvName, uvOwner)
  674. EXESORTC(Group, dvName, uvGroup)
  675. EXE(SortColumnAscendingAction, assert(ListColumn);
  676. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  677. EXE(SortColumnDescendingAction, assert(ListColumn);
  678. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  679. // SHOW/HIDE COLUMN
  680. EXESHCOL(Local, dv, Name)
  681. EXESHCOL(Local, dv, Ext)
  682. EXESHCOL(Local, dv, Size)
  683. EXESHCOL(Local, dv, Type)
  684. EXESHCOL(Local, dv, Changed)
  685. EXESHCOL(Local, dv, Attr)
  686. EXESHCOL(Remote, uv, Name)
  687. EXESHCOL(Remote, uv, Ext)
  688. EXESHCOL(Remote, uv, Size)
  689. EXESHCOL(Remote, uv, Changed)
  690. EXESHCOL(Remote, uv, Rights)
  691. EXESHCOL(Remote, uv, Owner)
  692. EXESHCOL(Remote, uv, Group)
  693. EXESHCOL(Remote, uv, LinkTarget)
  694. EXESHCOL(Remote, uv, Type)
  695. EXE(HideColumnAction, assert(ListColumn);
  696. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  697. EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO
  698. #undef COLVIEWPROPS
  699. // SESSION
  700. EXE(NewSessionAction, ScpExplorer->NewSession(false))
  701. EXE(SiteManagerAction, ScpExplorer->NewSession(true))
  702. EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
  703. EXE(CloseSessionAction, ScpExplorer->CloseSession())
  704. EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2))
  705. EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction))
  706. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  707. EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession())
  708. EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false))
  709. // COMMAND
  710. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  711. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  712. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  713. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  714. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  715. EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
  716. EXE(CloseApplicationAction, ScpExplorer->Close())
  717. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  718. EXE(SessionGenerateUrlAction, ScpExplorer->SessionGenerateUrl())
  719. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  720. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  721. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  722. // CUSTOM COMMANDS
  723. EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
  724. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
  725. EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
  726. EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
  727. EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
  728. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  729. // QUEUE
  730. EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled())
  731. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  732. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  733. EXEQUEUE(GoTo)
  734. EXEQUEUE(Preferences)
  735. EXEQUEUE(ItemQuery)
  736. EXEQUEUE(ItemError)
  737. EXEQUEUE(ItemPrompt)
  738. EXEQUEUE(ItemDelete)
  739. EXEQUEUE(ItemExecute)
  740. EXEQUEUE(ItemPause)
  741. EXEQUEUE(ItemResume)
  742. EXEQUEUE(ItemUp)
  743. EXEQUEUE(ItemDown)
  744. EXEQUEUE(PauseAll)
  745. EXEQUEUE(ResumeAll)
  746. EXEQUEUE(DeleteAll)
  747. EXEQUEUE(DeleteAllDone)
  748. #undef EXEQUEUE
  749. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  750. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  751. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  752. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  753. Config.Show = qv ## SHOW; \
  754. WinConfiguration->QueueView = Config)
  755. QUEUEACTION(Show)
  756. QUEUEACTION(HideWhenEmpty)
  757. QUEUEACTION(Hide)
  758. #undef QUEUEACTION
  759. EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction());
  760. EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
  761. EXE(QueueDisconnectOnceEmptyAction, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction))
  762. EXE(QueueSuspendOnceEmptyAction, SetQueueOnceEmptyAction(QueueSuspendOnceEmptyAction))
  763. EXE(QueueShutDownOnceEmptyAction, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction))
  764. EXECOMP(QueueToolbar);
  765. EXE(QueueItemSpeedAction, )
  766. ;
  767. }
  768. DoIdle();
  769. }
  770. //---------------------------------------------------------------------------
  771. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  772. {
  773. // following actions needs to be updated even when all clients
  774. // are invisible, so the queue list toolbar button can be shown
  775. NonVisualDataModule->QueueItemQueryAction->Update();
  776. NonVisualDataModule->QueueItemErrorAction->Update();
  777. NonVisualDataModule->QueueItemPromptAction->Update();
  778. }
  779. //---------------------------------------------------------------------------
  780. #define CTRL TShiftState() << ssCtrl
  781. #define ALT TShiftState() << ssAlt
  782. #define SHIFT TShiftState() << ssShift
  783. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  784. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  785. #define NONE TShiftState()
  786. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  787. {
  788. // Directory
  789. CurrentCreateDirAction->ShortCut = ShortCut(L'D', CTRL);
  790. // File operation
  791. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  792. CurrentEditAction->ShortCut = ShortCut(L'E', CTRL);
  793. CurrentAddEditLinkAction->ShortCut = ShortCut(L'L', CTRLALT);
  794. CurrentEditInternalAction->ShortCut = 0;
  795. CurrentEditInternalFocusedAction->ShortCut = 0;
  796. // Focused operation
  797. RemoteCopyAction->ShortCut = ShortCut(L'C', CTRL);
  798. RemoteMoveAction->ShortCut = ShortCut(L'M', CTRL);
  799. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  800. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  801. RemoteMoveToFocusedAction->ShortCut = ShortCut(L'M', CTRLALT);
  802. // remote directory
  803. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  804. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  805. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  806. RemotePathToClipboardAction->ShortCut = ShortCut(L'P', CTRLSHIFT);
  807. // selected operation
  808. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
  809. RemoteMoveToAction->ShortCut = ShortCut(L'M', CTRLALT);
  810. // selection
  811. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  812. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  813. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  814. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  815. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRL);
  816. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  817. // commands
  818. NewFileAction->ShortCut = ShortCut(L'E', CTRLSHIFT);
  819. RemoteFindFilesAction->ShortCut = ShortCut(VK_F3, NONE);
  820. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  821. CloneShortcuts();
  822. }
  823. //---------------------------------------------------------------------------
  824. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  825. {
  826. bool ExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  827. // Directory
  828. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  829. // File operation
  830. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  831. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  832. CurrentAddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  833. CurrentEditInternalAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  834. CurrentEditInternalFocusedAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  835. // Focused operation
  836. RemoteCopyAction->ShortCut =
  837. ExplorerKeyboardShortcuts ? ShortCut(L'K', CTRL) : ShortCut(VK_F5, NONE);
  838. RemoteMoveAction->ShortCut = ShortCut(VK_F6, NONE);
  839. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  840. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  841. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  842. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  843. // remote directory
  844. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  845. RemoteRefreshAction->ShortCut =
  846. ExplorerKeyboardShortcuts ? ShortCut(VK_F5, NONE) : ShortCut(L'R', CTRL);
  847. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  848. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  849. // local directory
  850. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  851. // selected operation
  852. CurrentDeleteAction->SecondaryShortCuts->Clear();
  853. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  854. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  855. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  856. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  857. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  858. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  859. // selection
  860. SelectOneAction->ShortCut = VK_INSERT;
  861. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  862. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  863. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  864. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  865. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRL);
  866. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  867. // commands
  868. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  869. RemoteFindFilesAction->ShortCut =
  870. ExplorerKeyboardShortcuts ? ShortCut(VK_F3, NONE) : ShortCut(VK_F7, ALT);
  871. // legacy shortcut (can be removed when necessary)
  872. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  873. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  874. CloneShortcuts();
  875. }
  876. #undef CTRL
  877. #undef ALT
  878. #undef NONE
  879. //---------------------------------------------------------------------------
  880. void __fastcall TNonVisualDataModule::CloneShortcuts()
  881. {
  882. // Directory
  883. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  884. // File operation
  885. CurrentAddEditLinkContextAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  886. LocalAddEditLinkAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  887. RemoteAddEditLinkAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  888. // local directory
  889. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  890. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  891. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  892. // selected operation
  893. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  894. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  895. // local selected operation
  896. LocalCopyAction->ShortCut = RemoteCopyAction->ShortCut;
  897. LocalRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  898. LocalEditAction->ShortCut = CurrentEditAction->ShortCut;
  899. LocalMoveAction->ShortCut = RemoteMoveAction->ShortCut;
  900. LocalCreateDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  901. LocalDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  902. LocalPropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  903. // local focused operation
  904. LocalCopyFocusedAction->ShortCut = LocalCopyAction->ShortCut;
  905. LocalMoveFocusedAction->ShortCut = LocalMoveAction->ShortCut;
  906. // remote selected operation
  907. RemoteRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  908. RemoteEditAction->ShortCut = CurrentEditAction->ShortCut;
  909. RemoteCreateDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  910. RemoteDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  911. RemotePropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  912. // remote focused operation
  913. RemoteCopyFocusedAction->ShortCut = RemoteCopyAction->ShortCut;
  914. RemoteMoveFocusedAction->ShortCut = RemoteMoveAction->ShortCut;
  915. // selection
  916. LocalSelectAction->ShortCut = SelectAction->ShortCut;
  917. LocalUnselectAction->ShortCut = UnselectAction->ShortCut;
  918. LocalSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  919. RemoteSelectAction->ShortCut = SelectAction->ShortCut;
  920. RemoteUnselectAction->ShortCut = UnselectAction->ShortCut;
  921. RemoteSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  922. }
  923. //---------------------------------------------------------------------------
  924. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  925. {
  926. FScpExplorer = value;
  927. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  928. }
  929. //---------------------------------------------------------------------------
  930. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  931. TObject */*Sender*/)
  932. {
  933. DoIdle();
  934. }
  935. //---------------------------------------------------------------------------
  936. void __fastcall TNonVisualDataModule::DoIdle()
  937. {
  938. if (!FSessionIdleTimerExecuting)
  939. {
  940. FSessionIdleTimerExecuting = true;
  941. try
  942. {
  943. assert(ScpExplorer);
  944. ScpExplorer->Idle();
  945. }
  946. __finally
  947. {
  948. FSessionIdleTimerExecuting = false;
  949. }
  950. }
  951. }
  952. //---------------------------------------------------------------------------
  953. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  954. TTBCustomItem * Menu, bool OnFocused, bool Toolbar, bool Both)
  955. {
  956. for (int Index = 0; Index < WinConfiguration->CustomCommandList->Count; Index++)
  957. {
  958. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Index];
  959. int State;
  960. if (!Both)
  961. {
  962. State = ScpExplorer->CustomCommandState(*Command, OnFocused);
  963. }
  964. else
  965. {
  966. State = ScpExplorer->BothCustomCommandState(*Command);
  967. }
  968. if (State >= 0)
  969. {
  970. TTBCustomItem * Item = new TTBXItem(Owner);
  971. Item->Caption = Command->Name;
  972. if (Toolbar)
  973. {
  974. Item->Caption = EscapeHotkey(StripHotkey(Item->Caption));
  975. }
  976. Item->Tag = Index;
  977. Item->Enabled = (State > 0);
  978. if (OnFocused)
  979. {
  980. Item->Tag = Item->Tag | 0x0100;
  981. }
  982. if (Both)
  983. {
  984. Item->Tag = Item->Tag | 0x0200;
  985. }
  986. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Command->Name)));
  987. if (!Both)
  988. {
  989. Item->ShortCut = Command->ShortCut;
  990. }
  991. Item->OnClick = CustomCommandClick;
  992. Menu->Add(Item);
  993. }
  994. }
  995. TTBCustomItem * Item;
  996. if (!Both)
  997. {
  998. Item = new TTBXItem(Menu);
  999. Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
  1000. Menu->Add(Item);
  1001. Item = new TTBXItem(Menu);
  1002. Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
  1003. if (Toolbar)
  1004. {
  1005. Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
  1006. }
  1007. Menu->Add(Item);
  1008. }
  1009. AddMenuSeparator(Menu);
  1010. if (!Toolbar && !Both)
  1011. {
  1012. Item = new TTBXItem(Menu);
  1013. Item->Action = CustomCommandsBandAction;
  1014. Menu->Add(Item);
  1015. }
  1016. Item = new TTBXItem(Menu);
  1017. Item->Action = CustomCommandsCustomizeAction;
  1018. Menu->Add(Item);
  1019. }
  1020. //---------------------------------------------------------------------------
  1021. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  1022. TAction * Action, bool OnFocused, bool Both)
  1023. {
  1024. assert(Action);
  1025. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1026. if (Menu)
  1027. {
  1028. int PrevCount = Menu->Count;
  1029. CreateCustomCommandsMenu(Menu, OnFocused, false, Both);
  1030. for (int Index = 0; Index < PrevCount; Index++)
  1031. {
  1032. Menu->Delete(0);
  1033. }
  1034. }
  1035. }
  1036. //---------------------------------------------------------------------------
  1037. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  1038. {
  1039. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1040. if (ALWAYS_TRUE(Menu != NULL))
  1041. {
  1042. bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
  1043. CreateCustomCommandsMenu(Action, OnFocused, false);
  1044. }
  1045. }
  1046. //---------------------------------------------------------------------------
  1047. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  1048. {
  1049. // can be called while explorer is being created
  1050. if (ScpExplorer == NULL)
  1051. {
  1052. return;
  1053. }
  1054. int AdditionalCommands = 4;
  1055. TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;
  1056. bool Changed = (CustomCommandList->Count != (Toolbar->Items->Count - AdditionalCommands));
  1057. if (!Changed)
  1058. {
  1059. int Index = 0;
  1060. while (!Changed && (Index < CustomCommandList->Count))
  1061. {
  1062. Changed =
  1063. (Toolbar->Items->Items[Index]->Caption !=
  1064. EscapeHotkey(StripHotkey(CustomCommandList->Commands[Index]->Name)));
  1065. Index++;
  1066. }
  1067. }
  1068. if (Changed)
  1069. {
  1070. Toolbar->BeginUpdate();
  1071. try
  1072. {
  1073. Toolbar->Items->Clear();
  1074. CreateCustomCommandsMenu(Toolbar->Items, false, true, false);
  1075. assert(CustomCommandList->Count == (Toolbar->Items->Count - AdditionalCommands));
  1076. }
  1077. __finally
  1078. {
  1079. Toolbar->EndUpdate();
  1080. }
  1081. }
  1082. else
  1083. {
  1084. for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
  1085. {
  1086. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1087. int CommandIndex = (Item->Tag & 0x00FF);
  1088. assert(CommandIndex == Index);
  1089. int State = ScpExplorer->CustomCommandState(
  1090. *CustomCommandList->Commands[CommandIndex], false);
  1091. assert(State >= 0);
  1092. Item->Enabled = (State > 0);
  1093. }
  1094. }
  1095. }
  1096. //---------------------------------------------------------------------------
  1097. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  1098. {
  1099. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1100. assert(Item);
  1101. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Item->Tag & 0x00FF];
  1102. if (FLAGCLEAR(Item->Tag, 0x0200))
  1103. {
  1104. ScpExplorer->ExecuteFileOperationCommand(foCustomCommand, osRemote,
  1105. FLAGSET(Item->Tag, 0x0100), false, const_cast<TCustomCommandType *>(Command));
  1106. }
  1107. else
  1108. {
  1109. ScpExplorer->BothCustomCommand(*Command);
  1110. }
  1111. }
  1112. //---------------------------------------------------------------------------
  1113. void __fastcall TNonVisualDataModule::CreateSessionColorMenu(TAction * Action)
  1114. {
  1115. if (ALWAYS_TRUE(Action->ActionComponent != NULL))
  1116. {
  1117. ::CreateSessionColorMenu(Action->ActionComponent, ScpExplorer->SessionColor,
  1118. SessionColorChange);
  1119. }
  1120. }
  1121. //---------------------------------------------------------------------------
  1122. void __fastcall TNonVisualDataModule::SessionColorChange(TColor Color)
  1123. {
  1124. ScpExplorer->SessionColor = Color;
  1125. }
  1126. //---------------------------------------------------------------------------
  1127. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  1128. {
  1129. StoredSessions->Load();
  1130. CreateSessionListMenuLevel(
  1131. dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
  1132. }
  1133. //---------------------------------------------------------------------------
  1134. UnicodeString __fastcall TNonVisualDataModule::GetSessionFolderRoot(
  1135. TSessionData * Data, int Level)
  1136. {
  1137. UnicodeString Path = Data->Name;
  1138. UnicodeString Root;
  1139. for (int ALevel = 0; ALevel < Level; ALevel++)
  1140. {
  1141. Root.Insert(::CutToChar(Path, L'/', false) + L'/', Root.Length() + 1);
  1142. }
  1143. return Root;
  1144. }
  1145. //---------------------------------------------------------------------------
  1146. void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
  1147. TTBCustomItem * Menu, int Index, int Level)
  1148. {
  1149. Menu->Clear();
  1150. TTBCustomItem * Item = new TTBXItem(Menu);
  1151. UnicodeString Root;
  1152. if (Level == 0)
  1153. {
  1154. Item->Action = SiteManagerAction;
  1155. Root = L"";
  1156. }
  1157. else
  1158. {
  1159. assert(Index < StoredSessions->Count);
  1160. TSessionData * Data = StoredSessions->Sessions[Index];
  1161. Root = GetSessionFolderRoot(Data, Level);
  1162. Item->Caption = LoadStr(SAVEDSESSIONFOLDER_THIS_OPEN);
  1163. Item->Tag = MAKELONG(Index, Level);
  1164. UnicodeString FolderName = Root;
  1165. if (ALWAYS_TRUE(!FolderName.IsEmpty() && FolderName[FolderName.Length()] == L'/'))
  1166. {
  1167. FolderName.Delete(FolderName.Length(), 1);
  1168. }
  1169. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_THIS_HINT, (FolderName));
  1170. Item->OnClick = SessionFolderThisItemClick;
  1171. }
  1172. Menu->Insert(Menu->Count, Item);
  1173. AddMenuSeparator(Menu);
  1174. int FirstSession = Menu->Count;
  1175. UnicodeString PrevName;
  1176. while (Index < StoredSessions->Count)
  1177. {
  1178. TSessionData * Data = StoredSessions->Sessions[Index];
  1179. if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
  1180. {
  1181. // Sessions are sorted, so no chance further sessions may match
  1182. break;
  1183. }
  1184. else if (!Data->IsWorkspace)
  1185. {
  1186. UnicodeString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
  1187. int P = Name.Pos(L'/');
  1188. if (P > 0)
  1189. {
  1190. Name.SetLength(P - 1);
  1191. }
  1192. if (Name != PrevName)
  1193. {
  1194. if (P > 0)
  1195. {
  1196. TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
  1197. Item->Caption = Name;
  1198. Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
  1199. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_HINT, (Root + Name));
  1200. Item->ImageIndex = SavedSessionsAction2->ImageIndex;
  1201. Item->OnClick = SessionFolderItemClick;
  1202. Menu->Insert(FirstSession, Item);
  1203. FirstSession++;
  1204. }
  1205. else
  1206. {
  1207. TTBCustomItem * Item = new TTBXItem(Menu);
  1208. Item->Caption = Name;
  1209. Item->Tag = Index;
  1210. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  1211. Item->OnClick = SessionItemClick;
  1212. Menu->Insert(Menu->Count, Item);
  1213. }
  1214. PrevName = Name;
  1215. }
  1216. }
  1217. Index++;
  1218. }
  1219. }
  1220. //---------------------------------------------------------------------------
  1221. void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
  1222. {
  1223. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1224. assert(Item != NULL);
  1225. CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
  1226. }
  1227. //---------------------------------------------------------------------------
  1228. void __fastcall TNonVisualDataModule::SessionFolderThisItemClick(TObject * Sender)
  1229. {
  1230. TTBCustomItem * Item = NOT_NULL(dynamic_cast<TTBCustomItem *>(Sender));
  1231. int Index = LOWORD(Item->Tag);
  1232. int Level = HIWORD(Item->Tag);
  1233. UnicodeString Folder = GetSessionFolderRoot(StoredSessions->Sessions[Index], Level);
  1234. ScpExplorer->OpenFolderOrWorkspace(Folder);
  1235. }
  1236. //---------------------------------------------------------------------------
  1237. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  1238. {
  1239. assert(StoredSessions && (((TTBCustomItem *)Sender)->Tag < StoredSessions->Count));
  1240. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TTBCustomItem *)Sender)->Tag]);
  1241. }
  1242. //---------------------------------------------------------------------------
  1243. void __fastcall TNonVisualDataModule::CreateWorkspacesMenu(TAction * Action)
  1244. {
  1245. StoredSessions->Load();
  1246. if (!StoredSessions->HasAnyWorkspace())
  1247. {
  1248. Abort();
  1249. }
  1250. else
  1251. {
  1252. TTBCustomItem * Menu =
  1253. NOT_NULL(dynamic_cast<TTBCustomItem *>(Action->ActionComponent));
  1254. Menu->Clear();
  1255. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1256. for (int Index = 0; Index < Workspaces->Count; Index++)
  1257. {
  1258. TTBCustomItem * Item = new TTBXItem(Menu);
  1259. Item->Caption = Workspaces->Strings[Index];
  1260. Item->Tag = Index;
  1261. Item->Hint = FMTLOAD(WORKSPACE_HINT, (Workspaces->Strings[Index]));
  1262. Item->OnClick = WorkspaceItemClick;
  1263. Menu->Insert(Menu->Count, Item);
  1264. }
  1265. }
  1266. }
  1267. //---------------------------------------------------------------------------
  1268. void __fastcall TNonVisualDataModule::WorkspaceItemClick(TObject * Sender)
  1269. {
  1270. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1271. ScpExplorer->OpenFolderOrWorkspace(
  1272. Workspaces->Strings[NOT_NULL(dynamic_cast<TTBCustomItem *>(Sender))->Tag]);
  1273. }
  1274. //---------------------------------------------------------------------------
  1275. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  1276. {
  1277. if (Index >= 0 && Index < 10)
  1278. {
  1279. return ShortCut((Word)(Index < 9 ? L'0' + 1 + Index : L'0'),
  1280. TShiftState() << ssAlt);
  1281. }
  1282. else
  1283. {
  1284. return scNone;
  1285. }
  1286. }
  1287. //---------------------------------------------------------------------------
  1288. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  1289. {
  1290. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1291. assert(OpenedSessionsMenu != NULL);
  1292. TTerminalManager * Manager = TTerminalManager::Instance();
  1293. TStrings * TerminalList = Manager->TerminalList;
  1294. int PrevCount = OpenedSessionsMenu->Count;
  1295. for (int Index = 0; Index < TerminalList->Count; Index++)
  1296. {
  1297. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  1298. assert(Terminal);
  1299. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  1300. Item->Caption = TerminalList->Strings[Index];
  1301. Item->Tag = int(Terminal);
  1302. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  1303. Item->Checked = (Manager->ActiveTerminal == Terminal);
  1304. Item->ShortCut = OpenSessionShortCut(Index);
  1305. Item->OnClick = OpenedSessionItemClick;
  1306. Item->RadioItem = true;
  1307. OpenedSessionsMenu->Add(Item);
  1308. }
  1309. for (int Index = 0; Index < PrevCount; Index++)
  1310. {
  1311. OpenedSessionsMenu->Delete(0);
  1312. }
  1313. }
  1314. //---------------------------------------------------------------------------
  1315. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  1316. {
  1317. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  1318. }
  1319. //---------------------------------------------------------------------------
  1320. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action, bool OnFocused)
  1321. {
  1322. assert(Action != NULL);
  1323. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1324. if (Menu != NULL)
  1325. {
  1326. int PrevCount = Menu->Count;
  1327. TTBCustomItem * Item = new TTBXItem(Menu);
  1328. Item->Action = OnFocused ? CurrentEditInternalFocusedAction : CurrentEditInternalAction;
  1329. Menu->Add(Item);
  1330. AddMenuSeparator(Menu);
  1331. TStringList * UsedEditors = CreateSortedStringList();
  1332. try
  1333. {
  1334. const TEditorList * EditorList = WinConfiguration->EditorList;
  1335. for (int Index = 0; Index < EditorList->Count; Index++)
  1336. {
  1337. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1338. if ((Editor->Data->Editor == edExternal) &&
  1339. (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
  1340. {
  1341. UsedEditors->Add(Editor->Data->ExternalEditor);
  1342. TTBCustomItem * Item = new TTBXItem(Menu);
  1343. Item->Caption = Editor->Name;
  1344. Item->Tag = Index;
  1345. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1346. if (OnFocused)
  1347. {
  1348. Item->OnClick = EditorItemClickFocused;
  1349. }
  1350. else
  1351. {
  1352. Item->OnClick = EditorItemClick;
  1353. }
  1354. Menu->Add(Item);
  1355. }
  1356. }
  1357. Item = new TTBXItem(Menu);
  1358. Item->Action = OnFocused ? CurrentEditWithFocusedAction : CurrentEditWithAction;
  1359. Menu->Add(Item);
  1360. AddMenuSeparator(Menu);
  1361. Item = new TTBXItem(Menu);
  1362. Item->Action = EditorListCustomizeAction;
  1363. Menu->Add(Item);
  1364. for (int Index = 0; Index < PrevCount; Index++)
  1365. {
  1366. Menu->Delete(0);
  1367. }
  1368. }
  1369. __finally
  1370. {
  1371. delete UsedEditors;
  1372. }
  1373. }
  1374. }
  1375. //---------------------------------------------------------------------------
  1376. void __fastcall TNonVisualDataModule::DoEditorItemClick(TObject * Sender, bool OnFocused)
  1377. {
  1378. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1379. const TEditorList * EditorList = WinConfiguration->EditorList;
  1380. // sanity check
  1381. if (Tag < EditorList->Count)
  1382. {
  1383. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
  1384. true, OnFocused);
  1385. }
  1386. }
  1387. //---------------------------------------------------------------------------
  1388. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1389. {
  1390. DoEditorItemClick(Sender, false);
  1391. }
  1392. //---------------------------------------------------------------------------
  1393. void __fastcall TNonVisualDataModule::EditorItemClickFocused(TObject * Sender)
  1394. {
  1395. DoEditorItemClick(Sender, true);
  1396. }
  1397. //---------------------------------------------------------------------------
  1398. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1399. {
  1400. TAction * Action = NULL;
  1401. switch (ScpExplorer->DefaultQueueOperation())
  1402. {
  1403. case qoItemQuery:
  1404. Action = QueueItemQueryAction;
  1405. break;
  1406. case qoItemError:
  1407. Action = QueueItemErrorAction;
  1408. break;
  1409. case qoItemPrompt:
  1410. Action = QueueItemPromptAction;
  1411. break;
  1412. case qoItemExecute:
  1413. Action = QueueItemExecuteAction;
  1414. break;
  1415. case qoItemPause:
  1416. Action = QueueItemPauseAction;
  1417. break;
  1418. case qoItemResume:
  1419. Action = QueueItemResumeAction;
  1420. break;
  1421. }
  1422. TTBCustomItem * Item;
  1423. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1424. {
  1425. Item = QueuePopup->Items->Items[Index];
  1426. TTBItemOptions O = Item->Options;
  1427. if ((Action != NULL) && (Item->Action == Action))
  1428. {
  1429. O << tboDefault;
  1430. }
  1431. else
  1432. {
  1433. O >> tboDefault;
  1434. }
  1435. Item->Options = O;
  1436. }
  1437. QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
  1438. }
  1439. //---------------------------------------------------------------------------
  1440. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1441. {
  1442. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1443. unsigned short H, M, S, MS;
  1444. DecodeTime(Now(), H, M, S, MS);
  1445. int CurrentCompoundVer = Configuration->CompoundVersion;
  1446. CheckForUpdatesAction->ImageIndex =
  1447. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1448. !Updates.Results.Disabled &&
  1449. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1450. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1451. ((Updates.Results.Version > CurrentCompoundVer) ||
  1452. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1453. ((int(Updates.Period) <= 0) ? 81 : 63));
  1454. }
  1455. //---------------------------------------------------------------------------
  1456. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1457. {
  1458. if (ScpExplorer != NULL)
  1459. {
  1460. ScpExplorer->PreferencesDialog(APreferencesMode);
  1461. }
  1462. else
  1463. {
  1464. DoPreferencesDialog(APreferencesMode);
  1465. }
  1466. }
  1467. //---------------------------------------------------------------------------
  1468. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1469. {
  1470. TCustomCommandType Command;
  1471. int State;
  1472. bool Defined = ScpExplorer->GetLastCustomCommand(
  1473. (Action == CustomCommandsLastFocusedAction), Command, State);
  1474. Action->Visible = Defined;
  1475. if (Defined)
  1476. {
  1477. UnicodeString TitleCommand = Command.Command;
  1478. int MaxTitleCommandLen = 20;
  1479. if (TitleCommand.Length() > MaxTitleCommandLen)
  1480. {
  1481. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + "...";
  1482. }
  1483. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (TitleCommand));
  1484. Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (Command.Command));
  1485. Action->Enabled = (State > 0);
  1486. }
  1487. }
  1488. //---------------------------------------------------------------------------
  1489. UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeString & Text,
  1490. TTBXComboBoxItem * Item)
  1491. {
  1492. unsigned long Speed = GetSpeedLimit(Text);
  1493. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1494. UnicodeString Result = SetSpeedLimit(Speed);
  1495. SaveToHistory(Item->Strings, Result);
  1496. CustomWinConfiguration->History[L"SpeedLimit"] = Item->Strings;
  1497. return Result;
  1498. }
  1499. //---------------------------------------------------------------------------
  1500. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1501. TObject * Sender)
  1502. {
  1503. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1504. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1505. }
  1506. //---------------------------------------------------------------------------
  1507. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1508. TObject * Sender, UnicodeString & NewText, bool & /*Accept*/)
  1509. {
  1510. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1511. NewText = QueueItemSpeed(NewText, Item);
  1512. QueueItemSpeedAction->Text = NewText;
  1513. }
  1514. //---------------------------------------------------------------------------
  1515. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1516. {
  1517. // IDE often looses this link
  1518. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1519. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1520. }
  1521. //---------------------------------------------------------------------------
  1522. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1523. {
  1524. Item->Strings = CustomWinConfiguration->History[L"SpeedLimit"];
  1525. }
  1526. //---------------------------------------------------------------------------
  1527. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1528. {
  1529. TAction * Current = CurrentQueueOnceEmptyAction();
  1530. if (Current != Action)
  1531. {
  1532. Current->Checked = false;
  1533. Action->Checked = true;
  1534. }
  1535. }
  1536. //---------------------------------------------------------------------------
  1537. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1538. {
  1539. TAction * Current = CurrentQueueOnceEmptyAction();
  1540. Current->Checked = false;
  1541. if (Current == QueueIdleOnceEmptyAction)
  1542. {
  1543. QueueDisconnectOnceEmptyAction->Checked = true;
  1544. }
  1545. else if (Current == QueueDisconnectOnceEmptyAction)
  1546. {
  1547. QueueSuspendOnceEmptyAction->Checked = true;
  1548. }
  1549. else if (Current == QueueSuspendOnceEmptyAction)
  1550. {
  1551. QueueShutDownOnceEmptyAction->Checked = true;
  1552. }
  1553. else if (Current == QueueShutDownOnceEmptyAction)
  1554. {
  1555. QueueIdleOnceEmptyAction->Checked = true;
  1556. }
  1557. else
  1558. {
  1559. FAIL;
  1560. }
  1561. }
  1562. //---------------------------------------------------------------------------
  1563. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1564. {
  1565. TAction * Result;
  1566. if (QueueIdleOnceEmptyAction->Checked)
  1567. {
  1568. Result = QueueIdleOnceEmptyAction;
  1569. }
  1570. else if (QueueDisconnectOnceEmptyAction->Checked)
  1571. {
  1572. Result = QueueDisconnectOnceEmptyAction;
  1573. }
  1574. else if (QueueSuspendOnceEmptyAction->Checked)
  1575. {
  1576. Result = QueueSuspendOnceEmptyAction;
  1577. }
  1578. else if (QueueShutDownOnceEmptyAction->Checked)
  1579. {
  1580. Result = QueueShutDownOnceEmptyAction;
  1581. }
  1582. else
  1583. {
  1584. FAIL;
  1585. }
  1586. return Result;
  1587. }
  1588. //---------------------------------------------------------------------------
  1589. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1590. {
  1591. TOnceDoneOperation Result;
  1592. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1593. if (Current == QueueIdleOnceEmptyAction)
  1594. {
  1595. Result = odoIdle;
  1596. }
  1597. else if (Current == QueueDisconnectOnceEmptyAction)
  1598. {
  1599. Result = odoDisconnect;
  1600. }
  1601. else if (Current == QueueSuspendOnceEmptyAction)
  1602. {
  1603. Result = odoSuspend;
  1604. }
  1605. else if (Current == QueueShutDownOnceEmptyAction)
  1606. {
  1607. Result = odoShutDown;
  1608. }
  1609. else
  1610. {
  1611. FAIL;
  1612. }
  1613. return Result;
  1614. }
  1615. //---------------------------------------------------------------------------
  1616. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1617. {
  1618. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1619. }
  1620. //---------------------------------------------------------------------------
  1621. void __fastcall TNonVisualDataModule::StartBusy()
  1622. {
  1623. FBusy++;
  1624. }
  1625. //---------------------------------------------------------------------------
  1626. void __fastcall TNonVisualDataModule::EndBusy()
  1627. {
  1628. FBusy--;
  1629. }