View | Details | Raw Unified | Return to bug 426243 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java (+45 lines)
Lines 11-16 Link Here
11
package org.eclipse.swt.widgets;
11
package org.eclipse.swt.widgets;
12
12
13
import java.util.*;
13
import java.util.*;
14
import java.util.List;
14
15
15
import org.eclipse.swt.*;
16
import org.eclipse.swt.*;
16
import org.eclipse.swt.graphics.*;
17
import org.eclipse.swt.graphics.*;
Lines 4646-4651 Link Here
4646
	return true;
4647
	return true;
4647
}
4648
}
4648
4649
4650
/**
4651
 * Block spinning the event loop until {@link BlockCondition#isBlocked()}
4652
 * return false
4653
 * 
4654
 * @param block
4655
 *            the block condition
4656
 */
4657
public void block(BlockCondition block) {
4658
	checkDevice();
4659
	if( ! block.isBlocked() ) {
4660
		return;
4661
	}
4662
	while (block.isBlocked()) {
4663
		if (!readAndDispatch()) {
4664
			sleep();
4665
		}
4666
	}
4667
}
4668
4649
int sourceProc (int info) {
4669
int sourceProc (int info) {
4650
	return 0;
4670
	return 0;
4651
}
4671
}
Lines 5956-5959 Link Here
5956
	return 0;
5976
	return 0;
5957
}
5977
}
5958
5978
5979
public static class BlockCondition {
5980
	private boolean blocked = true;
5981
	private List listenerList = new ArrayList();
5982
	
5983
	public void addListener(Runnable r) {
5984
		listenerList.add(r);
5985
	}
5986
	
5987
	public void removeListener(Runnable r) {
5988
		listenerList.remove(r);
5989
	}
5990
	
5991
	public boolean isBlocked() {
5992
		return blocked;
5993
	}
5994
	
5995
	public void unblock() {
5996
		blocked = false;
5997
		Object[] listeners = listenerList.toArray();
5998
		for( int i = 0; i < listeners.length; i++ ) {
5999
			((Runnable)listeners[i]).run();
6000
		}
6001
	}
6002
}
6003
5959
}
6004
}
(-)a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java (+15 lines)
Lines 16-21 Link Here
16
import org.eclipse.swt.events.*;
16
import org.eclipse.swt.events.*;
17
import org.eclipse.swt.graphics.*;
17
import org.eclipse.swt.graphics.*;
18
import org.eclipse.swt.internal.cocoa.*;
18
import org.eclipse.swt.internal.cocoa.*;
19
import org.eclipse.swt.widgets.Display.BlockCondition;
19
20
20
/**
21
/**
21
 * Instances of this class represent the "windows"
22
 * Instances of this class represent the "windows"
Lines 2328-2331 Link Here
2328
	closeWidget(true);
2329
	closeWidget(true);
2329
}
2330
}
2330
2331
2332
/**
2333
 * Open the shell and block until it is closed
2334
 */
2335
public void openBlocking() {
2336
	final BlockCondition c = new BlockCondition();
2337
	addDisposeListener(new DisposeListener() {
2338
		
2339
		public void widgetDisposed(DisposeEvent e) {
2340
			c.unblock();
2341
		}
2342
	});
2343
	open();
2344
	getDisplay().block(c);
2345
}
2331
}
2346
}

Return to bug 426243