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 java.awt.Window;
16: import java.awt.event.WindowAdapter;
17: import java.awt.event.WindowEvent;
18:
19: import com.ibm.richtext.textpanel.MTextPanel;
20: import com.ibm.richtext.uiimpl.resources.MenuData;
21:
22: public final class DialogItem extends CommandMenuItem {
23:
24: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
25:
26: public static abstract class DialogFactory {
27:
28: public abstract Window createDialog(MTextPanel textPanel);
29: }
30:
31: private DialogFactory fDialogFactory;
32: private Window fDialog = null;
33:
34: public DialogItem(MenuData menuData, DialogFactory dialogFactory) {
35:
36: super (menuData, true);
37: fDialogFactory = dialogFactory;
38: }
39:
40: protected void textPanelChanged() {
41: // do nothing
42: }
43:
44: protected boolean isEnabled() {
45:
46: // should never get called...
47: return true;
48: }
49:
50: public boolean respondsToEventType(int type) {
51:
52: return false;
53: }
54:
55: protected void performAction() {
56:
57: if (fDialog == null) {
58: MTextPanel panel = getTextPanel();
59: if (panel != null) {
60: fDialog = fDialogFactory.createDialog(panel);
61: fDialog.addWindowListener(new WindowAdapter() {
62: public void windowClosed(WindowEvent e) {
63: fDialog = null;
64: }
65: });
66: }
67: }
68: fDialog.show();
69: }
70: }
|