Guest User

Untitled

a guest
Apr 18th, 2018
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////////////////////////////////////////////////////////////////////////////
  2. // ADOBE SYSTEMS INCORPORATED
  3. // Copyright 2007 Adobe Systems Incorporated
  4. // All Rights Reserved
  5. //
  6. // NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the
  7. // terms of the Adobe license agreement accompanying it.  If you have received this file from a
  8. // source other than Adobe, then your use, modification, or distribution of it requires the prior
  9. // written permission of Adobe.
  10. /////////////////////////////////////////////////////////////////////////////
  11.  
  12. /**
  13.   @fileoverview Shows how to use a progress bar ScriptUI component.
  14.   @class Shows how to use a progress bar ScriptUI component.
  15.  
  16.   <h4>Usage</h4>
  17.   <ol>
  18.   <li> Open this file and run it in the ExtendScript Toolkit.
  19.        You can choose as the target any application that supports ScriptUI
  20.   <li> Press Start in the displayed dialog and watch progress bar update
  21.   <li> Press Reset to return the progress bar to its initial state
  22.   </ol>
  23.  
  24.   <h4>Description</h4>
  25.  
  26.    <p>Creates a dialog containing a progress bar, a button that updates
  27.    its value periodically, and another button that resets the progress to 0.<br />
  28.  
  29.  
  30.   @constructor Constructor.
  31.  */
  32. function SnpCreateProgressBar ()
  33. {
  34.     this.windowRef = null;
  35. }
  36.  
  37. /**
  38.  Create a window, add a progress-bar control, a text label, and buttons.
  39.  Define behavior for the buttons that increment or reset the progress value.
  40.  
  41.  @return True if the snippet ran as expected, false  otherwise.
  42.  @type Boolean
  43. */
  44. SnpCreateProgressBar.prototype.run = function() {
  45.     var retval = true;
  46.    
  47.     // Create a palette-type window (a modeless or floating dialog),
  48.     var win = new Window("palette", "SnpCreateProgressBar", [150, 150, 600, 300]);
  49.     this.windowRef = win;
  50.     // Add a panel to contain the components
  51.     win.pnl = win.add("panel", [10, 10, 440, 100], "Click Start to move the Progress bar");
  52.  
  53.     // Add a progress bar with a label and initial value of 0, max value of 200.
  54.     win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], "Progress");
  55.     win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], 0, 200);
  56.    
  57.     // Add buttons
  58.     win.goButton = win.add("button", [25, 110, 125, 140], "Start");
  59.     win.resetButton = win.add("button", [150, 110, 250, 140], "Reset");
  60.     win.doneButton = win.add("button", [310, 110, 410, 140], "Done");
  61.  
  62.  
  63.     // Define behavior for the "Done" button
  64.     win.doneButton.onClick = function ()
  65.     {
  66.         win.close();
  67.     };
  68.    
  69.     // Define behavior for the "Start" button
  70.     win.goButton.onClick = function ()
  71.     {
  72.         while(win.pnl.progBar.value < win.pnl.progBar.maxvalue)
  73.         {
  74.             // this is what causes the progress bar increase its progress
  75.             win.pnl.progBar.value++;
  76.             $.sleep(10);
  77.         }
  78.         $.writeln("Progress Bar Complete");
  79.        
  80.     };
  81.  
  82.     // Define behavior for the "Reset" button
  83.     win.resetButton.onClick = function()
  84.     {
  85.         // set the progress back to 0
  86.         win.pnl.progBar.value = 0;
  87.         $.writeln("Progress Bar Reset");
  88.     }
  89.  
  90.     // Display the window
  91.     win.show();
  92.  
  93.     return retval;
  94. }
  95.  
  96. /**
  97.  "main program": construct an anonymous instance and run it
  98.   as long as we are not unit-testing this snippet.
  99. */
  100. if(typeof(SnpCreateProgressBar_unitTest) == "undefined") {
  101.     new SnpCreateProgressBar().run();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment