]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/uiimpl/MItem.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / uiimpl / MItem.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.util.Vector;\r
16 import java.util.EventObject;\r
17 \r
18 import com.ibm.richtext.uiimpl.resources.MenuData;\r
19 \r
20 public abstract class MItem {\r
21 \r
22     static final String COPYRIGHT =\r
23                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
24     private Vector fListeners = new Vector(2);\r
25     private EventObject fEvent = new EventObject(this);\r
26     \r
27     public abstract void setEnabled(boolean enabled);\r
28     public abstract void setState(boolean checked);\r
29     \r
30     public final void addListener(EventListener listener) {\r
31         \r
32         fListeners.addElement(listener);\r
33     }\r
34     \r
35     public final void removeListener(EventListener listener) {\r
36         \r
37         fListeners.removeElement(listener);\r
38     }\r
39     \r
40     protected void handleSelected() {\r
41             \r
42         int length = fListeners.size();\r
43         for (int i=0; i < length; i++) {\r
44             EventListener l = (EventListener) fListeners.elementAt(i);\r
45             l.eventOccurred(fEvent);\r
46         }\r
47     }\r
48     \r
49     // factory stuff\r
50     \r
51     /**\r
52      * Clients should synchronize on LOCK while setting and using\r
53      * global factory.\r
54      */\r
55     public static final Object LOCK = new Object();\r
56     \r
57     public static interface ItemFactory {\r
58         \r
59         public MItem createItem(MenuData menuData);\r
60         public MItem createCheckboxItem(MenuData menuData);\r
61         public void createSeparator();\r
62     }\r
63     \r
64     private static ItemFactory fgFactory;\r
65     \r
66     public static MItem createItem(MenuData menuData) {\r
67         \r
68         return fgFactory.createItem(menuData);\r
69     }\r
70     \r
71     public static MItem createCheckboxItem(MenuData menuData) {\r
72         \r
73         return fgFactory.createCheckboxItem(menuData);\r
74     }\r
75     \r
76     public static void setItemFactory(ItemFactory factory) {\r
77         \r
78         fgFactory = factory;\r
79     }\r
80     \r
81     public static ItemFactory getItemFactory() {\r
82         \r
83         return fgFactory;\r
84     }\r
85 }\r