home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-10-25 | 3.5 KB | 144 lines |
- /*
- * Copyright 1998 Symantec Corporation, All Rights Reserved.
- */
-
- package com.symantec.itools.vcafe.openapi.pluginapi;
-
- import java.awt.Window;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import symantec.itools.vcafe.plugin.BasePluginDialog;
- import com.symantec.itools.vcafe.openapi.VisualCafe;
-
- /**
- * The API used to integrate a dialog window into Visual Cafe.
- * By default, the application main frame wiindow will be made
- * the parent for this dialog box.
- *
- * @author Symantec Internet Tools Division
- * @version 1.0
- * @since VCafe 3.0
- */
- public class PluginDialog extends BasePluginDialog
- {
- /**
- * Create a modal dialog
- */
- public PluginDialog()
- {
- this(null, "", true);
- }
-
- /**
- * Create a modal/modeless dialog
- *
- * @param modal true for modal and false for modeless dialog box
- */
- public PluginDialog(boolean modal)
- {
- this(null, "", modal);
- }
-
- /**
- * Create a modeless dialog with the given title
- *
- * @param title The title on the frame
- */
- public PluginDialog(String title)
- {
- this(null, title, false);
- }
-
- /**
- * Create a modal/modeless dialog with the given title
- *
- * @param modal true for modal and false for modeless dialog box
- * @param title The title on the frame
- */
- public PluginDialog(String title, boolean modal)
- {
- this(null, title, modal);
- }
-
- /**
- * Create a modal/modeless dialog with the given title and parent
- *
- * @param parent the owner of the dialog
- * @param modal true for modal and false for modeless dialog box
- * @param title The title on the frame
- */
- public PluginDialog(Window parent, String title, boolean modal)
- {
- super(parent, title, modal);
- this.addKeyListener(new SymKey());
- }
-
- /**
- * This method is called by the the framework when online help is requested
- * by the user, usually by pressing F1 key. The default behaviour returns false,
- * meaning no help is available.
- *
- * This method will not get called if a help id is already specified by calling
- * <code>setHelpId</code>.
- *
- * When this method is called, you can bring up help by calling methods in
- * <code>VisualCafe</code> class.
- *
- * @return <code>true</code> if help is opened and <code>false</code> otherwise.
- * @see PluginDialog#setHelpId
- * @see VisualCafe#invokeHelp
- */
- protected boolean invokeHelp()
- {
- if (helpId != 0)
- {
- VisualCafe.getVisualCafe().invokeHelp(helpId);
- return true;
- }
- return false;
- }
-
- /**
- * Set the help id for this dialog. Pressing F1 on an active plug in dialog will
- * invoke online help displaying the link specified by the given id.
- *
- * @param id the help id to use for this view
- */
- public void setHelpId(int id)
- {
- helpId = id;
- super.setHelpId(id);
- }
-
- /**
- * Get the help id used by this dialog.
- *
- * @return the help id being used by this dialog
- */
- public int getHelpId()
- {
- return helpId;
- }
-
- /**
- * This method is called by the keyboard listener when the user presses
- * the Escape key. The default implementation closes this dialog box.
- */
- protected void closeDialog()
- {
- setVisible(false);
- dispose();
- }
-
- //-------------------- Keyboard listener --------------------
- class SymKey extends KeyAdapter
- {
- public void keyPressed(KeyEvent event)
- {
- if(event.getKeyCode() == KeyEvent.VK_ESCAPE)
- closeDialog();
- }
- }
-
- private int helpId = 0;
- }