|
Lines 12-23
Link Here
|
| 12 |
package org.eclipse.swt.widgets; |
12 |
package org.eclipse.swt.widgets; |
| 13 |
|
13 |
|
| 14 |
import org.eclipse.rwt.Adaptable; |
14 |
import org.eclipse.rwt.Adaptable; |
| 15 |
import org.eclipse.rwt.internal.AdapterManager; |
|
|
| 16 |
import org.eclipse.rwt.internal.engine.RWTFactory; |
15 |
import org.eclipse.rwt.internal.engine.RWTFactory; |
| 17 |
import org.eclipse.rwt.internal.events.EventAdapter; |
16 |
import org.eclipse.rwt.internal.events.EventAdapter; |
| 18 |
import org.eclipse.rwt.internal.events.IEventAdapter; |
17 |
import org.eclipse.rwt.internal.events.IEventAdapter; |
|
|
18 |
import org.eclipse.rwt.internal.lifecycle.LifeCycleAdapterFactory; |
| 19 |
import org.eclipse.rwt.internal.theme.IThemeAdapter; |
19 |
import org.eclipse.rwt.internal.theme.IThemeAdapter; |
| 20 |
import org.eclipse.rwt.lifecycle.IWidgetAdapter; |
20 |
import org.eclipse.rwt.lifecycle.*; |
| 21 |
import org.eclipse.swt.SWT; |
21 |
import org.eclipse.swt.SWT; |
| 22 |
import org.eclipse.swt.SWTException; |
22 |
import org.eclipse.swt.SWTException; |
| 23 |
import org.eclipse.swt.events.DisposeEvent; |
23 |
import org.eclipse.swt.events.DisposeEvent; |
|
Lines 94-106
Link Here
|
| 94 |
int state; |
94 |
int state; |
| 95 |
Display display; |
95 |
Display display; |
| 96 |
private Object data; |
96 |
private Object data; |
| 97 |
private AdapterManager adapterManager; |
97 |
private AbstractWidgetLCA widgetLCA; |
| 98 |
private IWidgetAdapter widgetAdapter; |
98 |
private IWidgetAdapter widgetAdapter; |
| 99 |
private IEventAdapter eventAdapter; |
99 |
private IEventAdapter eventAdapter; |
| 100 |
private UntypedEventAdapter untypedAdapter; |
100 |
private UntypedEventAdapter untypedAdapter; |
| 101 |
private IWidgetGraphicsAdapter widgetGraphicsAdapter; |
101 |
private IWidgetGraphicsAdapter widgetGraphicsAdapter; |
| 102 |
|
102 |
|
| 103 |
|
|
|
| 104 |
Widget() { |
103 |
Widget() { |
| 105 |
// prevent instantiation from outside this package |
104 |
// prevent instantiation from outside this package |
| 106 |
} |
105 |
} |
|
Lines 152-190
Link Here
|
| 152 |
* from application code. |
151 |
* from application code. |
| 153 |
* </p> |
152 |
* </p> |
| 154 |
*/ |
153 |
*/ |
| 155 |
public Object getAdapter( final Class adapter ) { |
154 |
public Object getAdapter( Class adapter ) { |
|
|
155 |
// The AdapterManager is bypassed for the sake of performance. |
| 156 |
Object result; |
156 |
Object result; |
| 157 |
if( adapter == IEventAdapter.class ) { |
157 |
if( adapter == IEventAdapter.class ) { |
| 158 |
// Note: This is not implemented via the AdapterManager, since the |
158 |
// Note: This is not implemented via the AdapterManager since the manager's mapping mechanism |
| 159 |
// manager's mapping mechanism prevents the component being released |
159 |
// prevents the component being released unless the session is invalidated. |
| 160 |
// unless the session is invalidated. |
|
|
| 161 |
if( eventAdapter == null ) { |
160 |
if( eventAdapter == null ) { |
| 162 |
eventAdapter = new EventAdapter(); |
161 |
eventAdapter = new EventAdapter(); |
| 163 |
} |
162 |
} |
| 164 |
result = eventAdapter; |
163 |
result = eventAdapter; |
| 165 |
} else if( adapter == IWidgetAdapter.class ) { |
164 |
} else if( adapter == IWidgetAdapter.class ) { |
| 166 |
// [fappel] Directly return the WidgetAdapter instead of consulting the |
|
|
| 167 |
// adapter factory. This is done for performance reasons and must not |
| 168 |
// be changed without good reason. |
| 169 |
if( widgetAdapter == null ) { |
165 |
if( widgetAdapter == null ) { |
| 170 |
widgetAdapter = new WidgetAdapter(); |
166 |
widgetAdapter = new WidgetAdapter(); |
| 171 |
} |
167 |
} |
| 172 |
result = widgetAdapter; |
168 |
result = widgetAdapter; |
| 173 |
} else if( adapter == IThemeAdapter.class ) { |
169 |
} else if( adapter == IThemeAdapter.class ) { |
| 174 |
// This also bypasses the AdapterManager for the sake of performance. |
|
|
| 175 |
// ThemeAdapters are requested frequently during size computations. |
| 176 |
result = RWTFactory.getThemeAdapterManager().getThemeAdapter( this ); |
170 |
result = RWTFactory.getThemeAdapterManager().getThemeAdapter( this ); |
| 177 |
} else if( adapter == IWidgetGraphicsAdapter.class ) { |
171 |
} else if( adapter == IWidgetGraphicsAdapter.class ) { |
| 178 |
if( widgetGraphicsAdapter == null ) { |
172 |
if( widgetGraphicsAdapter == null ) { |
| 179 |
widgetGraphicsAdapter = new WidgetGraphicsAdapter(); |
173 |
widgetGraphicsAdapter = new WidgetGraphicsAdapter(); |
| 180 |
} |
174 |
} |
| 181 |
result = widgetGraphicsAdapter; |
175 |
result = widgetGraphicsAdapter; |
| 182 |
} else { |
176 |
} else if( adapter == ILifeCycleAdapter.class ) { |
| 183 |
// [fappel] Buffer the adapterManager to improve performance |
177 |
if( widgetLCA == null ) { |
| 184 |
if( adapterManager == null ) { |
178 |
LifeCycleAdapterFactory factory = RWTFactory.getLifeCycleAdapterFactory(); |
| 185 |
adapterManager = RWTFactory.getAdapterManager(); |
179 |
widgetLCA = ( AbstractWidgetLCA )factory.getAdapter( this, ILifeCycleAdapter.class ); |
| 186 |
} |
180 |
} |
| 187 |
result = adapterManager.getAdapter( this, adapter ); |
181 |
result = widgetLCA; |
|
|
182 |
} else { |
| 183 |
result = RWTFactory.getAdapterManager().getAdapter( this, adapter ); |
| 188 |
} |
184 |
} |
| 189 |
return result; |
185 |
return result; |
| 190 |
} |
186 |
} |
|
Lines 811-817
Link Here
|
| 811 |
} |
807 |
} |
| 812 |
|
808 |
|
| 813 |
void releaseWidget() { |
809 |
void releaseWidget() { |
| 814 |
adapterManager = null; |
|
|
| 815 |
untypedAdapter = null; |
810 |
untypedAdapter = null; |
| 816 |
state |= DISPOSED; |
811 |
state |= DISPOSED; |
| 817 |
} |
812 |
} |