Source Code Cross Referenced for RichTextArea.java in  » Ajax » GWT » com » google » gwt » user » client » ui » 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 » Ajax » GWT » com.google.gwt.user.client.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.user.client.ui;
017:
018:        import com.google.gwt.core.client.GWT;
019:        import com.google.gwt.user.client.DOM;
020:        import com.google.gwt.user.client.Event;
021:        import com.google.gwt.user.client.ui.impl.RichTextAreaImpl;
022:
023:        /**
024:         * A rich text editor that allows complex styling and formatting.
025:         * 
026:         * Because some browsers do not support rich text editing, and others support
027:         * only a limited subset of functionality, there are two formatter interfaces,
028:         * accessed via {@link #getBasicFormatter()} and {@link #getExtendedFormatter()}.
029:         * A browser that does not support rich text editing at all will return
030:         * <code>null</code> for both of these, while one that supports only the basic
031:         * functionality will return <code>null</code> for the latter.
032:         * 
033:         * <p>
034:         * <img class='gallery' src='RichTextArea.png'/>
035:         * </p>
036:         * 
037:         * <h3>CSS Style Rules</h3>
038:         * <ul class="css">
039:         * <li>.gwt-RichTextArea { }</li>
040:         * </ul>
041:         */
042:        public class RichTextArea extends FocusWidget implements  HasHTML,
043:                SourcesMouseEvents {
044:
045:            /**
046:             * This interface is used to access basic formatting options, when available.
047:             * If the implementation supports basic formatting, then
048:             * {@link RichTextArea#getBasicFormatter()} will return an instance of this
049:             * class.
050:             */
051:            public interface BasicFormatter {
052:
053:                /**
054:                 * Gets the background color.
055:                 * 
056:                 * @return the background color
057:                 */
058:                String getBackColor();
059:
060:                /**
061:                 * Gets the foreground color.
062:                 * 
063:                 * @return the foreground color
064:                 */
065:                String getForeColor();
066:
067:                /**
068:                 * Is the current region bold?
069:                 * 
070:                 * @return true if the current region is bold
071:                 */
072:                boolean isBold();
073:
074:                /**
075:                 * Is the current region italic?
076:                 * 
077:                 * @return true if the current region is italic
078:                 */
079:                boolean isItalic();
080:
081:                /**
082:                 * Is the current region subscript?
083:                 * 
084:                 * @return true if the current region is subscript
085:                 */
086:                boolean isSubscript();
087:
088:                /**
089:                 * Is the current region superscript?
090:                 * 
091:                 * @return true if the current region is superscript
092:                 */
093:                boolean isSuperscript();
094:
095:                /**
096:                 * Is the current region underlined?
097:                 * 
098:                 * @return true if the current region is underlined
099:                 */
100:                boolean isUnderlined();
101:
102:                /**
103:                 * Selects all the text.
104:                 */
105:                void selectAll();
106:
107:                /**
108:                 * Sets the background color.
109:                 * 
110:                 * @param color the new background color
111:                 */
112:                void setBackColor(String color);
113:
114:                /**
115:                 * Sets the font name.
116:                 * 
117:                 * @param name the new font name
118:                 */
119:                void setFontName(String name);
120:
121:                /**
122:                 * Sets the font size.
123:                 * 
124:                 * @param fontSize the new font size
125:                 */
126:                void setFontSize(FontSize fontSize);
127:
128:                /**
129:                 * Sets the foreground color.
130:                 * 
131:                 * @param color the new foreground color
132:                 */
133:                void setForeColor(String color);
134:
135:                /**
136:                 * Sets the justification.
137:                 * 
138:                 * @param justification the new justification
139:                 */
140:                void setJustification(Justification justification);
141:
142:                /**
143:                 * Toggles bold.
144:                 */
145:                void toggleBold();
146:
147:                /**
148:                 * Toggles italic.
149:                 */
150:                void toggleItalic();
151:
152:                /**
153:                 * Toggles subscript.
154:                 */
155:                void toggleSubscript();
156:
157:                /**
158:                 * Toggles superscript.
159:                 */
160:                void toggleSuperscript();
161:
162:                /**
163:                 * Toggles underline.
164:                 */
165:                void toggleUnderline();
166:            }
167:
168:            /**
169:             * This interface is used to access full formatting options, when available.
170:             * If the implementation supports full formatting, then
171:             * {@link RichTextArea#getExtendedFormatter()} will return an instance of this
172:             * class.
173:             */
174:            public interface ExtendedFormatter extends BasicFormatter {
175:
176:                /**
177:                 * Creates a link to the supplied URL.
178:                 * 
179:                 * @param url the URL to be linked to
180:                 */
181:                void createLink(String url);
182:
183:                /**
184:                 * Inserts a horizontal rule.
185:                 */
186:                void insertHorizontalRule();
187:
188:                /**
189:                 * Inserts an image element.
190:                 * 
191:                 * @param url the url of the image to be inserted
192:                 */
193:                void insertImage(String url);
194:
195:                /**
196:                 * Starts an numbered list. Indentation will create nested items.
197:                 */
198:                void insertOrderedList();
199:
200:                /**
201:                 * Starts an bulleted list. Indentation will create nested items.
202:                 */
203:                void insertUnorderedList();
204:
205:                /**
206:                 * Is the current region strikethrough?
207:                 * 
208:                 * @return true if the current region is strikethrough
209:                 */
210:                boolean isStrikethrough();
211:
212:                /**
213:                 * Left indent.
214:                 */
215:                void leftIndent();
216:
217:                /**
218:                 * Removes all formatting on the selected text.
219:                 */
220:                void removeFormat();
221:
222:                /**
223:                 * Removes any link from the selected text.
224:                 */
225:                void removeLink();
226:
227:                /**
228:                 * Right indent.
229:                 */
230:                void rightIndent();
231:
232:                /**
233:                 * Toggles strikethrough.
234:                 */
235:                void toggleStrikethrough();
236:            }
237:
238:            /**
239:             * Font size enumeration. Represents the seven basic HTML font sizes, as
240:             * defined in CSS.
241:             */
242:            public static class FontSize {
243:
244:                /**
245:                 * Represents an XX-Small font.
246:                 */
247:                public static final FontSize XX_SMALL = new FontSize(1);
248:
249:                /**
250:                 * Represents an X-Small font.
251:                 */
252:                public static final FontSize X_SMALL = new FontSize(2);
253:
254:                /**
255:                 * Represents a Small font.
256:                 */
257:                public static final FontSize SMALL = new FontSize(3);
258:
259:                /**
260:                 * Represents a Medium font.
261:                 */
262:                public static final FontSize MEDIUM = new FontSize(4);
263:
264:                /**
265:                 * Represents a Large font.
266:                 */
267:                public static final FontSize LARGE = new FontSize(5);
268:
269:                /**
270:                 * Represents an X-Large font.
271:                 */
272:                public static final FontSize X_LARGE = new FontSize(6);
273:
274:                /**
275:                 * Represents an XX-Large font.
276:                 */
277:                public static final FontSize XX_LARGE = new FontSize(7);
278:
279:                private int number;
280:
281:                private FontSize(int number) {
282:                    this .number = number;
283:                }
284:
285:                /**
286:                 * Gets the HTML font number associated with this font size.
287:                 * 
288:                 * @return an integer from 1 to 7 inclusive
289:                 */
290:                public int getNumber() {
291:                    return number;
292:                }
293:
294:                @Override
295:                public String toString() {
296:                    return Integer.toString(number);
297:                }
298:            }
299:
300:            /**
301:             * Justification enumeration. The three values are <code>left</code>,
302:             * <code>right</code>, <code>center</code>.
303:             */
304:            public static class Justification {
305:
306:                /**
307:                 * Center justification.
308:                 */
309:                public static final Justification CENTER = new Justification(
310:                        "Center");
311:
312:                /**
313:                 * Left justification.
314:                 */
315:                public static final Justification LEFT = new Justification(
316:                        "Left");
317:
318:                /**
319:                 * Right justification.
320:                 */
321:                public static final Justification RIGHT = new Justification(
322:                        "Right");
323:
324:                private String tag;
325:
326:                private Justification(String tag) {
327:                    this .tag = tag;
328:                }
329:
330:                @Override
331:                public String toString() {
332:                    return "Justify " + tag;
333:                }
334:            }
335:
336:            private RichTextAreaImpl impl = GWT.create(RichTextAreaImpl.class);
337:            private MouseListenerCollection mouseListeners;
338:
339:            /**
340:             * Creates a new, blank {@link RichTextArea} object with no stylesheet.
341:             */
342:            public RichTextArea() {
343:                setElement(impl.getElement());
344:                setStyleName("gwt-RichTextArea");
345:            }
346:
347:            public void addMouseListener(MouseListener listener) {
348:                if (mouseListeners == null) {
349:                    mouseListeners = new MouseListenerCollection();
350:                }
351:                mouseListeners.add(listener);
352:            }
353:
354:            /**
355:             * Gets the basic rich text formatting interface.
356:             * 
357:             * @return <code>null</code> if basic formatting is not supported
358:             */
359:            public BasicFormatter getBasicFormatter() {
360:                if ((impl instanceof  BasicFormatter)
361:                        && (impl.isBasicEditingSupported())) {
362:                    return (BasicFormatter) impl;
363:                }
364:                return null;
365:            }
366:
367:            /**
368:             * Gets the full rich text formatting interface.
369:             * 
370:             * @return <code>null</code> if full formatting is not supported
371:             */
372:            public ExtendedFormatter getExtendedFormatter() {
373:                if ((impl instanceof  ExtendedFormatter)
374:                        && (impl.isExtendedEditingSupported())) {
375:                    return (ExtendedFormatter) impl;
376:                }
377:                return null;
378:            }
379:
380:            public String getHTML() {
381:                return impl.getHTML();
382:            }
383:
384:            public String getText() {
385:                return impl.getText();
386:            }
387:
388:            @Override
389:            public void onBrowserEvent(Event event) {
390:                switch (DOM.eventGetType(event)) {
391:                case Event.ONMOUSEDOWN:
392:                case Event.ONMOUSEUP:
393:                case Event.ONMOUSEMOVE:
394:                case Event.ONMOUSEOVER:
395:                case Event.ONMOUSEOUT:
396:                    if (mouseListeners != null) {
397:                        mouseListeners.fireMouseEvent(this , event);
398:                    }
399:                    break;
400:
401:                default:
402:                    // ClickEvents, KeyboardEvents, and FocusEvents
403:                    super .onBrowserEvent(event);
404:                }
405:            }
406:
407:            public void removeMouseListener(MouseListener listener) {
408:                if (mouseListeners != null) {
409:                    mouseListeners.remove(listener);
410:                }
411:            }
412:
413:            @Override
414:            public void setFocus(boolean focused) {
415:                // There are different problems on each browser when you try to focus an
416:                // unattached rich text iframe, so just cut it off early.
417:                if (isAttached()) {
418:                    impl.setFocus(focused);
419:                }
420:            }
421:
422:            public void setHTML(String html) {
423:                impl.setHTML(html);
424:            }
425:
426:            public void setText(String text) {
427:                impl.setText(text);
428:            }
429:
430:            @Override
431:            protected void onAttach() {
432:                super .onAttach();
433:                impl.initElement();
434:            }
435:
436:            @Override
437:            protected void onDetach() {
438:                super.onDetach();
439:                impl.uninitElement();
440:            }
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.