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 |
} |