|
@@ -1,74 +1,74 @@ |
1 |
|
- |
// This Source Code is Copyright & Licenced as indicated below |
2 |
|
- |
package org.litesoft.GWT.client.widgets.nonpublic.external; |
3 |
|
- |
/* |
4 |
|
- |
* Copyright 2006 Mat Gessel <mat.gessel@gmail.com> |
5 |
|
- |
* |
6 |
|
- |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
7 |
|
- |
* use this file except in compliance with the License. You may obtain a copy of |
8 |
|
- |
* the License at |
9 |
|
- |
* |
10 |
|
- |
* http://www.apache.org/licenses/LICENSE-2.0 |
11 |
|
- |
* |
12 |
|
- |
* Unless required by applicable law or agreed to in writing, software |
13 |
|
- |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
14 |
|
- |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
15 |
|
- |
* License for the specific language governing permissions and limitations under |
16 |
|
- |
* the License. |
17 |
|
- |
*/ |
18 |
|
- |
|
19 |
|
- |
import com.google.gwt.user.client.*; |
20 |
|
- |
import com.google.gwt.user.client.ui.*; |
21 |
|
- |
|
22 |
|
- |
public abstract class EventDelegateAdaptor implements EventDelegate { |
23 |
|
- |
private final int m_eventBits; |
24 |
|
- |
|
25 |
|
- |
/** |
26 |
|
- |
* Default constructor for convienence. Subclasses must override |
27 |
|
- |
* {@link #getEventBits()} if they want to process events. |
28 |
|
- |
*/ |
29 |
|
- |
public EventDelegateAdaptor() { |
30 |
|
- |
m_eventBits = 0; |
31 |
|
- |
} |
32 |
|
- |
|
33 |
|
- |
/** |
34 |
|
- |
* Creates an event delegate which is interested in the specified bits. |
35 |
|
- |
* |
36 |
|
- |
* @param eventBits a bitmask of the events to process |
37 |
|
- |
* |
38 |
|
- |
* @see Event |
39 |
|
- |
*/ |
40 |
|
- |
public EventDelegateAdaptor( int eventBits ) { |
41 |
|
- |
m_eventBits = eventBits; |
42 |
|
- |
} |
43 |
|
- |
|
44 |
|
- |
/* |
45 |
|
- |
* (non-Javadoc) |
46 |
|
- |
* @see asquare.gwt.tk.client.ui.behavior.EventDelegate#onBrowserEvent(com.google.gwt.user.client.ui.Widget, com.google.gwt.user.client.Event) |
47 |
|
- |
*/ |
48 |
|
- |
@Override |
49 |
|
- |
public void onBrowserEvent( Widget widget, Event event ) { |
50 |
|
- |
if ( !doBrowserEvent( widget, event ) ) { |
51 |
|
- |
DOM.eventPreventDefault( event ); |
52 |
|
- |
DOM.eventCancelBubble( event, true ); |
53 |
|
- |
} |
54 |
|
- |
} |
55 |
|
- |
|
56 |
|
- |
/** |
57 |
|
- |
* A convenience method for processing events. The event is cancelled if the |
58 |
|
- |
* return value is false. |
59 |
|
- |
* |
60 |
|
- |
* @return false to cancel the event |
61 |
|
- |
*/ |
62 |
|
- |
protected boolean doBrowserEvent( Widget widget, Event event ) { |
63 |
|
- |
return true; |
64 |
|
- |
} |
65 |
|
- |
|
66 |
|
- |
/** |
67 |
|
- |
* {@inheritDoc} |
68 |
|
- |
* Override in subclass if using the default constructor. |
69 |
|
- |
*/ |
70 |
|
- |
@Override |
71 |
|
- |
public int getEventBits() { |
72 |
|
- |
return m_eventBits; |
73 |
|
- |
} |
74 |
|
- |
} |
|
1 |
+ |
// This Source Code is Copyright & Licenced as indicated below |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.nonpublic.external; |
|
3 |
+ |
/* |
|
4 |
+ |
* Copyright 2006 Mat Gessel <mat.gessel@gmail.com> |
|
5 |
+ |
* |
|
6 |
+ |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|
7 |
+ |
* use this file except in compliance with the License. You may obtain a copy of |
|
8 |
+ |
* the License at |
|
9 |
+ |
* |
|
10 |
+ |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11 |
+ |
* |
|
12 |
+ |
* Unless required by applicable law or agreed to in writing, software |
|
13 |
+ |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
14 |
+ |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
15 |
+ |
* License for the specific language governing permissions and limitations under |
|
16 |
+ |
* the License. |
|
17 |
+ |
*/ |
|
18 |
+ |
|
|
19 |
+ |
import com.google.gwt.user.client.*; |
|
20 |
+ |
import com.google.gwt.user.client.ui.*; |
|
21 |
+ |
|
|
22 |
+ |
public abstract class EventDelegateAdaptor implements EventDelegate { |
|
23 |
+ |
private final int m_eventBits; |
|
24 |
+ |
|
|
25 |
+ |
/** |
|
26 |
+ |
* Default constructor for convienence. Subclasses must override |
|
27 |
+ |
* {@link #getEventBits()} if they want to process events. |
|
28 |
+ |
*/ |
|
29 |
+ |
public EventDelegateAdaptor() { |
|
30 |
+ |
m_eventBits = 0; |
|
31 |
+ |
} |
|
32 |
+ |
|
|
33 |
+ |
/** |
|
34 |
+ |
* Creates an event delegate which is interested in the specified bits. |
|
35 |
+ |
* |
|
36 |
+ |
* @param eventBits a bitmask of the events to process |
|
37 |
+ |
* |
|
38 |
+ |
* @see Event |
|
39 |
+ |
*/ |
|
40 |
+ |
public EventDelegateAdaptor( int eventBits ) { |
|
41 |
+ |
m_eventBits = eventBits; |
|
42 |
+ |
} |
|
43 |
+ |
|
|
44 |
+ |
/* |
|
45 |
+ |
* (non-Javadoc) |
|
46 |
+ |
* @see asquare.gwt.tk.client.ui.behavior.EventDelegate#onBrowserEvent(com.google.gwt.user.client.ui.Widget, com.google.gwt.user.client.Event) |
|
47 |
+ |
*/ |
|
48 |
+ |
@Override |
|
49 |
+ |
public void onBrowserEvent( Widget widget, Event event ) { |
|
50 |
+ |
if ( !doBrowserEvent( widget, event ) ) { |
|
51 |
+ |
DOM.eventPreventDefault( event ); |
|
52 |
+ |
DOM.eventCancelBubble( event, true ); |
|
53 |
+ |
} |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
/** |
|
57 |
+ |
* A convenience method for processing events. The event is cancelled if the |
|
58 |
+ |
* return value is false. |
|
59 |
+ |
* |
|
60 |
+ |
* @return false to cancel the event |
|
61 |
+ |
*/ |
|
62 |
+ |
protected boolean doBrowserEvent( Widget widget, Event event ) { |
|
63 |
+ |
return true; |
|
64 |
+ |
} |
|
65 |
+ |
|
|
66 |
+ |
/** |
|
67 |
+ |
* {@inheritDoc} |
|
68 |
+ |
* Override in subclass if using the default constructor. |
|
69 |
+ |
*/ |
|
70 |
+ |
@Override |
|
71 |
+ |
public int getEventBits() { |
|
72 |
+ |
return m_eventBits; |
|
73 |
+ |
} |
|
74 |
+ |
} |