Browse Source

Switch to config binder for splitpane.

pull/121/head
Greg Holmes 9 years ago
parent
commit
88752347f9

+ 7
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/MainSplitPane.java View File

@@ -0,0 +1,7 @@
1
+package com.dmdirc.addons.ui_swing;
2
+
3
+import com.dmdirc.addons.ui_swing.components.SplitPane;
4
+
5
+public class MainSplitPane extends SplitPane {
6
+
7
+}

+ 9
- 33
ui_swing/src/com/dmdirc/addons/ui_swing/components/SplitPane.java View File

@@ -23,6 +23,8 @@
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.config.ConfigBinder;
27
+import com.dmdirc.config.ConfigBinding;
26 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 29
 import com.dmdirc.interfaces.config.ConfigChangeListener;
28 30
 
@@ -33,33 +35,17 @@ import javax.swing.JSplitPane;
33 35
 /**
34 36
  * JSplit pane that snaps around its components preferred size.
35 37
  */
36
-public class SplitPane extends JSplitPane implements ConfigChangeListener {
38
+public class SplitPane extends JSplitPane {
37 39
 
38 40
     /** A version number for this class. */
39 41
     private static final long serialVersionUID = 2;
40
-    /** use one touch expandable? */
41
-    private boolean useOneTouchExpandable;
42
-    /** Global config manager. */
43
-    private final AggregateConfigProvider config;
44 42
 
45 43
     /** Orientation type . */
46 44
     public enum Orientation {
47
-
48 45
         /** Horizontal orientation. */
49 46
         HORIZONTAL,
50 47
         /** Vertical orientation. */
51 48
         VERTICAL
52
-
53
-    }
54
-
55
-    /**
56
-     * Instantiates a new snapping split pane. Defaults to using a horizontal split, two null
57
-     * components and snapping to the left component.
58
-     *
59
-     * @param manager Config manager to read values from
60
-     */
61
-    public SplitPane(final AggregateConfigProvider manager) {
62
-        this(manager, Orientation.HORIZONTAL, null, null);
63 49
     }
64 50
 
65 51
     /**
@@ -84,29 +70,19 @@ public class SplitPane extends JSplitPane implements ConfigChangeListener {
84 70
      */
85 71
     public SplitPane(final AggregateConfigProvider manager, final Orientation orientation,
86 72
             final Component leftComponent, final Component rightComponent) {
87
-        super((orientation.equals(Orientation.HORIZONTAL))
88
-                ? HORIZONTAL_SPLIT : VERTICAL_SPLIT,
89
-                true, leftComponent, rightComponent);
73
+        super(orientation == Orientation.HORIZONTAL ? HORIZONTAL_SPLIT : VERTICAL_SPLIT, true,
74
+                leftComponent, rightComponent);
90 75
 
91
-        config = manager;
92
-        useOneTouchExpandable = config.getOptionBool(
93
-                "ui", "useOneTouchExpandable");
94
-
95
-        setOneTouchExpandable(useOneTouchExpandable);
96 76
         setContinuousLayout(true);
97 77
 
98 78
         getActionMap().setParent(null);
99 79
         getActionMap().clear();
100 80
 
101
-        config.addChangeListener("ui", "useOneTouchExpandable", this);
81
+        new ConfigBinder(manager).bind(this, SplitPane.class);
102 82
     }
103 83
 
104
-    @Override
105
-    public void configChanged(final String domain, final String key) {
106
-        useOneTouchExpandable = config.getOptionBool(
107
-                "ui", "useOneTouchExpandable");
108
-
109
-        UIUtilities.invokeLater(() -> setOneTouchExpandable(useOneTouchExpandable));
84
+    @ConfigBinding(domain = "ui", key = "useOneTouchExpandable")
85
+    public void oneTouchChanged(final boolean value) {
86
+        UIUtilities.invokeLater(() -> setOneTouchExpandable(value));
110 87
     }
111
-
112 88
 }

Loading…
Cancel
Save