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 239182 Details for
Bug 426243
[All] Add Display API to spin event loop
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revise patch upon Pauls requirement
api_proposal.patch (text/plain), 3.21 KB, created by
Thomas Schindl
on 2014-01-21 09:05:08 EST
(
hide
)
Description:
Revise patch upon Pauls requirement
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2014-01-21 09:05:08 EST
Size:
3.21 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java >index 7e1054a..dabd9c9 100644 >--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java >+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java >@@ -11,6 +11,7 @@ > package org.eclipse.swt.widgets; > > import java.util.*; >+import java.util.List; > > import org.eclipse.swt.*; > import org.eclipse.swt.graphics.*; >@@ -4646,6 +4647,25 @@ > return true; > } > >+/** >+ * Block spinning the event loop until {@link EventLoopAdvisor#isBlocked()} >+ * return false >+ * >+ * @param advisor >+ * the block condition >+ */ >+public void spinEventLoop(EventLoopAdvisor advisor) { >+ checkDevice(); >+ if( ! advisor.isBlocked() ) { >+ return; >+ } >+ while (advisor.isBlocked()) { >+ if (!readAndDispatch()) { >+ advisor.runIdleCode(); >+ } >+ } >+} >+ > int sourceProc (int info) { > return 0; > } >@@ -5956,4 +5976,55 @@ > return 0; > } > >+public interface EventLoopAdvisor { >+ public boolean isBlocked(); >+ public void addListener(Runnable r); >+ public void removeListener(Runnable r); >+ public void runIdleCode(); >+} >+ >+public static class DefaultEventLoopAdvisor implements EventLoopAdvisor { >+ private boolean blocked = true; >+ private final List listenerList = new ArrayList(); >+ private final Runnable idleCode; >+ private final Display display; >+ >+ public DefaultEventLoopAdvisor(Display display) { >+ this(display, null); >+ } >+ >+ public DefaultEventLoopAdvisor(Display display, Runnable idleCode) { >+ this.display = display; >+ this.idleCode = idleCode; >+ } >+ >+ public void runIdleCode() { >+ if( idleCode != null ) { >+ idleCode.run(); >+ } else { >+ display.sleep(); >+ } >+ } >+ >+ public void addListener(Runnable r) { >+ listenerList.add(r); >+ } >+ >+ public void removeListener(Runnable r) { >+ listenerList.remove(r); >+ } >+ >+ public boolean isBlocked() { >+ return blocked; >+ } >+ >+ public void unblock() { >+ blocked = false; >+ Object[] listeners = listenerList.toArray(); >+ for( int i = 0; i < listeners.length; i++ ) { >+ ((Runnable)listeners[i]).run(); >+ } >+ } >+} >+ > } >diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java >index 369e2e9..25b4303 100644 >--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java >+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java >@@ -16,6 +16,8 @@ > import org.eclipse.swt.events.*; > import org.eclipse.swt.graphics.*; > import org.eclipse.swt.internal.cocoa.*; >+import org.eclipse.swt.widgets.Display.EventLoopAdvisor; >+import org.eclipse.swt.widgets.Display.DefaultEventLoopAdvisor; > > /** > * Instances of this class represent the "windows" >@@ -2328,4 +2330,19 @@ > closeWidget(true); > } > >+/** >+ * Open the shell and block until it is closed >+ */ >+public void openBlocking() { >+ Display d = getDisplay(); >+ final DefaultEventLoopAdvisor c = new DefaultEventLoopAdvisor(d); >+ addDisposeListener(new DisposeListener() { >+ >+ public void widgetDisposed(DisposeEvent e) { >+ c.unblock(); >+ } >+ }); >+ open(); >+ getDisplay().spinEventLoop(c); >+} > }
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 426243
:
239179
| 239182