]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/uiimpl/DialogItem.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / uiimpl / DialogItem.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.\r
3  *\r
4  * The program is provided "as is" without any warranty express or\r
5  * implied, including the warranty of non-infringement and the implied\r
6  * warranties of merchantibility and fitness for a particular purpose.\r
7  * IBM will not be liable for any damages suffered by you as a result\r
8  * of using the Program. In no event will IBM be liable for any\r
9  * special, indirect or consequential damages or lost profits even if\r
10  * IBM has been advised of the possibility of their occurrence. IBM\r
11  * will not be liable for any third party claims against you.\r
12  */\r
13 package com.ibm.richtext.uiimpl;\r
14 \r
15 import java.awt.Window;\r
16 import java.awt.event.WindowAdapter;\r
17 import java.awt.event.WindowEvent;\r
18 \r
19 import com.ibm.richtext.textpanel.MTextPanel;\r
20 import com.ibm.richtext.uiimpl.resources.MenuData;\r
21 \r
22 public final class DialogItem extends CommandMenuItem {\r
23     \r
24     static final String COPYRIGHT =\r
25                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
26     public static abstract class DialogFactory {\r
27         \r
28         public abstract Window createDialog(MTextPanel textPanel);\r
29     }\r
30     \r
31     private DialogFactory fDialogFactory;\r
32     private Window fDialog = null;\r
33     \r
34     public DialogItem(MenuData menuData,\r
35                       DialogFactory dialogFactory) {\r
36         \r
37         super(menuData, true);\r
38         fDialogFactory = dialogFactory;\r
39     }\r
40     \r
41     protected void textPanelChanged() {\r
42         // do nothing\r
43     }\r
44         \r
45     protected boolean isEnabled() {\r
46             \r
47         // should never get called...\r
48         return true;\r
49     }\r
50 \r
51     public boolean respondsToEventType(int type) {\r
52             \r
53         return false;\r
54     }\r
55 \r
56     protected void performAction() {\r
57 \r
58         if (fDialog == null) {\r
59             MTextPanel panel = getTextPanel();\r
60             if (panel != null) {\r
61                 fDialog = fDialogFactory.createDialog(panel);\r
62                 fDialog.addWindowListener(new WindowAdapter() {\r
63                     public void windowClosed(WindowEvent e) {\r
64                         fDialog = null;\r
65                     }\r
66                 });\r
67             }\r
68         }\r
69         fDialog.show();\r
70     }\r
71 }