Browse Source

Use new ConfigBinder Invocation.

pull/170/head
Greg Holmes 9 years ago
parent
commit
9a99df84fa

+ 44
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/EDTInvocation.java View File

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.ui_swing;
24
+
25
+import com.dmdirc.config.BasicInvocation;
26
+
27
+import java.lang.reflect.Field;
28
+import java.lang.reflect.Method;
29
+
30
+/**
31
+ * ConfigBinder Invocation that invokes on the EDT.
32
+ */
33
+public class EDTInvocation extends BasicInvocation {
34
+
35
+    @Override
36
+    public void invoke(final Field field, final Object instance, final Object value) {
37
+        UIUtilities.invokeAndWait(() -> super.invoke(field, instance, value));
38
+    }
39
+
40
+    @Override
41
+    public void invoke(final Method method, final Object instance, final Object value) {
42
+        UIUtilities.invokeAndWait(() -> super.invoke(method, instance, value));
43
+    }
44
+}

+ 14
- 14
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java View File

@@ -25,8 +25,8 @@ package com.dmdirc.addons.ui_swing.components.frames;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.ServerState;
28
+import com.dmdirc.addons.ui_swing.EDTInvocation;
28 29
 import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
29
-import com.dmdirc.addons.ui_swing.UIUtilities;
30 30
 import com.dmdirc.addons.ui_swing.components.NickList;
31 31
 import com.dmdirc.addons.ui_swing.components.SplitPane;
32 32
 import com.dmdirc.addons.ui_swing.components.TopicBar;
@@ -159,23 +159,23 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
159 159
         }
160 160
     }
161 161
 
162
-    @ConfigBinding(domain = "ui", key = "channelSplitPanePosition")
162
+    @ConfigBinding(domain = "ui", key = "channelSplitPanePosition",
163
+            invocation = EDTInvocation.class)
163 164
     public void handleSplitPanePosition(final int value) {
164
-        UIUtilities.invokeLater(() -> {
165
-            nicklist.setPreferredSize(new Dimension(value, 0));
166
-            splitPane.setDividerLocation(splitPane.getWidth() - splitPane.getDividerSize() - value);
167
-        });
165
+        checkOnEDT();
166
+        nicklist.setPreferredSize(new Dimension(value, 0));
167
+        splitPane.setDividerLocation(splitPane.getWidth() - splitPane.getDividerSize() - value);
168 168
     }
169 169
 
170
-    @ConfigBinding(key = "shownicklist")
170
+    @ConfigBinding(key = "shownicklist",
171
+            invocation = EDTInvocation.class)
171 172
     public void handleShowNickList(final boolean value) {
172
-        UIUtilities.invokeLater(() -> {
173
-            if (value) {
174
-                splitPane.setRightComponent(nicklist);
175
-            } else {
176
-                splitPane.setRightComponent(null);
177
-            }
178
-        });
173
+        checkOnEDT();
174
+        if (value) {
175
+            splitPane.setRightComponent(nicklist);
176
+        } else {
177
+            splitPane.setRightComponent(null);
178
+        }
179 179
     }
180 180
 
181 181
     @Handler(invocation = EdtHandlerInvocation.class)

Loading…
Cancel
Save