01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.uiimpl;
14:
15: import com.ibm.richtext.textpanel.KeyRemap;
16: import com.ibm.richtext.textpanel.TextPanelEvent;
17: import com.ibm.richtext.textpanel.MTextPanel;
18: import com.ibm.richtext.uiimpl.resources.MenuData;
19:
20: public final class KeymapMenuItemSet extends ChoiceMenuItemSet {
21:
22: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
23:
24: public KeymapMenuItemSet(KeyRemap[] values, MenuData[] menuData) {
25:
26: super (values, menuData);
27: }
28:
29: protected void handleValueSelected(Object value) {
30:
31: MTextPanel textPanel = getTextPanel();
32: if (textPanel == null) {
33: throw new Error("Menu item is enabled when panel is null!");
34: }
35:
36: textPanel.setKeyRemap((KeyRemap) value);
37: }
38:
39: protected Object getCurrentValue() {
40:
41: MTextPanel textPanel = getTextPanel();
42: if (textPanel == null) {
43: throw new Error("Shouldn't call this without a text panel!");
44: }
45: return textPanel.getKeyRemap();
46: }
47:
48: public void textEventOccurred(TextPanelEvent event) {
49:
50: setChecked();
51: }
52:
53: public boolean respondsToEventType(int type) {
54:
55: return type == TextPanelEvent.KEYREMAP_CHANGED;
56: }
57:
58: }
|