|
Lines 13-18
Link Here
|
| 13 |
|
13 |
|
| 14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
| 15 |
import java.io.InputStream; |
15 |
import java.io.InputStream; |
|
|
16 |
import java.lang.ref.WeakReference; |
| 16 |
import java.text.MessageFormat; |
17 |
import java.text.MessageFormat; |
| 17 |
import java.util.*; |
18 |
import java.util.*; |
| 18 |
import java.util.List; |
19 |
import java.util.List; |
|
Lines 129-135
Link Here
|
| 129 |
private static final String APP_VERSION |
130 |
private static final String APP_VERSION |
| 130 |
= Display.class.getName() + "#appVersion"; |
131 |
= Display.class.getName() + "#appVersion"; |
| 131 |
|
132 |
|
| 132 |
|
|
|
| 133 |
/* Package Name */ |
133 |
/* Package Name */ |
| 134 |
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; |
134 |
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; |
| 135 |
|
135 |
|
|
Lines 204-211
Link Here
|
| 204 |
|
204 |
|
| 205 |
/* Display Data */ |
205 |
/* Display Data */ |
| 206 |
private Object data; |
206 |
private Object data; |
| 207 |
private String [] keys; |
207 |
private String[] keys; |
| 208 |
private Object [] values; |
208 |
private Object[] values; |
|
|
209 |
|
| 210 |
private static WeakReference[] displays = new WeakReference[ 4 ]; |
| 209 |
|
211 |
|
| 210 |
/** |
212 |
/** |
| 211 |
* Constructs a new instance of this class. |
213 |
* Constructs a new instance of this class. |
|
Lines 233-238
Link Here
|
| 233 |
SWT.error( SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]" ); |
235 |
SWT.error( SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]" ); |
| 234 |
} |
236 |
} |
| 235 |
RWTLifeCycle.setSessionDisplay( this ); |
237 |
RWTLifeCycle.setSessionDisplay( this ); |
|
|
238 |
register( this); |
| 236 |
shells = new ArrayList(); |
239 |
shells = new ArrayList(); |
| 237 |
readInitialBounds(); |
240 |
readInitialBounds(); |
| 238 |
readScrollBarSize(); |
241 |
readScrollBarSize(); |
|
Lines 690-695
Link Here
|
| 690 |
// TODO [rh] zero fields |
693 |
// TODO [rh] zero fields |
| 691 |
} |
694 |
} |
| 692 |
|
695 |
|
|
|
696 |
protected void destroy () { |
| 697 |
deregister( this ); |
| 698 |
} |
| 699 |
|
| 693 |
private void sendDisposeEvent() { |
700 |
private void sendDisposeEvent() { |
| 694 |
Event event = new Event(); |
701 |
Event event = new Event(); |
| 695 |
event.display = this; |
702 |
event.display = this; |
|
Lines 1880-1885
Link Here
|
| 1880 |
session.setAttribute( APP_VERSION, version ); |
1887 |
session.setAttribute( APP_VERSION, version ); |
| 1881 |
} |
1888 |
} |
| 1882 |
|
1889 |
|
|
|
1890 |
/** |
| 1891 |
* Returns the display which the given thread is the |
| 1892 |
* user-interface thread for, or null if the given thread |
| 1893 |
* is not a user-interface thread for any display. Specifying |
| 1894 |
* <code>null</code> as the thread will return <code>null</code> |
| 1895 |
* for the display. |
| 1896 |
* |
| 1897 |
* @param thread the user-interface thread |
| 1898 |
* @return the display for the given thread |
| 1899 |
* |
| 1900 |
* @since 1.3 |
| 1901 |
*/ |
| 1902 |
public static Display findDisplay( final Thread thread ) { |
| 1903 |
synchronized( Device.class ) { |
| 1904 |
Display result = null; |
| 1905 |
for( int i = 0; i < displays.length && result == null; i++ ) { |
| 1906 |
WeakReference current = displays[ i ]; |
| 1907 |
if( current != null ) { |
| 1908 |
Display display = ( Display )current.get(); |
| 1909 |
if( display != null && display.thread == thread ) { |
| 1910 |
result = display; |
| 1911 |
} |
| 1912 |
} |
| 1913 |
} |
| 1914 |
return result; |
| 1915 |
} |
| 1916 |
} |
| 1917 |
|
| 1918 |
private static void register( final Display display ) { |
| 1919 |
synchronized( Device.class ) { |
| 1920 |
boolean registered = false; |
| 1921 |
for( int i = 0; i < displays.length && !registered; i++ ) { |
| 1922 |
if( displays[ i ] == null ) { |
| 1923 |
displays[ i ] = new WeakReference( display ); |
| 1924 |
registered = true; |
| 1925 |
} |
| 1926 |
} |
| 1927 |
if( !registered ) { |
| 1928 |
WeakReference[] newDisplays = new WeakReference[ displays.length + 4 ]; |
| 1929 |
System.arraycopy( displays, 0, newDisplays, 0, displays.length ); |
| 1930 |
newDisplays[ displays.length ] = new WeakReference( display ); |
| 1931 |
displays = newDisplays; |
| 1932 |
} |
| 1933 |
} |
| 1934 |
} |
| 1935 |
|
| 1936 |
private static void deregister( final Display display ) { |
| 1937 |
synchronized( Device.class ) { |
| 1938 |
for( int i = 0; i < displays.length; i++ ) { |
| 1939 |
WeakReference current = displays[ i ]; |
| 1940 |
if( current != null && display == current.get() ) { |
| 1941 |
displays[ i ] = null; |
| 1942 |
} |
| 1943 |
} |
| 1944 |
} |
| 1945 |
} |
| 1946 |
|
| 1883 |
///////////////////// |
1947 |
///////////////////// |
| 1884 |
// Consistency checks |
1948 |
// Consistency checks |
| 1885 |
|
1949 |
|