Last change
on this file since 193 was
193,
checked in by Maciej Komosinski, 10 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | package com.framsticks.gui; |
---|
2 | |
---|
3 | |
---|
4 | import com.framsticks.util.dispatching.AbstractJoinable; |
---|
5 | import com.framsticks.util.dispatching.Dispatcher; |
---|
6 | import com.framsticks.util.dispatching.ThrowExceptionHandler; |
---|
7 | |
---|
8 | import javax.swing.*; |
---|
9 | import com.framsticks.util.dispatching.RunAt; |
---|
10 | |
---|
11 | /** |
---|
12 | * @author Piotr Sniegowski |
---|
13 | */ |
---|
14 | public class SwingDispatcher<C> extends AbstractJoinable implements Dispatcher<C> { |
---|
15 | |
---|
16 | @SuppressWarnings("rawtypes") |
---|
17 | protected static final SwingDispatcher instance = new SwingDispatcher(); |
---|
18 | |
---|
19 | @SuppressWarnings("unchecked") |
---|
20 | public static <C> Dispatcher<C> getInstance() { |
---|
21 | return (Dispatcher<C>) instance; |
---|
22 | } |
---|
23 | |
---|
24 | public SwingDispatcher() { |
---|
25 | dispatch(new RunAt<C>(ThrowExceptionHandler.getInstance()) { |
---|
26 | @Override |
---|
27 | protected void runAt() { |
---|
28 | Thread.currentThread().setName("gui"); |
---|
29 | } |
---|
30 | }); |
---|
31 | } |
---|
32 | |
---|
33 | @Override |
---|
34 | public final boolean isActive() { |
---|
35 | return SwingUtilities.isEventDispatchThread(); |
---|
36 | } |
---|
37 | |
---|
38 | @Override |
---|
39 | public final void dispatch(RunAt<? extends C> runnable) { |
---|
40 | SwingUtilities.invokeLater(runnable); |
---|
41 | } |
---|
42 | |
---|
43 | @Override |
---|
44 | public String getName() { |
---|
45 | return "gui"; |
---|
46 | } |
---|
47 | |
---|
48 | @Override |
---|
49 | protected void joinableStart() { |
---|
50 | |
---|
51 | } |
---|
52 | |
---|
53 | @Override |
---|
54 | protected void joinableInterrupt() { |
---|
55 | finishJoinable(); |
---|
56 | } |
---|
57 | |
---|
58 | @Override |
---|
59 | protected void joinableFinish() { |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | @Override |
---|
64 | protected void joinableJoin() throws InterruptedException { |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.