Source Code Cross Referenced for XEditorEventHandler.java in  » XML-UI » XUI » net » xoetrope » builder » editor » 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 » XML UI » XUI » net.xoetrope.builder.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.builder.editor;
002:
003:        import java.lang.reflect.Method;
004:        import java.util.Hashtable;
005:
006:        import java.awt.AWTEvent;
007:        import java.awt.Component;
008:        import java.awt.Container;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.awt.event.FocusEvent;
012:        import java.awt.event.FocusListener;
013:        import java.awt.event.ItemEvent;
014:        import java.awt.event.ItemListener;
015:        import java.awt.event.KeyEvent;
016:        import java.awt.event.KeyListener;
017:        import java.awt.event.MouseEvent;
018:        import java.awt.event.MouseListener;
019:        import java.awt.event.MouseMotionListener;
020:        import java.awt.event.TextEvent;
021:        import java.awt.event.TextListener;
022:
023:        import net.xoetrope.xui.validation.XValidator;
024:        import net.xoetrope.xui.XEventHandler;
025:        import net.xoetrope.xui.validation.XValidationHandler;
026:
027:        /**
028:         * <p>Implements an event handler for the XPageBuilder and redirects events to
029:         * the page builder.
030:         * XPage</p>
031:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
032:         * License:      see license.txt
033:         * @version 1.0
034:         */
035:        public class XEditorEventHandler extends XEventHandler implements 
036:                ActionListener, FocusListener, TextListener, ItemListener,
037:                KeyListener, MouseListener, MouseMotionListener
038:
039:        {
040:            protected XEventHandler originalEventHandler;
041:            protected XPageHolder pageHolder;
042:
043:            public XEditorEventHandler(XPageHolder pb, XEventHandler eh,
044:                    Container c, XValidationHandler vh) {
045:                super (c, vh);
046:                originalEventHandler = eh;
047:                pageHolder = pb;
048:            }
049:
050:            /**
051:             * Invokes an event. Called in response to an event. If a handler has been
052:             * added for the event it will be invoked.
053:             * @param evt the event object
054:             */
055:            protected void invoke(long eventType, AWTEvent evt) {
056:            }
057:
058:            /**
059:             * Check the focus change status
060:             * @return true if the focus change events are being suppressed.
061:             */
062:            public boolean isFocusChangeSuppressed() {
063:                return originalEventHandler.isFocusChangeSuppressed();
064:            }
065:
066:            /**
067:             * Get the current event
068:             * @return the AWTEvent that was last triggered
069:             */
070:            public AWTEvent getCurrentEvent() {
071:                return originalEventHandler.getCurrentEvent();
072:            }
073:
074:            /**
075:             * Adds an event handler. A specific handler such as the addActionHandler should
076:             * be used instead of calling this method
077:             * @param comp the component that fires the event
078:             * @param methodName the method to be invoked in response to the object
079:             */
080:            public void addHandler(Component comp, long eventType,
081:                    String methodName) throws Exception {
082:            }
083:
084:            /**
085:             * Adds a listener for an event type. This method should not normally be
086:             * called by an application
087:             * @param comp the component that fires events
088:             * @param listenerName the name of the listener interface
089:             * @param argType the listener arguments
090:             */
091:            public void addListener(Component comp, String listenerName,
092:                    String argType) {
093:            }
094:
095:            /**
096:             * Adds a handler for action events
097:             * @param comp the component that fires the events
098:             * @param methodName the method to be invoked in response to the action event
099:             * @see java.awt.event.ActionListener
100:             * @see java.awt.event.ActionEvent
101:             */
102:            public void addActionHandler(Component comp, String methodName) {
103:            }
104:
105:            /**
106:             * Adds a handler for focus events
107:             * @param comp the component that fires the events
108:             * @param methodName the method to be invoked in response to the focus event
109:             * @see java.awt.event.FocusListener
110:             * @see java.awt.event.FocusEvent
111:             */
112:            public void addFocusHandler(Component comp, String methodName) {
113:            }
114:
115:            /**
116:             * Adds a handler for text events
117:             * @param comp the component that fires the events
118:             * @param methodName the method to be invoked in response to the text event
119:             * @see java.awt.event.TextListener
120:             * @see java.awt.event.TextEvent
121:             */
122:            public void addTextHandler(Component comp, String methodName) {
123:            }
124:
125:            /**
126:             * Adds a handler for item events
127:             * @param comp the component that fires the events
128:             * @param methodName the method to be invoked in response to the item event
129:             * @see java.awt.event.ItemListener
130:             * @see java.awt.event.ItemEvent
131:             */
132:            public void addItemHandler(Component comp, String methodName) {
133:            }
134:
135:            /**
136:             * Adds a handler for key events
137:             * @param comp the component that fires the events
138:             * @param methodName the method to be invoked in response to the key event
139:             * @see java.awt.event.KeyListener
140:             * @see java.awt.event.KeyEvent
141:             */
142:            public void addKeyHandler(Component comp, String methodName) {
143:            }
144:
145:            /**
146:             * Adds a handler for mouse events
147:             * @param comp the component that fires the events
148:             * @param methodName the method to be invoked in response to the mouse event
149:             * @see java.awt.event.MouseMotionListener
150:             * @see java.awt.event.MouseEvent
151:             */
152:            public void addMouseHandler(Component comp, String methodName) {
153:            }
154:
155:            /**
156:             * Adds a handler for mouse motion events
157:             * @param comp the component that fires the events
158:             * @param methodName the method to be invoked in response to the mouse event
159:             * @see java.awt.event.MouseMotionListener
160:             * @see java.awt.event.MouseEvent
161:             */
162:            public void addMouseMotionHandler(Component comp, String methodName) {
163:            }
164:
165:            /**
166:             * A utility method used to determine if the last event corrseponds to a mouse
167:             * click. The notion of a click is extended by assuming the a mouse press and
168:             * release within a single component constitutes a click even if not at the
169:             * same coordinate. A MouseEvent.MOUSE_CLICKED is only triggered when the press
170:             * and release are at the same location and this is often inadequate for end-user
171:             * interaction.
172:             * @return true if the mouse was clicked
173:             */
174:            public boolean wasMouseClicked() {
175:                return false;
176:            }
177:
178:            //----------------------------------------------------------------------------
179:            public void actionPerformed(ActionEvent e) {
180:                pageHolder.actionPerformed(e);
181:                invoke(AWTEvent.ACTION_EVENT_MASK, e);
182:            }
183:
184:            public void focusGained(FocusEvent e) {
185:                pageHolder.focusGained(e);
186:            }
187:
188:            public void focusLost(FocusEvent e) {
189:                pageHolder.focusLost(e);
190:            }
191:
192:            public void textValueChanged(TextEvent e) {
193:                pageHolder.textValueChanged(e);
194:                invoke(AWTEvent.TEXT_EVENT_MASK, e);
195:            }
196:
197:            public void itemStateChanged(ItemEvent e) {
198:                pageHolder.itemStateChanged(e);
199:                invoke(AWTEvent.ITEM_EVENT_MASK, e);
200:            }
201:
202:            public void keyPressed(KeyEvent e) {
203:                pageHolder.keyPressed(e);
204:                invoke(AWTEvent.KEY_EVENT_MASK, e);
205:            }
206:
207:            public void keyReleased(KeyEvent e) {
208:                pageHolder.keyReleased(e);
209:                invoke(AWTEvent.KEY_EVENT_MASK, e);
210:            }
211:
212:            public void keyTyped(KeyEvent e) {
213:                pageHolder.keyTyped(e);
214:                invoke(AWTEvent.KEY_EVENT_MASK, e);
215:            }
216:
217:            public void mouseClicked(MouseEvent e) {
218:                pageHolder.mouseClicked(e);
219:            }
220:
221:            public void mouseEntered(MouseEvent e) {
222:                pageHolder.mouseEntered(e);
223:                invoke(AWTEvent.MOUSE_EVENT_MASK, e);
224:            }
225:
226:            public void mouseExited(MouseEvent e) {
227:                pageHolder.mouseExited(e);
228:                invoke(AWTEvent.MOUSE_EVENT_MASK, e);
229:            }
230:
231:            public void mousePressed(MouseEvent e) {
232:                pageHolder.mousePressed(e);
233:            }
234:
235:            public void mouseReleased(MouseEvent e) {
236:                pageHolder.mouseReleased(e);
237:                invoke(AWTEvent.MOUSE_EVENT_MASK, e);
238:            }
239:
240:            public void mouseMoved(MouseEvent e) {
241:                invoke(AWTEvent.MOUSE_MOTION_EVENT_MASK, e);
242:            }
243:
244:            public void mouseDragged(MouseEvent e) {
245:                invoke(AWTEvent.MOUSE_MOTION_EVENT_MASK, e);
246:            }
247:
248:            //----------------------------------------------------------------------------
249:
250:            public void suppressFocusEvents(boolean suppress) {
251:            }
252:
253:            public XEventHandler getOriginalEventHandler() {
254:                return originalEventHandler;
255:            }
256:
257:            //----------------------------------------------------------------------------
258:            /**
259:             * Removes an event handler. A specific handler such as the removeActionHandler should
260:             * be used instead of calling this method
261:             * @param comp the component that fires the event
262:             * @param methodName the method to be invoked in response to the object
263:             */
264:            public void removeHandler(Object comp, long eventType,
265:                    String methodName) throws Exception {
266:                try {
267:                    Method m = container.getClass().getMethod(methodName, null);
268:                    handlers.put(new Long(eventType * comp.hashCode()), m);
269:                } catch (NoSuchMethodException ex) {
270:                    throw new Exception("Could not locate method '"
271:                            + methodName + "'");
272:                } catch (SecurityException ex) {
273:                    throw new Exception("Access to method '" + methodName
274:                            + "' not permitted");
275:                }
276:            }
277:
278:            /**
279:             * Removes a listener for an event type. This method should not normally be
280:             * called by an application
281:             * @param comp the component that fires events
282:             * @param listenerName the name of the listener interface
283:             * @param argType the listener arguments
284:             */
285:            public void removeListener(Object comp, String listenerName,
286:                    String argType) {
287:                try {
288:                    Class params[] = new Class[1];
289:                    params[0] = Class.forName(argType);
290:                    Method m = comp.getClass().getMethod(listenerName, params);
291:                    Object args[] = new Object[1];
292:                    args[0] = originalEventHandler;
293:                    m.invoke(comp, args);
294:                } catch (Exception e) {
295:                    e.printStackTrace();
296:                }
297:            }
298:
299:            /**
300:             * Removes a handler for action events
301:             * @param menuItem the menu item that fires the events
302:             * @param methodName the method to be invoked in response to the action event
303:             * @see java.awt.event.ActionListener
304:             * @see java.awt.event.ActionEvent
305:             */
306:            public void removeMenuHandler(Object menuItem, String methodName) {
307:                removeListener(menuItem, "removeActionListener",
308:                        "java.awt.event.ActionListener");
309:                try {
310:                    removeHandler(menuItem, AWTEvent.ACTION_EVENT_MASK,
311:                            methodName);
312:                } catch (Exception ex) {
313:                    ex.printStackTrace();
314:                }
315:            }
316:
317:            /**
318:             * Removes a handler for action events
319:             * @param comp the component that fires the events
320:             * @param methodName the method to be invoked in response to the action event
321:             * @see java.awt.event.ActionListener
322:             * @see java.awt.event.ActionEvent
323:             */
324:            public void removeActionHandler(Component comp, String methodName) {
325:                removeListener(comp, "removeActionListener",
326:                        "java.awt.event.ActionListener");
327:                try {
328:                    removeHandler(comp, AWTEvent.ACTION_EVENT_MASK, methodName);
329:                } catch (Exception ex) {
330:                    ex.printStackTrace();
331:                }
332:            }
333:
334:            /**
335:             * Removes a handler for focus events
336:             * @param comp the component that fires the events
337:             * @param methodName the method to be invoked in response to the focus event
338:             * @see java.awt.event.FocusListener
339:             * @see java.awt.event.FocusEvent
340:             */
341:            public void removeFocusHandler(Component comp, String methodName) {
342:                removeListener(comp, "removeFocusListener",
343:                        "java.awt.event.FocusListener");
344:                try {
345:                    removeHandler(comp, AWTEvent.FOCUS_EVENT_MASK, methodName);
346:                } catch (Exception ex) {
347:                    ex.printStackTrace();
348:                }
349:            }
350:
351:            /**
352:             * Removes a handler for text events
353:             * @param comp the component that fires the events
354:             * @param methodName the method to be invoked in response to the text event
355:             * @see java.awt.event.TextListener
356:             * @see java.awt.event.TextEvent
357:             */
358:            public void removeTextHandler(Component comp, String methodName) {
359:                removeListener(comp, "removeTextListener",
360:                        "java.awt.event.TextListener");
361:                try {
362:                    removeHandler(comp, AWTEvent.TEXT_EVENT_MASK, methodName);
363:                } catch (Exception ex) {
364:                    ex.printStackTrace();
365:                }
366:            }
367:
368:            /**
369:             * Removes a handler for item events
370:             * @param comp the component that fires the events
371:             * @param methodName the method to be invoked in response to the item event
372:             * @see java.awt.event.ItemListener
373:             * @see java.awt.event.ItemEvent
374:             */
375:            public void removeItemHandler(Component comp, String methodName) {
376:                removeListener(comp, "removeItemListener",
377:                        "java.awt.event.ItemListener");
378:                try {
379:                    removeHandler(comp, AWTEvent.ITEM_EVENT_MASK, methodName);
380:                } catch (Exception ex) {
381:                    ex.printStackTrace();
382:                }
383:            }
384:
385:            /**
386:             * Removes a handler for key events
387:             * @param comp the component that fires the events
388:             * @param methodName the method to be invoked in response to the key event
389:             * @see java.awt.event.KeyListener
390:             * @see java.awt.event.KeyEvent
391:             */
392:            public void removeKeyHandler(Component comp, String methodName) {
393:                removeListener(comp, "removeKeyListener",
394:                        "java.awt.event.KeyListener");
395:                try {
396:                    removeHandler(comp, AWTEvent.KEY_EVENT_MASK, methodName);
397:                } catch (Exception ex) {
398:                    ex.printStackTrace();
399:                }
400:            }
401:
402:            /**
403:             * Removes a handler for mouse events
404:             * @param comp the component that fires the events
405:             * @param methodName the method to be invoked in response to the mouse event
406:             * @see java.awt.event.MouseMotionListener
407:             * @see java.awt.event.MouseEvent
408:             */
409:            public void removeMouseHandler(Component comp, String methodName) {
410:                removeListener(comp, "removeMouseListener",
411:                        "java.awt.event.MouseListener");
412:                try {
413:                    removeHandler(comp, AWTEvent.MOUSE_EVENT_MASK, methodName);
414:                } catch (Exception ex) {
415:                    ex.printStackTrace();
416:                }
417:            }
418:
419:            /**
420:             * Removes a handler for mouse motion events
421:             * @param comp the component that fires the events
422:             * @param methodName the method to be invoked in response to the mouse event
423:             * @see java.awt.event.MouseMotionListener
424:             * @see java.awt.event.MouseEvent
425:             */
426:            public void removeMouseMotionHandler(Component comp,
427:                    String methodName) {
428:                removeListener(comp, "removeMouseMotionListener",
429:                        "java.awt.event.MouseMotionListener");
430:                try {
431:                    removeHandler(comp, AWTEvent.MOUSE_MOTION_EVENT_MASK,
432:                            methodName);
433:                } catch (Exception ex) {
434:                    ex.printStackTrace();
435:                }
436:            }
437:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.