home *** CD-ROM | disk | FTP | other *** search
/ Web Page Construction Kit 3.0 / Web Page Construction Kit 3.0.iso / pc / source / 3rdparty / java / jamba / dev / jambaobj.awx / TEMPLATE / TWIDOBJ.JAVA < prev   
Encoding:
Text File  |  1996-07-15  |  5.9 KB  |  267 lines

  1. $$IF(JAMBA_EXPLCOMMENTS)
  2. /**
  3. * Jamba code template for $$JAMBA_CLASSNAME$$Obj
  4. * twidobj.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 WidgetObj
  25. {
  26.     // Used in objStart to check if previously stopped
  27.     private boolean bStopped = false;
  28.  
  29. $$IF(JAMBA_EXPLCOMMENTS)
  30.     /**
  31.     * Called once, and only once, when object is first loaded. Use
  32.     * to perform one time object initialization
  33.     */
  34. $$ENDIF
  35.     public void objLoad ()
  36.     {
  37. $$IF(JAMBA_TODOCOMMENTS)
  38.         //# TODO - Insert custom code here
  39. $$ENDIF
  40.         super.objLoad();
  41.     }
  42.  
  43. $$IF(JAMBA_EXPLCOMMENTS)
  44.     /**
  45.     * Called each time the Jamba page containing the object is displayed. Use
  46.     * to allocate object resources. These resources should be freed in
  47.     * objFlush
  48.     */
  49. $$ENDIF
  50.     public final void objPrepare()
  51.     {
  52. $$IF(JAMBA_TODOCOMMENTS)
  53.         //# TODO - Insert custom code here
  54. $$ENDIF
  55.         // Create the component for the object.
  56.         if (theComponent == null)
  57.         {
  58.             theComponent = (Component)new TemplateWidgetImp(this);
  59.         }
  60.  
  61.         super.objPrepare();
  62.     }
  63.  
  64. $$IF(JAMBA_EXPLCOMMENTS)
  65.     /**
  66.     * Called each time the Jamba page containing the object is removed from
  67.     * the list of recently accessed Jamba pages. Use to free resources
  68.     * allocated by object.
  69.     */
  70. $$ENDIF
  71.     public void objFlush()
  72.     {
  73. $$IF(JAMBA_TODOCOMMENTS)
  74.         //# TODO - Insert custom code here
  75. $$ENDIF
  76.         super.objFlush();
  77.     }
  78.  
  79. $$IF(JAMBA_EXPLCOMMENTS)
  80.     /**
  81.     * Called in response to several events including the object being made
  82.     * visible and the HTML page containing the object being redisplayed.
  83.     */
  84. $$ENDIF
  85.     public void objStart()
  86.     {
  87.         // If object stopped by objStop(), restart it here
  88.         if (bStopped)
  89.         {
  90.             bStopped = false;
  91. $$IF(JAMBA_TODOCOMMENTS)
  92.         //# TODO - Insert custom code here
  93. $$ENDIF
  94.         }
  95.  
  96.         super.objStart();
  97.     }
  98.  
  99. $$IF(JAMBA_EXPLCOMMENTS)
  100.     /**
  101.     * Called in response to several events including the object being made
  102.     * not visible and the HTML page containing the object being changed
  103.     * within a web browser such that another HTML page can be displayed.
  104.     * Use to cease any ongoing object activity.
  105.     */
  106. $$ENDIF
  107.     public void objStop()
  108.     {
  109.         if (!bStopped)
  110.         {
  111. $$IF(JAMBA_TODOCOMMENTS)
  112.             //# TODO - Insert custom code here
  113. $$ENDIF
  114.               bStopped = true;
  115.         }
  116.  
  117.         super.objStop();
  118.     }
  119.  
  120. $$IF(JAMBA_EXPLCOMMENTS)
  121.     /**
  122.      * Called when object properties are set or changed
  123.      */
  124. $$ENDIF
  125.     public synchronized void objSetProp(String name, String value)
  126.     {
  127.         if (name.equals("property1"))
  128.         {
  129. $$IF(JAMBA_TODOCOMMENTS)
  130.             //# TODO - Insert custom code here
  131. $$ENDIF
  132.         }
  133.  
  134.         else if (name.equals("property2"))
  135.         {
  136. $$IF(JAMBA_TODOCOMMENTS)
  137.             //# TODO - Insert custom code here
  138. $$ENDIF
  139.         }
  140.  
  141.         // Default property handling
  142.         else super.objSetProp(name, value);
  143.     }
  144.  
  145. $$IF(JAMBA_EXPLCOMMENTS)
  146.     /**
  147.     * Called to retrieve the current value of an object property.
  148.     */
  149. $$ENDIF
  150.     public synchronized String objGetProp(String name)
  151.     {
  152.         // If object does not track a property value in member variables or
  153.         // does not modify properties without updating the object's property
  154.         // list, it can simply allow the default property handling to occur
  155.         // and not have a case for it in the following code
  156.         if (name.equals("property1"))
  157.         {
  158. $$IF(JAMBA_TODOCOMMENTS)
  159.             //# TODO - Insert custom code here
  160. $$ENDIF
  161.         }
  162.  
  163.         else if (name.equals("property2"))
  164.         {
  165. $$IF(JAMBA_TODOCOMMENTS)
  166.             //# TODO - Insert custom code here
  167. $$ENDIF
  168.         }
  169.  
  170.         return (super.objGetProp(name));
  171.     }
  172.  
  173. $$IF(JAMBA_EXPLCOMMENTS)
  174.     /**
  175.     * Called when an object methods has been called within a ToDo list.
  176.     */
  177. $$ENDIF
  178.     public synchronized boolean objDoMethod(String method, Vector args)
  179.     {
  180.         if (method.equals ("method1"))
  181.         {
  182. $$IF(JAMBA_TODOCOMMENTS)
  183.             //# TODO - Insert custom code here
  184. $$ENDIF
  185.         }
  186.         else if (method.equals ("method2"))
  187.         {
  188. $$IF(JAMBA_TODOCOMMENTS)
  189.             //# TODO - Insert custom code here
  190. $$ENDIF
  191.         }
  192.         else
  193.         {
  194.             return (super.objDoMethod(method, args));
  195.         }
  196.  
  197.         // The method was handled
  198.         return (true);
  199.     }
  200. }
  201.  
  202. $$IF(JAMBA_EXPLCOMMENTS)
  203. /**
  204. * Jamba code for TemplateWidgetImp. This is the actual Java componet
  205. * created for the object. You need to supply all painting and event
  206. * handling.
  207. *
  208. * This class can be modified to extend other Java components besides
  209. * $$JAMBA_CLASSEXTEND$$.
  210. */
  211. $$ENDIF
  212. class TemplateWidgetImp extends $$JAMBA_CLASSEXTEND$$
  213. {
  214.     // Handle to the Jamba object
  215.     private BaseObj obj;
  216.  
  217. $$IF(JAMBA_EXPLCOMMENTS)
  218.     /**
  219.     * Constructor to create component
  220.     */
  221. $$ENDIF
  222.     public TemplateWidgetImp (BaseObj obj)
  223.     {
  224.         // Create the component
  225.         super();
  226.  
  227.         // Save a handle to the Jamba object
  228.         this.obj = obj;
  229.  
  230. $$IF(JAMBA_TODOCOMMENTS)
  231.         //# TODO - Insert custom code here
  232. $$ENDIF
  233.     }
  234.  
  235. $$IF(JAMBA_EXPLCOMMENTS)
  236.     /**
  237.     * Sample paint method used to validate object creation
  238.     * For a canvas class you can override the paint member like this
  239.     * public void paint (Graphics g)
  240.     * {
  241.     *     g.drawString ("Object Is Alive", 10, 20);
  242.     * }
  243.     */
  244. $$ENDIF
  245.  
  246. $$IF(JAMBA_EXPLCOMMENTS)
  247.     /**
  248.     * Handle input events and generate corresponding Jamba events
  249.     */
  250. $$ENDIF
  251.     public boolean handleEvent(Event event)
  252.     {
  253.         switch (event.id)
  254.         {
  255.             //# Sample event handling
  256.             case Event.MOUSE_UP:
  257.                 obj.processAction ("click");
  258.                 break;
  259.  
  260.             default:
  261.                 return (false);
  262.         }
  263.  
  264.         return (true);
  265.     }
  266. }
  267.