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