home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / javaapp / jamba / dev / jambaobj.awx / TEMPLATE / TROBJ.JAVA < prev    next >
Encoding:
Text File  |  1996-07-15  |  5.1 KB  |  247 lines

  1. $$IF(JAMBA_EXPLCOMMENTS)
  2. /**
  3. * Jamba code template for $$JAMBA_CLASSNAME$$Obj
  4. * trobj.java
  5. */
  6. $$ENDIF
  7.  
  8. // All Jamba objects are located in the objects package
  9. package Aimtech.objects;
  10.  
  11. // Standard Jamba imports
  12. import java.lang.*;
  13. import java.awt.*;
  14. import java.util.*;
  15. import Aimtech.utils.*;
  16. import Aimtech.effects.*;
  17. import Aimtech.smartpage.*;
  18.  
  19. $$IF(JAMBA_EXPLCOMMENTS)
  20. /**
  21. * Implementation of Jamba $$JAMBA_CLASSNAME$$Obj object
  22. */
  23. $$ENDIF
  24. public class $$JAMBA_CLASSNAME$$Obj extends BaseObj implements Runnable
  25. {
  26.     // Used in objStart to check if previously stopped
  27.     private boolean bStopped = false;
  28.  
  29.     // This object's thread
  30.     Thread thread = null;
  31.  
  32. $$IF(JAMBA_EXPLCOMMENTS)
  33.     /**
  34.     * Called once, and only once, when object is first loaded. Use
  35.     * to perform one time object initialization
  36.     */
  37. $$ENDIF
  38.     public void objLoad ()
  39.     {
  40. $$IF(JAMBA_TODOCOMMENTS)
  41.         //# TODO - Insert custom code here
  42. $$ENDIF
  43.         super.objLoad();
  44.     }
  45.  
  46. $$IF(JAMBA_EXPLCOMMENTS)
  47.     /**
  48.     * Called each time the Jamba page containing the object is displayed. Use
  49.     * to allocate object resources. These resources should be freed in
  50.     * objFlush
  51.     */
  52. $$ENDIF
  53.     public final void objPrepare()
  54.     {
  55. $$IF(JAMBA_TODOCOMMENTS)
  56.         //# TODO - Insert custom code here
  57. $$ENDIF
  58.         super.objPrepare();
  59.     }
  60.  
  61. $$IF(JAMBA_EXPLCOMMENTS)
  62.     /**
  63.     * Called each time the Jamba page containing the object is removed from
  64.     * the list of recently accessed Jamba pages. Use to free resources
  65.     * allocated by object.
  66.     */
  67. $$ENDIF
  68.     public void objFlush()
  69.     {
  70. $$IF(JAMBA_TODOCOMMENTS)
  71.         //# TODO - Insert custom code here
  72. $$ENDIF
  73.         super.objFlush();
  74.     }
  75.  
  76. $$IF(JAMBA_EXPLCOMMENTS)
  77.     /**
  78.     * Called in response to several events including the object being made
  79.     * visible and the HTML page containing the object being redisplayed.
  80.     */
  81. $$ENDIF
  82.     public void objStart()
  83.     {
  84.         // If object stopped by objStop(), restart it here
  85.         if (bStopped)
  86.         {
  87. $$IF(JAMBA_TODOCOMMENTS)
  88.             //# TODO - Insert custom code here
  89. $$ENDIF
  90.             start();
  91.             bStopped = false;
  92.         }
  93.  
  94.         super.objStart();
  95.     }
  96.  
  97. $$IF(JAMBA_EXPLCOMMENTS)
  98.     /**
  99.     * Called in response to several events including the object being made
  100.     * not visible and the HTML page containing the object being changed
  101.     * within a web browser such that another HTML page can be displayed.
  102.     * Use to cease any ongoing object activity.
  103.     */
  104. $$ENDIF
  105.     public void objStop()
  106.     {
  107.         if (!bStopped)
  108.         {
  109. $$IF(JAMBA_TODOCOMMENTS)
  110.             //# TODO - Insert custom code here
  111. $$ENDIF
  112.             stop();
  113.               bStopped = true;
  114.         }
  115.  
  116.         super.objStop();
  117.     }
  118.  
  119. $$IF(JAMBA_EXPLCOMMENTS)
  120.     /**
  121.      * Called when object properties are set or changed
  122.      */
  123. $$ENDIF
  124.     public synchronized void objSetProp(String name, String value)
  125.     {
  126.         if (name.equals("property1"))
  127.         {
  128. $$IF(JAMBA_TODOCOMMENTS)
  129.             //# TODO - Insert custom code here
  130. $$ENDIF
  131.         }
  132.  
  133.         else if (name.equals("property2"))
  134.         {
  135. $$IF(JAMBA_TODOCOMMENTS)
  136.             //# TODO - Insert custom code here
  137. $$ENDIF
  138.         }
  139.  
  140.         // Default property handling
  141.         else super.objSetProp(name, value);
  142.     }
  143.  
  144. $$IF(JAMBA_EXPLCOMMENTS)
  145.     /**
  146.     * Called to retrieve the current value of an object property.
  147.     */
  148. $$ENDIF
  149.     public synchronized String objGetProp(String name)
  150.     {
  151.         // If object does not track a property value in member variables or
  152.         // does not modify properties without updating the object's property
  153.         // list, it can simply allow the default property handling to occur
  154.         // and not have a case for it in the following code
  155.         if (name.equals("property1"))
  156.         {
  157. $$IF(JAMBA_TODOCOMMENTS)
  158.             //# TODO - Insert custom code here
  159. $$ENDIF
  160.         }
  161.  
  162.         else if (name.equals("property2"))
  163.         {
  164. $$IF(JAMBA_TODOCOMMENTS)
  165.             //# TODO - Insert custom code here
  166. $$ENDIF
  167.         }
  168.  
  169.         return (super.objGetProp(name));
  170.     }
  171.  
  172. $$IF(JAMBA_EXPLCOMMENTS)
  173.     /**
  174.     * Called when an object methods has been called within a ToDo list.
  175.     */
  176. $$ENDIF
  177.     public synchronized boolean objDoMethod(String method, Vector args)
  178.     {
  179.         if (method.equals ("method1"))
  180.         {
  181. $$IF(JAMBA_TODOCOMMENTS)
  182.             //# TODO - Insert custom code here
  183. $$ENDIF
  184.         }
  185.         else if (method.equals ("method2"))
  186.         {
  187. $$IF(JAMBA_TODOCOMMENTS)
  188.             //# TODO - Insert custom code here
  189. $$ENDIF
  190.         }
  191.         else
  192.         {
  193.             return (super.objDoMethod(method, args));
  194.         }
  195.  
  196.         // The method was handled
  197.         return (true);
  198.     }
  199.  
  200. $$IF(JAMBA_EXPLCOMMENTS)
  201.     /**
  202.     * Standard start method used by Jamba objects
  203.     */
  204. $$ENDIF
  205.     public void start ()
  206.     {
  207.         if (thread == null)
  208.         {
  209.             thread = new Thread (this);
  210.         }
  211.  
  212.         if (!thread.isAlive())
  213.         {
  214.             thread.start();
  215.         }
  216.     }
  217.  
  218. $$IF(JAMBA_EXPLCOMMENTS)
  219.     /**
  220.     * Standard stop method used by Jamba objects
  221.     */
  222. $$ENDIF
  223.     public void stop ()
  224.     {
  225.         if (thread != null)
  226.         {
  227.             Thread tmp = thread;
  228.             thread = null;
  229.             tmp.stop();
  230.         }
  231.     }
  232.  
  233. $$IF(JAMBA_EXPLCOMMENTS)
  234.     /**
  235.     * Object's run method for it's thread
  236.     */
  237. $$ENDIF
  238.     public void run ()
  239.     {
  240. $$IF(JAMBA_TODOCOMMENTS)
  241.         //# TODO - Insert custom code here
  242. $$ENDIF
  243.         // Must be last line in method
  244.         stop();
  245.     }
  246. }
  247.