src/main/java/xelfi/top/TopDialog.java
author Jaroslav Tulach <jaroslav.tulach@xelfi.cz>
Tue, 17 Jan 2017 21:09:05 +0100
changeset 7 e25795e78b78
parent 0 189280700bc7
permissions -rw-r--r--
Allow access to getBase from the same package
     1 /**  Top level desktop dialog
     2 * @author Filip Dvorak
     3 * @version 2.0
     4 */
     5 
     6 package xelfi.top;
     7 
     8 import java.awt.*;
     9 //import java.util.*;
    10 
    11 //import xelfi.design.forms.XelfiDesignForm;
    12 //import xelfi.compiler.Output;
    13 
    14   /** Inherit this class to create a xelfi top level desktop dialog window.
    15    */
    16 public class TopDialog extends Dialog
    17 {
    18   private TopWindowBase base;
    19 
    20   /** Calls matching constructor of Dialog. Parent will be xelfi main window.*/
    21   public TopDialog(String title, boolean modal)
    22   {
    23     super(TopLevel.getMenu(), title, modal);
    24     base = new TopWindowBase(this);
    25   }
    26 
    27   /** Calls matching constructor of Dialog. */
    28   public TopDialog(Frame parent, boolean modal)
    29   {
    30     super(parent, modal);
    31     base = new TopWindowBase(this);
    32   }
    33 
    34   /** Calls matching constructor of Dialog. */
    35   public TopDialog(Frame parent, String title, boolean modal)
    36   {
    37     super(parent, title, modal);
    38     base = new TopWindowBase(this);
    39   }
    40 
    41   public boolean handleEvent(Event ev)
    42   {
    43     if(base.handleEvent(ev)) return true;
    44     else return super.handleEvent(ev);
    45   }
    46 
    47     /** Handles Window menu items updating, setting window positions, etc. */
    48   public void show()
    49   {
    50     base.beforeShow();
    51     // Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    52     super.show();
    53   }
    54 
    55     /** Handles Window menu items updating. */
    56   public void hide()
    57   {
    58     super.hide();
    59     base.afterHide();
    60   }
    61 
    62   /** Handles focus switchinhg. The system needs to know the window that has got the focus. */
    63   public boolean gotFocus(Event ev, Object what)
    64   {
    65     boolean bas = base.gotFocus(ev, what);
    66     boolean par = super.gotFocus(ev, what);
    67     return bas || par;
    68   }
    69 
    70   /** Handles focus switchinhg. The system needs to know the window that has got the focus. */
    71   public boolean lostFocus(Event ev, Object what)
    72   {
    73     boolean bas = base.lostFocus(ev, what);
    74     boolean par = super.lostFocus(ev, what);
    75     return bas || par;
    76   }
    77 
    78     /** Key shortcuts */
    79   public boolean keyDown(Event  e, int  key)
    80   {
    81     if(base.keyDown(e, key)) return true;
    82     else return super.keyDown(e, key);
    83   }
    84 
    85     /** Should be called before closing the frame is no longer needed. */
    86   public void dispose()
    87   {
    88     base.done();
    89     super.dispose();
    90   }
    91 
    92     /** Adds item to the list of focused items for this frame. Focused items are items that will be
    93       automatically enabled/disabled when the frame receives/looses a focus.
    94       @param itemId new focused item. */
    95   public void addFocusedItem(int itemId)
    96   {
    97     base.addFocusedItem(itemId);
    98   }
    99 
   100     /** Removes item from the list of focused items for this frame. Focused items are items that will be
   101       automatically enabled/disabled when the frame receives/looses a focus.
   102       @param itemId focused item to remove */
   103   public void removeFocusedItem(int itemId)
   104   {
   105     base.removeFocusedItem(itemId);
   106   }
   107 
   108   protected TopWindowBase getBase()
   109   {
   110     return base;
   111   }
   112 }
   113 
   114