home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Objects / FinderToolBar.script
Encoding:
Text File  |  2001-06-19  |  3.7 KB  |  135 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3. // @Modified build 232 cm19981109 - exposed findwhat and replacewith edit boxes
  4.  
  5. var gOutput = getOutput();
  6.  
  7. function OnNotify()
  8. {   
  9.     var output = getOutput();
  10.     var logEvents = getGlobal("LogEvents", false);
  11.     if (logEvents)
  12.     {
  13.         output.writeLine("Running Objects/FinderToolbar");
  14.     }
  15.     
  16.     CreateFinderToolbar();
  17. }
  18.  
  19. var gFindParameters = getGlobal("FindParameters", null);
  20.  
  21. function onUpdateFindWhat(text)
  22. {
  23.     if (text)
  24.     {
  25.         gFindComboBox.text = text;
  26.     }
  27. }
  28.  
  29. function onUpdateReplaceWith(text)
  30. {
  31.     if (text)
  32.     {
  33.         gReplaceComboBox.text = text;
  34.     }
  35. }
  36.  
  37. function onFindTextChange(text)
  38. {
  39.     if (text)
  40.     {
  41.         // Break infinte update loop
  42.         gFindParameters.updateFindWhat(text);
  43.     }
  44. }
  45.  
  46. function onFindTextReturnKeyPressed()
  47. {
  48.     var editor = getActiveEditor();
  49.     if (editor)
  50.     {
  51.         editor.findNext();
  52.     }
  53. }
  54.  
  55.  
  56. function onReplaceTextChange(text)
  57. {
  58.     // Break infinte update loop
  59.     gFindParameters.updateReplaceWith(text);
  60. }
  61.  
  62. function onFindDropDown()
  63. {
  64.     return gFindParameters.findHistoryList;
  65. }
  66.  
  67. function onReplaceDropDown()
  68. {
  69.     return gFindParameters.replaceHistoryList;
  70. }
  71.     
  72. var gFindComboBox = newToolBarButton("combobox");
  73. var gReplaceComboBox = newToolBarButton("combobox");
  74.  
  75. function CreateFinderToolbar()
  76. {
  77.     setGlobal("FinderFindWhat",gFindComboBox); // cm19981109
  78.     setGlobal("FinderReplaceWith",gReplaceComboBox);// cm19981109
  79.     
  80.     var toolBar = newToolBar("Finder", "finder");
  81.     if (toolBar)
  82.     {
  83.         var findLabel = newToolBarButton("label");
  84.         findLabel.width = 30;
  85.         findLabel.text = "Find:";
  86.         toolBar.setButton(0, findLabel);
  87.     
  88.         gFindComboBox.dropDownHeight = 150;
  89.         gFindComboBox.width = 200;
  90.         gFindComboBox.scriptHandler = "Objects\\FinderToolBar.script";
  91.         gFindComboBox.onDropDownHandler = "onFindDropDown";
  92.         gFindComboBox.onTextChangeHandler = "onFindTextChange";
  93.         gFindComboBox.onReturnHandler = "onFindTextReturnKeyPressed";
  94.         toolBar.setButton(1, gFindComboBox);
  95.         gFindComboBox.text = gFindParameters.findWhat;
  96.         
  97.         var findInWindowsButton = newToolBarButton("icon");
  98.         findInWindowsButton.scriptPath = "\\Misc\\findInOpenDocuments.script"; 
  99.         findInWindowsButton.description = "Find in windows";
  100.         findInWindowsButton.toolTipText = "Find in windows";
  101.         toolBar.setButton(5, findInWindowsButton);
  102.     
  103.         var replaceLabel = newToolBarButton("label");
  104.         replaceLabel.width = 55;
  105.         replaceLabel.text = "Replace:";
  106.         toolBar.setButton(7, replaceLabel);
  107.     
  108.         gReplaceComboBox.dropDownHeight = 150;
  109.         gReplaceComboBox.width = 200;
  110.         gReplaceComboBox.scriptHandler = "Objects\\FinderToolBar.script";
  111.         gReplaceComboBox.onDropDownHandler = "onReplaceDropDown";
  112.         gReplaceComboBox.onTextChangeHandler = "onReplaceTextChange";
  113.         gReplaceComboBox.onReturnHandler = "onFindTextReturnKeyPressed";
  114.         toolBar.setButton(8, gReplaceComboBox);
  115.         gReplaceComboBox.text = gFindParameters.replaceWith;
  116.         
  117.         var replaceInWindowsButton = newToolBarButton("icon");
  118.         replaceInWindowsButton.scriptPath = "\\Misc\\replaceInOpenDocuments.script";  
  119.         replaceInWindowsButton.description = "Replace in windows";
  120.         replaceInWindowsButton.toolTipText = "Replace in windows";
  121.         toolBar.setButton(12, replaceInWindowsButton);
  122.     
  123.         var findInWindowsButton = newToolBarButton("icon");
  124.         findInWindowsButton.scriptPath = "\\Misc\\replaceInFiles.script"; 
  125.         findInWindowsButton.description = "Replace in files";
  126.         findInWindowsButton.toolTipText = "Replace in files";
  127.         toolBar.setButton(13, findInWindowsButton);
  128.     
  129.         toolBar.restoreState();
  130.     }
  131. }
  132.  
  133. !!/Script
  134.  
  135.