2 * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
\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
13 package com.ibm.richtext.uiimpl;
\r
15 import java.util.Vector;
\r
16 import java.util.EventObject;
\r
18 import com.ibm.richtext.uiimpl.resources.MenuData;
\r
20 public abstract class MItem {
\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
27 public abstract void setEnabled(boolean enabled);
\r
28 public abstract void setState(boolean checked);
\r
30 public final void addListener(EventListener listener) {
\r
32 fListeners.addElement(listener);
\r
35 public final void removeListener(EventListener listener) {
\r
37 fListeners.removeElement(listener);
\r
40 protected void handleSelected() {
\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
52 * Clients should synchronize on LOCK while setting and using
\r
55 public static final Object LOCK = new Object();
\r
57 public static interface ItemFactory {
\r
59 public MItem createItem(MenuData menuData);
\r
60 public MItem createCheckboxItem(MenuData menuData);
\r
61 public void createSeparator();
\r
64 private static ItemFactory fgFactory;
\r
66 public static MItem createItem(MenuData menuData) {
\r
68 return fgFactory.createItem(menuData);
\r
71 public static MItem createCheckboxItem(MenuData menuData) {
\r
73 return fgFactory.createCheckboxItem(menuData);
\r
76 public static void setItemFactory(ItemFactory factory) {
\r
78 fgFactory = factory;
\r
81 public static ItemFactory getItemFactory() {
\r