home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / PluginDialog.java < prev    next >
Text File  |  1998-10-25  |  4KB  |  144 lines

  1. /*
  2.  * Copyright 1998 Symantec Corporation, All Rights Reserved.
  3.  */
  4.  
  5. package com.symantec.itools.vcafe.openapi.pluginapi;
  6.  
  7. import java.awt.Window;
  8. import java.awt.event.KeyAdapter;
  9. import java.awt.event.KeyEvent;
  10. import symantec.itools.vcafe.plugin.BasePluginDialog;
  11. import com.symantec.itools.vcafe.openapi.VisualCafe;
  12.  
  13. /**
  14.  * The API used to integrate a dialog window into Visual Cafe.
  15.  * By default, the application main frame wiindow will be made
  16.  * the parent for this dialog box.
  17.  *
  18.  * @author Symantec Internet Tools Division
  19.  * @version 1.0
  20.  * @since VCafe 3.0
  21.  */
  22. public class PluginDialog extends BasePluginDialog
  23. {
  24.     /**
  25.      * Create a modal dialog
  26.      */
  27.     public PluginDialog()
  28.     {
  29.         this(null, "", true);
  30.     }
  31.  
  32.     /**
  33.      * Create a modal/modeless dialog
  34.      *
  35.      * @param modal        true for modal and false for modeless dialog box
  36.      */
  37.     public PluginDialog(boolean modal)
  38.     {
  39.         this(null, "", modal);
  40.     }
  41.  
  42.     /**
  43.      * Create a modeless dialog with the given title
  44.      *
  45.      * @param title        The title on the frame
  46.      */
  47.     public PluginDialog(String title)
  48.     {
  49.         this(null, title, false);
  50.     }
  51.  
  52.     /**
  53.      * Create a modal/modeless dialog with the given title
  54.      *
  55.      * @param modal        true for modal and false for modeless dialog box
  56.      * @param title        The title on the frame
  57.      */
  58.     public PluginDialog(String title, boolean modal)
  59.     {
  60.         this(null, title, modal);
  61.     }
  62.  
  63.     /**
  64.      * Create a modal/modeless dialog with the given title and parent
  65.      *
  66.      * @param parent    the owner of the dialog
  67.      * @param modal        true for modal and false for modeless dialog box
  68.      * @param title        The title on the frame
  69.      */
  70.     public PluginDialog(Window parent, String title, boolean modal)
  71.     {
  72.         super(parent, title, modal);
  73.         this.addKeyListener(new SymKey());
  74.     }
  75.  
  76.     /**
  77.      * This method is called by the the framework when online help is requested
  78.      * by the user, usually by pressing F1 key. The default behaviour returns false,
  79.      * meaning no help is available.
  80.      *
  81.      * This method will not get called if a help id is already specified by calling
  82.      * <code>setHelpId</code>.
  83.      *
  84.      * When this method is called, you can bring up help by calling methods in
  85.      * <code>VisualCafe</code> class.
  86.      *
  87.      * @return <code>true</code> if help is opened and <code>false</code> otherwise.
  88.      * @see PluginDialog#setHelpId
  89.      * @see VisualCafe#invokeHelp
  90.      */
  91.     protected boolean invokeHelp()
  92.     {
  93.         if (helpId != 0)
  94.         {
  95.             VisualCafe.getVisualCafe().invokeHelp(helpId);
  96.             return true;
  97.         }
  98.         return false;
  99.     }
  100.  
  101.     /**
  102.      * Set the help id for this dialog. Pressing F1 on an active plug in dialog will
  103.      * invoke online help displaying the link specified by the given id.
  104.      *
  105.      * @param id     the help id to use for this view
  106.      */
  107.     public void setHelpId(int id)
  108.     {
  109.         helpId = id;
  110.         super.setHelpId(id);
  111.     }
  112.  
  113.     /**
  114.      * Get the help id used by this dialog.
  115.      *
  116.      * @return      the help id being used by this dialog
  117.      */
  118.     public int getHelpId()
  119.     {
  120.         return helpId;
  121.     }
  122.  
  123.     /**
  124.      * This method is called by the keyboard listener when the user presses
  125.      * the Escape key. The default implementation closes this dialog box.
  126.      */
  127.     protected void closeDialog()
  128.     {
  129.         setVisible(false);
  130.         dispose();
  131.     }
  132.  
  133.     //-------------------- Keyboard listener --------------------
  134.     class SymKey extends KeyAdapter
  135.     {
  136.         public void keyPressed(KeyEvent event)
  137.         {
  138.             if(event.getKeyCode() == KeyEvent.VK_ESCAPE)
  139.                 closeDialog();
  140.         }
  141.     }
  142.  
  143.     private int helpId = 0;
  144. }