KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > custom > StyledTextListener


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.custom;
12
13 import org.eclipse.swt.events.*;
14 import org.eclipse.swt.widgets.*;
15 import org.eclipse.swt.internal.SWTEventListener;
16
17 class StyledTextListener extends TypedListener {
18 /**
19  */

20 StyledTextListener(SWTEventListener listener) {
21     super(listener);
22 }
23 /**
24  * Process StyledText events by invoking the event's handler.
25  */

26 public void handleEvent(Event e) {
27     
28     switch (e.type) {
29         case StyledText.ExtendedModify:
30             ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e);
31             ((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent);
32             break;
33         case StyledText.LineGetBackground:
34             LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
35             ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
36             ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
37             break;
38         case StyledText.LineGetSegments:
39             BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e);
40             ((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent);
41             ((StyledTextEvent) e).segments = segmentEvent.segments;
42             break;
43         case StyledText.LineGetStyle:
44             LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
45             ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
46             ((StyledTextEvent) e).ranges = lineStyleEvent.ranges;
47             ((StyledTextEvent) e).styles = lineStyleEvent.styles;
48             ((StyledTextEvent) e).alignment = lineStyleEvent.alignment;
49             ((StyledTextEvent) e).indent = lineStyleEvent.indent;
50             ((StyledTextEvent) e).justify = lineStyleEvent.justify;
51             ((StyledTextEvent) e).bullet = lineStyleEvent.bullet;
52             ((StyledTextEvent) e).bulletIndex = lineStyleEvent.bulletIndex;
53             break;
54         case StyledText.PaintObject:
55             PaintObjectEvent paintObjectEvent = new PaintObjectEvent((StyledTextEvent) e);
56             ((PaintObjectListener) eventListener).paintObject(paintObjectEvent);
57             break;
58         case StyledText.VerifyKey:
59             VerifyEvent verifyEvent = new VerifyEvent(e);
60             ((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
61             e.doit = verifyEvent.doit;
62             break;
63         case StyledText.TextChanged: {
64             TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
65             ((TextChangeListener) eventListener).textChanged(textChangedEvent);
66             break;
67         }
68         case StyledText.TextChanging:
69             TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e);
70             ((TextChangeListener) eventListener).textChanging(textChangingEvent);
71             break;
72         case StyledText.TextSet: {
73             TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
74             ((TextChangeListener) eventListener).textSet(textChangedEvent);
75             break;
76         }
77         case StyledText.WordNext: {
78             MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
79             ((MovementListener) eventListener).getNextOffset(wordBoundaryEvent);
80             ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
81             break;
82         }
83         case StyledText.WordPrevious: {
84             MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
85             ((MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent);
86             ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
87             break;
88         }
89     }
90 }
91 }
92
93
94
Popular Tags