Source Code Cross Referenced for CommandMenuItem.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » uiimpl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.richtext.uiimpl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.
003:         *
004:         * The program is provided "as is" without any warranty express or
005:         * implied, including the warranty of non-infringement and the implied
006:         * warranties of merchantibility and fitness for a particular purpose.
007:         * IBM will not be liable for any damages suffered by you as a result
008:         * of using the Program. In no event will IBM be liable for any
009:         * special, indirect or consequential damages or lost profits even if
010:         * IBM has been advised of the possibility of their occurrence. IBM
011:         * will not be liable for any third party claims against you.
012:         */
013:        package com.ibm.richtext.uiimpl;
014:
015:        import java.util.EventObject;
016:
017:        import com.ibm.richtext.textpanel.MTextPanel;
018:        import com.ibm.richtext.textpanel.TextPanelEvent;
019:        import com.ibm.richtext.uiimpl.resources.MenuData;
020:
021:        public abstract class CommandMenuItem extends MenuItemSet {
022:
023:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
024:            private/*final*/MItem fItem;
025:
026:            protected abstract boolean isEnabled();
027:
028:            protected abstract void performAction();
029:
030:            protected CommandMenuItem(MenuData data) {
031:
032:                this (data, false);
033:            }
034:
035:            protected CommandMenuItem(MenuData data, boolean enableByDefault) {
036:
037:                fItem = MItem.createItem(data);
038:                fItem.addListener(new EventListener() {
039:                    public void eventOccurred(EventObject event) {
040:                        performAction();
041:                    }
042:                });
043:                fItem.setEnabled(enableByDefault);
044:            }
045:
046:            protected void textPanelChanged() {
047:
048:                MTextPanel textPanel = getTextPanel();
049:                if (textPanel == null) {
050:                    fItem.setEnabled(false);
051:                } else {
052:                    fItem.setEnabled(isEnabled());
053:                }
054:            }
055:
056:            public final void textEventOccurred(TextPanelEvent event) {
057:
058:                fItem.setEnabled(isEnabled());
059:            }
060:
061:            public static final class CutCopyClear extends CommandMenuItem {
062:
063:                public static final int CUT = 0;
064:                public static final int COPY = 1;
065:                public static final int CLEAR = 2;
066:
067:                private final int fKind;
068:
069:                public CutCopyClear(MenuData menuData, int kind) {
070:
071:                    super (menuData);
072:                    if (kind != CUT && kind != COPY && kind != CLEAR) {
073:                        throw new IllegalArgumentException("Invalid menu kind");
074:                    }
075:                    fKind = kind;
076:                }
077:
078:                protected boolean isEnabled() {
079:
080:                    MTextPanel panel = getTextPanel();
081:                    return panel.getSelectionStart() != panel.getSelectionEnd();
082:                }
083:
084:                public boolean respondsToEventType(int type) {
085:
086:                    return type == TextPanelEvent.SELECTION_EMPTY_CHANGED;
087:                }
088:
089:                protected void performAction() {
090:
091:                    MTextPanel panel = getTextPanel();
092:                    switch (fKind) {
093:                    case CUT:
094:                        panel.cut();
095:                        break;
096:                    case COPY:
097:                        panel.copy();
098:                        break;
099:                    case CLEAR:
100:                        panel.clear();
101:                        break;
102:                    }
103:                }
104:            }
105:
106:            public static final class UndoRedo extends CommandMenuItem {
107:
108:                public static final boolean UNDO = true;
109:                public static final boolean REDO = false;
110:
111:                private boolean fKind;
112:
113:                public UndoRedo(MenuData menuData, boolean kind) {
114:
115:                    super (menuData);
116:                    fKind = kind;
117:                }
118:
119:                protected boolean isEnabled() {
120:
121:                    MTextPanel panel = getTextPanel();
122:                    if (fKind == UNDO) {
123:                        return panel.canUndo();
124:                    } else {
125:                        return panel.canRedo();
126:                    }
127:                }
128:
129:                public boolean respondsToEventType(int type) {
130:
131:                    return type == TextPanelEvent.UNDO_STATE_CHANGED;
132:                }
133:
134:                protected void performAction() {
135:
136:                    MTextPanel panel = getTextPanel();
137:                    if (fKind == UNDO) {
138:                        panel.undo();
139:                    } else {
140:                        panel.redo();
141:                    }
142:                }
143:            }
144:
145:            public static final class Paste extends CommandMenuItem {
146:
147:                public Paste(MenuData menuData) {
148:
149:                    super (menuData);
150:                }
151:
152:                protected boolean isEnabled() {
153:
154:                    return getTextPanel().clipboardNotEmpty();
155:                }
156:
157:                public boolean respondsToEventType(int type) {
158:
159:                    return type == TextPanelEvent.CLIPBOARD_CHANGED;
160:                }
161:
162:                protected void performAction() {
163:
164:                    getTextPanel().paste();
165:                }
166:            }
167:
168:            public static final class SelectAll extends CommandMenuItem {
169:
170:                public SelectAll(MenuData menuData) {
171:
172:                    super (menuData);
173:                }
174:
175:                protected boolean isEnabled() {
176:
177:                    return true;
178:                }
179:
180:                public boolean respondsToEventType(int type) {
181:
182:                    return false;
183:                }
184:
185:                protected void performAction() {
186:
187:                    getTextPanel().selectAll();
188:                }
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.