Pārlūkot izejas kodu

Fix HighlightManager not respecting optionals.

pull/480/head
Chris Smith 9 gadus atpakaļ
vecāks
revīzija
66e21df172

+ 2
- 0
src/com/dmdirc/config/ConfigBinder.java Parādīt failu

@@ -26,6 +26,7 @@ import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.events.AppErrorEvent;
27 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28 28
 import com.dmdirc.interfaces.config.ConfigChangeListener;
29
+import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
29 30
 import com.dmdirc.logger.ErrorLevel;
30 31
 import com.dmdirc.util.collections.MapList;
31 32
 
@@ -165,6 +166,7 @@ public class ConfigBinder {
165 166
             final Class<?> targetClass) {
166 167
         if (targetClass.equals(String.class)) {
167 168
             return manager.getOptionString(getDomain(binding.domain()), binding.key(),
169
+                    binding.required(), ReadOnlyConfigProvider.PERMISSIVE_VALIDATOR,
168 170
                     binding.fallbacks());
169 171
         }
170 172
 

+ 9
- 0
src/com/dmdirc/config/ConfigBinding.java Parādīt failu

@@ -63,6 +63,15 @@ public @interface ConfigBinding {
63 63
      */
64 64
     boolean applyInitially() default true;
65 65
 
66
+    /**
67
+     * For settings that support fallbacks, whether or not a value is required. If it is not
68
+     * required, a "false:" setting will result in {@code null} being returned, rather than
69
+     * the next fallback being tried.
70
+     *
71
+     * @return True if the setting is required, false otherwise.
72
+     */
73
+    boolean required() default true;
74
+
66 75
     /**
67 76
      * {@link Invocation} class that will be created and used to execute the config binding.  The
68 77
      * default just directly executes or sets the value.

+ 3
- 3
src/com/dmdirc/ui/messages/HighlightManager.java Parādīt failu

@@ -58,7 +58,7 @@ public class HighlightManager {
58 58
 
59 59
     private Optional<Pattern> nicknamePattern = Optional.empty();
60 60
 
61
-    private Optional<Colour> backgroundColour = Optional.of(Colour.RED);
61
+    private Optional<Colour> backgroundColour = Optional.empty();
62 62
     private Optional<Colour> foregroundColour = Optional.empty();
63 63
 
64 64
     public HighlightManager(
@@ -111,7 +111,7 @@ public class HighlightManager {
111 111
                 .ifPresent(this::setNickname);
112 112
     }
113 113
 
114
-    @ConfigBinding(domain = "ui", key = "highlightLineForegroundColour")
114
+    @ConfigBinding(domain = "ui", key = "highlightLineForegroundColour", required = false)
115 115
     void handleForegroundColour(final String value) {
116 116
         if (Strings.isNullOrEmpty(value)) {
117 117
             foregroundColour = Optional.empty();
@@ -120,7 +120,7 @@ public class HighlightManager {
120 120
         }
121 121
     }
122 122
 
123
-    @ConfigBinding(domain = "ui", key = "highlightLineBackgroundColour")
123
+    @ConfigBinding(domain = "ui", key = "highlightLineBackgroundColour", required = false)
124 124
     void handleBackgroundColour(final String value) {
125 125
         if (Strings.isNullOrEmpty(value)) {
126 126
             backgroundColour = Optional.empty();

Notiek ielāde…
Atcelt
Saglabāt