source: java/main/src/main/java/com/framsticks/gui/SwingJoinable.java @ 193

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.4 KB
Line 
1package com.framsticks.gui;
2
3
4import com.framsticks.util.FramsticksException;
5import com.framsticks.util.dispatching.AbstractJoinable;
6import com.framsticks.util.dispatching.Dispatcher;
7import com.framsticks.util.dispatching.RunAt;
8import com.framsticks.util.dispatching.ThrowExceptionHandler;
9
10public abstract class SwingJoinable<Swing> extends AbstractJoinable implements Dispatcher<SwingJoinable<Swing>> {
11
12        private Swing swing;
13
14        /**
15         * @return the swing
16         */
17        public Swing getSwing() {
18                if (swing == null) {
19                        throw new FramsticksException().msg("swing has not yet been initialized").arg("in", this);
20                }
21                return swing;
22        }
23
24        public boolean hasSwing() {
25                return swing != null;
26        }
27
28        /**
29         * @param swing the swing to set
30         */
31        protected void setSwing(Swing swing) {
32                this.swing = swing;
33        }
34
35
36        protected abstract void initializeGui();
37
38        @Override
39        protected void joinableStart() {
40                dispatch(new RunAt<SwingJoinable<Swing>>(ThrowExceptionHandler.getInstance()) {
41                        @Override
42                        protected void runAt() {
43                                initializeGui();
44                        }
45                });
46        }
47
48        @Override
49        public boolean isActive() {
50                return SwingDispatcher.instance.isActive();
51        }
52
53        @Override
54        public void dispatch(RunAt<? extends SwingJoinable<Swing>> runnable) {
55                SwingDispatcher.getInstance().dispatch(runnable);
56        }
57
58        @Override
59        protected void joinableInterrupt() {
60
61        }
62
63        @Override
64        protected void joinableFinish() {
65
66        }
67
68        @Override
69        protected void joinableJoin() throws InterruptedException {
70
71        }
72
73}
Note: See TracBrowser for help on using the repository browser.