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.resources;
14:
15: /**
16: * This class is used in resources to represent a Menu. It is
17: * just a name and an optional shortcut key.
18: */
19: public final class MenuData {
20:
21: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
22: private String fName;
23: private boolean fHasShortcut;
24: private char fShortcut;
25: private int fKeyCode;
26:
27: public MenuData(String name) {
28:
29: fName = name;
30: fHasShortcut = false;
31: }
32:
33: public MenuData(String name, char ch, int keyCode) {
34:
35: fName = name;
36: fHasShortcut = true;
37: fShortcut = ch;
38: fKeyCode = keyCode;
39: }
40:
41: public String getName() {
42:
43: return fName;
44: }
45:
46: public char getShortcutChar() {
47:
48: if (!fHasShortcut) {
49: throw new Error("Menu doesn't have shortcut");
50: }
51: return fShortcut;
52: }
53:
54: public int getShortcutKeyCode() {
55: if (!fHasShortcut) {
56: throw new Error("Menu doesn't have shortcut");
57: }
58: return fKeyCode;
59: }
60:
61: public boolean hasShortcut() {
62:
63: return fHasShortcut;
64: }
65: }
|