Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 166069 Details for
Bug 272803
Display#findDisplay() is missing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated patch - remove session scope.
Bug-272803.patch (text/plain), 5.44 KB, created by
Ivan Furnadjiev
on 2010-04-26 08:46:52 EDT
(
hide
)
Description:
Updated patch - remove session scope.
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2010-04-26 08:46:52 EDT
Size:
5.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/widgets/Display.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java,v >retrieving revision 1.95 >diff -u -r1.95 Display.java >--- src/org/eclipse/swt/widgets/Display.java 23 Mar 2010 10:13:35 -0000 1.95 >+++ src/org/eclipse/swt/widgets/Display.java 26 Apr 2010 12:45:01 -0000 >@@ -13,6 +13,7 @@ > > import java.io.IOException; > import java.io.InputStream; >+import java.lang.ref.WeakReference; > import java.text.MessageFormat; > import java.util.*; > import java.util.List; >@@ -129,7 +130,6 @@ > private static final String APP_VERSION > = Display.class.getName() + "#appVersion"; > >- > /* Package Name */ > static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; > >@@ -204,8 +204,10 @@ > > /* Display Data */ > private Object data; >- private String [] keys; >- private Object [] values; >+ private String[] keys; >+ private Object[] values; >+ >+ private static WeakReference[] displays = new WeakReference[ 4 ]; > > /** > * Constructs a new instance of this class. >@@ -233,6 +235,7 @@ > SWT.error( SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]" ); > } > RWTLifeCycle.setSessionDisplay( this ); >+ register( this); > shells = new ArrayList(); > readInitialBounds(); > readScrollBarSize(); >@@ -690,6 +693,10 @@ > // TODO [rh] zero fields > } > >+ protected void destroy () { >+ deregister( this ); >+ } >+ > private void sendDisposeEvent() { > Event event = new Event(); > event.display = this; >@@ -1880,6 +1887,63 @@ > session.setAttribute( APP_VERSION, version ); > } > >+ /** >+ * Returns the display which the given thread is the >+ * user-interface thread for, or null if the given thread >+ * is not a user-interface thread for any display. Specifying >+ * <code>null</code> as the thread will return <code>null</code> >+ * for the display. >+ * >+ * @param thread the user-interface thread >+ * @return the display for the given thread >+ * >+ * @since 1.3 >+ */ >+ public static Display findDisplay( final Thread thread ) { >+ synchronized( Device.class ) { >+ Display result = null; >+ for( int i = 0; i < displays.length && result == null; i++ ) { >+ WeakReference current = displays[ i ]; >+ if( current != null ) { >+ Display display = ( Display )current.get(); >+ if( display != null && display.thread == thread ) { >+ result = display; >+ } >+ } >+ } >+ return result; >+ } >+ } >+ >+ private static void register( final Display display ) { >+ synchronized( Device.class ) { >+ boolean registered = false; >+ for( int i = 0; i < displays.length && !registered; i++ ) { >+ if( displays[ i ] == null ) { >+ displays[ i ] = new WeakReference( display ); >+ registered = true; >+ } >+ } >+ if( !registered ) { >+ WeakReference[] newDisplays = new WeakReference[ displays.length + 4 ]; >+ System.arraycopy( displays, 0, newDisplays, 0, displays.length ); >+ newDisplays[ displays.length ] = new WeakReference( display ); >+ displays = newDisplays; >+ } >+ } >+ } >+ >+ private static void deregister( final Display display ) { >+ synchronized( Device.class ) { >+ for( int i = 0; i < displays.length; i++ ) { >+ WeakReference current = displays[ i ]; >+ if( current != null && display == current.get() ) { >+ displays[ i ] = null; >+ } >+ } >+ } >+ } >+ > ///////////////////// > // Consistency checks > >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/Display_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Display_Test.java,v >retrieving revision 1.43 >diff -u -r1.43 Display_Test.java >--- src/org/eclipse/swt/widgets/Display_Test.java 23 Mar 2010 10:07:28 -0000 1.43 >+++ src/org/eclipse/swt/widgets/Display_Test.java 26 Apr 2010 12:45:03 -0000 >@@ -20,8 +20,7 @@ > import org.eclipse.rwt.RWT; > import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.rwt.internal.lifecycle.*; >-import org.eclipse.rwt.internal.service.ContextProvider; >-import org.eclipse.rwt.internal.service.ServiceContext; >+import org.eclipse.rwt.internal.service.*; > import org.eclipse.rwt.lifecycle.*; > import org.eclipse.rwt.service.ISessionStore; > import org.eclipse.swt.*; >@@ -1122,6 +1121,30 @@ > assertNull( Display.getAppVersion() ); > } > >+ public void testFindDisplay() { >+ Display display = new Display(); >+ assertSame( display, Display.findDisplay( display.getThread() ) ); >+ assertNull( Display.findDisplay( null ) ); >+ display.dispose(); >+ assertNull( Display.findDisplay( display.getThread() ) ); >+ } >+ >+ public void testFindDisplayFromDifferentSession() throws Exception { >+ final Display[] otherDisplay = new Display[ 1 ]; >+ Thread thread = new Thread( new Runnable() { >+ public void run() { >+ Fixture.fakeContext(); >+ ContextProvider.getContext().setStateInfo( new ServiceStateInfo() ); >+ otherDisplay[ 0 ] = new Display(); >+ } >+ } ); >+ thread.start(); >+ thread.join(); >+ Display display = Display.findDisplay( thread ); >+ assertNotNull( display ); >+ assertSame( otherDisplay[ 0 ], display ); >+ } >+ > protected void setUp() throws Exception { > Fixture.setUp(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 272803
:
166054
| 166069