Source Code Cross Referenced for AwtMenuBuilder.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » awtui » 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.awtui 
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.awtui;
014:
015:        import java.awt.Frame;
016:        import java.awt.Menu;
017:        import java.awt.MenuBar;
018:        import java.awt.Window;
019:
020:        import com.ibm.richtext.textpanel.MTextPanel;
021:
022:        import com.ibm.richtext.uiimpl.resources.FrameResources;
023:
024:        import com.ibm.richtext.uiimpl.*;
025:        import com.ibm.richtext.uiimpl.DialogItem.DialogFactory;
026:
027:        // TO DO:  Don't hard-code menu configurations.  Instead, specify them with
028:        // strings somehow.  This is an improvement over what we had, and it'll do
029:        // for now.
030:
031:        /**
032:         * AwtMenuBuilder creates a set of AWT menus for interacting
033:         * with an MTextPanel.  Future versions of this class may allow
034:         * clients to control the menu contents.
035:         * @see MTextPanel
036:         */
037:        public final class AwtMenuBuilder extends MenuBuilder {
038:
039:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
040:            private static final AwtMenuBuilder INSTANCE = new AwtMenuBuilder();
041:
042:            /**
043:             * Id for an Edit menu.  The Edit menu has the following items:
044:             * <ul>
045:             * <li><b>Undo</b> - invoke undo() on the MTextPanel</li>
046:             * <li><b>Redo</b> - invoke redo() on the MTextPanel</li>
047:             * <li><b>Cut</b> - invoke cut() on the MTextPanel</li>
048:             * <li><b>Copy</b> - invoke copy() on the MTextPanel</li>
049:             * <li><b>Paste</b> - invoke paste() on the MTextPanel</li>
050:             * <li><b>Clear</b> - invoke clear() on the MTextPanel</li>
051:             * <li><b>Select All</b> - invoke selectAll() on the MTextPanel</li>
052:             * </ul>
053:             */
054:            public static final int EDIT = MenuBuilder.EDIT;
055:            /**
056:             * Id for the point sizes menu.  The menu has items that set the size of a character
057:             * in a typeface.
058:             */
059:            public static final int SIZE = MenuBuilder.SIZE;
060:            /**
061:             * Id for a Style menu.  The Style menu has the following items:
062:             * <ul>
063:             * <li><b>Plain</b> - remove <code>WEIGHT</code>,
064:             *                    <code>POSTURE</code>,
065:             *                    <code>UNDERLINE</code> and
066:             *                    <code>STRIKETHROUGH</code> attributes from the
067:             * current selection</li>
068:             * <li><b>Bold</b> - add <code>{WEIGHT,WEIGHT_BOLD}</code> to
069:             * the current selection</li>
070:             * <li><b>Italic</b> - add <code>{POSTURE,POSTURE_ITALIC}</code> to
071:             * the current selection</li>
072:             * <li><b>Underline</b> - add <code>{UNDERLINE,UNDERLINE_ON}</code> to
073:             * the current selection</li>
074:             * <li><b>Strikethrough</b> - add <code>{STRIKETHROUGH,STRIKETHROUGH_ON}</code>
075:             * to the current selection</li>
076:             * <li><b>Font...</b> - display a dialog allowing the user to
077:             * select a typeface (font family) for the current selection</li>
078:             * <li><b>Forecolor...</b> - display a dialog allowing the user to
079:             * select a foreground color for the current selection</li>
080:             * <li><b>Backcolor...</b> - display a dialog allowing the user to
081:             * select a background color for the current selection</li>
082:             * </ul>
083:             */
084:            public static final int STYLE = MenuBuilder.STYLE;
085:            /**
086:             * Id for a paragraph alignment menu.  The menu has the following items:
087:             * <ul>
088:             * <li><b>Leading</b> - give selected paragraph(s) LEADING flush</li>
089:             * <li><b>Center</b> - give selected paragraph(s) CENTER flush</li>
090:             * <li><b>Trailing</b> - give selected paragraph(s) TRAILING flush</li>
091:             * <li><b>Justified</b> - give selected paragraph(s) full justification</li>
092:             * </ul>
093:             */
094:            public static final int FLUSH = MenuBuilder.FLUSH;
095:            /**
096:             * Id for a menu that sets the KeyRemap
097:             * on an MTextPanel.  The menu has the following items:
098:             * <ul>
099:             * <li><b>Default</b> - set KeyRemap to identity remap</li>
100:             * <li><b>Arabic</b> - set KeyRemap to Arabic transliteration</li>
101:             * <li><b>Hebrew</b> - set KeyRemap to Hebrew transliteration</li>
102:             * <li><b>Israel Nikud</b> - set KeyRemap to Israel Nikud</li>
103:             * <li><b>Thai Ketmanee</b> - set KeyRemap to Thai Ketmanee</li>
104:             * </ul>
105:             */
106:            public static final int KEYMAP = MenuBuilder.KEYMAP;
107:            /**
108:             * Id for a menu that sets
109:             * the primary run direction for a paragraph.  Run direction can be left-to-right,
110:             * right-to-left, or can use the default run direction from the Unicode bidi algorithm.
111:             */
112:            public static final int BIDI = MenuBuilder.BIDI;
113:            /**
114:             * Id for a menu with an <b>About</b> item.  When selected, 
115:             * the item displays a Frame containing some
116:             * self-promotional text.
117:             */
118:            public static final int ABOUT = MenuBuilder.ABOUT;
119:
120:            /**
121:             * Return an instance of AwtMenuBuilder.
122:             */
123:            public static AwtMenuBuilder getInstance() {
124:
125:                return INSTANCE;
126:            }
127:
128:            private MenuBar fMenuBar;
129:
130:            private AwtMenuBuilder() {
131:            }
132:
133:            /**
134:             * Add a standard set of menus to the given menu bar.  The menus 
135:             * will interact with the given MTextPanel.
136:             * @param menuBar the MenuBar to which menus are added
137:             * @param textPanel the MTextPanel with which the menus interact
138:             * @param frame a Frame to use as the parent of any dialogs created by a 
139:             *   a menu item.  If null, menu items which create dialogs will be omitted.
140:             */
141:            public void createMenus(MenuBar menuBar, MTextPanel textPanel,
142:                    Frame frame) {
143:
144:                createMenus(menuBar, textPanel, frame, defaultMenus);
145:            }
146:
147:            /**
148:             * Add a set of menus to the given menu bar.  The menus 
149:             * will interact with the given MTextPanel.
150:             * @param menuBar the MenuBar to which menus are added
151:             * @param textPanel the MTextPanel with which the menus interact
152:             * @param frame a Frame to use as the parent of any dialogs created by a 
153:             *   a menu item.  If null, menu items which create dialogs will be omitted.
154:             * @param menus an array of integer menu id's.  Each element of the
155:             *   array must be one of this class's menu id constants.  If null,
156:             *   the default menus are created.
157:             */
158:            public void createMenus(MenuBar menuBar, MTextPanel textPanel,
159:                    Frame frame, int[] menus) {
160:
161:                if (menus == null) {
162:                    menus = defaultMenus;
163:                }
164:
165:                synchronized (MItem.LOCK) {
166:
167:                    fMenuBar = menuBar;
168:                    doCreateMenus(textPanel, frame, menus);
169:                    fMenuBar = null;
170:                }
171:            }
172:
173:            protected void handleAddMenu(String key) {
174:
175:                Menu menu = new Menu(ResourceUtils.getResourceString(key));
176:                fMenuBar.add(menu);
177:                MItem.setItemFactory(new AwtMenuFactory(menu));
178:            }
179:
180:            protected DialogFactory createObjectDialogFactory(
181:                    final String dialogTitle, final String dialogMessage,
182:                    final Object key, final boolean character,
183:                    final String[] names, final Object[] values) {
184:
185:                final Frame dialogParent = fDialogParent;
186:
187:                return new DialogFactory() {
188:                    public Window createDialog(MTextPanel textPanel) {
189:                        return new ObjectDialog(dialogParent, dialogTitle,
190:                                dialogMessage, textPanel, key, character,
191:                                names, values);
192:                    }
193:                };
194:            }
195:
196:            protected DialogFactory createNumberDialogFactory(
197:                    final String dialogTitle, final String dialogMessage,
198:                    final Object key, final boolean character) {
199:
200:                final Frame dialogParent = fDialogParent;
201:
202:                return new DialogFactory() {
203:                    public Window createDialog(MTextPanel textPanel) {
204:                        return new NumberDialog(dialogParent, dialogTitle,
205:                                dialogMessage, textPanel, key, character, 1);
206:                    }
207:                };
208:            }
209:
210:            protected DialogFactory createAboutDialogFactory() {
211:
212:                return new DialogFactory() {
213:                    public Window createDialog(MTextPanel textPanel) {
214:                        String title = ResourceUtils
215:                                .getResourceString(FrameResources.ABOUT_TITLE);
216:                        return new MessageDialog(title, AboutText
217:                                .getAboutText());
218:                    }
219:                };
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.