Browse Source

Tidying.

Change-Id: Ib589c2957a99b616774f2e6d9ca508125fd4e553
Reviewed-on: http://gerrit.dmdirc.com/3923
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/23/3923/2
Chris Smith 9 years ago
parent
commit
e03723f60d

+ 4
- 3
mediasource_dbus/src/com/dmdirc/addons/mediasource_dbus/DBusMediaSourceManager.java View File

32
 import java.io.IOException;
32
 import java.io.IOException;
33
 import java.io.InputStreamReader;
33
 import java.io.InputStreamReader;
34
 import java.util.ArrayList;
34
 import java.util.ArrayList;
35
+import java.util.Collections;
35
 import java.util.HashMap;
36
 import java.util.HashMap;
36
 import java.util.List;
37
 import java.util.List;
37
 import java.util.Map;
38
 import java.util.Map;
99
             }
100
             }
100
         }
101
         }
101
 
102
 
102
-        return sources;
103
+        return Collections.unmodifiableList(sources);
103
     }
104
     }
104
 
105
 
105
     /**
106
     /**
133
      * @return The output of the specified command
134
      * @return The output of the specified command
134
      */
135
      */
135
     protected List<String> getInfo(final String... args) {
136
     protected List<String> getInfo(final String... args) {
136
-        final ArrayList<String> result = new ArrayList<>();
137
+        final List<String> result = new ArrayList<>();
137
         Process process = null;
138
         Process process = null;
138
         try {
139
         try {
139
             process = Runtime.getRuntime().exec(args);
140
             process = Runtime.getRuntime().exec(args);
162
      *
163
      *
163
      * @return A map corresponding to the specified dictionary
164
      * @return A map corresponding to the specified dictionary
164
      */
165
      */
165
-    protected Map<String, String> parseDictionary(final List<String> lines) {
166
+    protected Map<String, String> parseDictionary(final Iterable<String> lines) {
166
         final Map<String, String> res = new HashMap<>();
167
         final Map<String, String> res = new HashMap<>();
167
 
168
 
168
         for (String line : lines) {
169
         for (String line : lines) {

+ 8
- 8
scriptplugin/src/com/dmdirc/addons/scriptplugin/TypedProperties.java View File

99
      */
99
      */
100
     @Override
100
     @Override
101
     public String getProperty(final String key) {
101
     public String getProperty(final String key) {
102
-        if (!caseSensitive) {
103
-            return super.getProperty(key.toLowerCase());
104
-        } else {
102
+        if (caseSensitive) {
105
             return super.getProperty(key);
103
             return super.getProperty(key);
104
+        } else {
105
+            return super.getProperty(key.toLowerCase());
106
         }
106
         }
107
     }
107
     }
108
 
108
 
116
      */
116
      */
117
     @Override
117
     @Override
118
     public String getProperty(final String key, final String fallback) {
118
     public String getProperty(final String key, final String fallback) {
119
-        if (!caseSensitive) {
120
-            return super.getProperty(key.toLowerCase(), fallback);
121
-        } else {
119
+        if (caseSensitive) {
122
             return super.getProperty(key, fallback);
120
             return super.getProperty(key, fallback);
121
+        } else {
122
+            return super.getProperty(key.toLowerCase(), fallback);
123
         }
123
         }
124
     }
124
     }
125
 
125
 
370
             return fallback;
370
             return fallback;
371
         } else {
371
         } else {
372
             final String[] bits = res.split("\n");
372
             final String[] bits = res.split("\n");
373
-            final ArrayList<String> result = new ArrayList<>();
373
+            final List<String> result = new ArrayList<>();
374
             Collections.addAll(result, bits);
374
             Collections.addAll(result, bits);
375
             return result;
375
             return result;
376
         }
376
         }
382
      * @param key   key for property
382
      * @param key   key for property
383
      * @param value Value for property
383
      * @param value Value for property
384
      */
384
      */
385
-    public void setListProperty(final String key, final List<String> value) {
385
+    public void setListProperty(final String key, final Iterable<String> value) {
386
         final StringBuilder val = new StringBuilder();
386
         final StringBuilder val = new StringBuilder();
387
         final String lf = "\n";
387
         final String lf = "\n";
388
         boolean first = true;
388
         boolean first = true;

+ 6
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanel.java View File

28
 import com.dmdirc.ui.IconManager;
28
 import com.dmdirc.ui.IconManager;
29
 import com.dmdirc.ui.messages.ColourManagerFactory;
29
 import com.dmdirc.ui.messages.ColourManagerFactory;
30
 
30
 
31
+import java.util.Collection;
31
 import java.util.TreeSet;
32
 import java.util.TreeSet;
32
 
33
 
33
 import javax.swing.BorderFactory;
34
 import javax.swing.BorderFactory;
37
 import javax.swing.JPanel;
38
 import javax.swing.JPanel;
38
 import javax.swing.JScrollPane;
39
 import javax.swing.JScrollPane;
39
 import javax.swing.JTextArea;
40
 import javax.swing.JTextArea;
41
+import javax.swing.MutableComboBoxModel;
40
 import javax.swing.UIManager;
42
 import javax.swing.UIManager;
41
 
43
 
42
 import net.miginfocom.swing.MigLayout;
44
 import net.miginfocom.swing.MigLayout;
75
         response.setRows(4);
77
         response.setRows(4);
76
         formatter = new JComboBox<>(new DefaultComboBoxModel<String>());
78
         formatter = new JComboBox<>(new DefaultComboBoxModel<String>());
77
 
79
 
78
-        final DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) formatter.
79
-                getModel();
80
+        final MutableComboBoxModel<String> model =
81
+                (MutableComboBoxModel<String>) formatter.getModel();
80
         model.addElement("No change");
82
         model.addElement("No change");
81
         model.addElement("No response");
83
         model.addElement("No response");
82
 
84
 
83
-        final TreeSet<String> formatters = new TreeSet<>(
84
-                String.CASE_INSENSITIVE_ORDER);
85
+        final Collection<String> formatters = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
85
         formatters.addAll(config.getOptions("formatter").keySet());
86
         formatters.addAll(config.getOptions("formatter").keySet());
86
 
87
 
87
         for (final String format : formatters) {
88
         for (final String format : formatters) {
110
      *
111
      *
111
      * @param response new response
112
      * @param response new response
112
      */
113
      */
113
-    public void setResponse(final String[] response) {
114
+    public void setResponse(final String... response) {
114
         final StringBuilder sb = new StringBuilder();
115
         final StringBuilder sb = new StringBuilder();
115
         for (String responseLine : response) {
116
         for (String responseLine : response) {
116
             responseLine = responseLine.replace("\n", "\\n");
117
             responseLine = responseLine.replace("\n", "\\n");

+ 16
- 27
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java View File

43
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
43
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
44
 import com.dmdirc.interfaces.config.ConfigChangeListener;
44
 import com.dmdirc.interfaces.config.ConfigChangeListener;
45
 import com.dmdirc.interfaces.ui.Window;
45
 import com.dmdirc.interfaces.ui.Window;
46
-import com.dmdirc.util.colours.Colour;
47
 import com.dmdirc.ui.WindowManager;
46
 import com.dmdirc.ui.WindowManager;
47
+import com.dmdirc.util.colours.Colour;
48
 
48
 
49
 import com.google.common.base.Optional;
49
 import com.google.common.base.Optional;
50
 
50
 
58
 import java.awt.event.MouseListener;
58
 import java.awt.event.MouseListener;
59
 import java.io.Serializable;
59
 import java.io.Serializable;
60
 import java.util.ArrayList;
60
 import java.util.ArrayList;
61
-import java.util.Collection;
62
 import java.util.Collections;
61
 import java.util.Collections;
63
 import java.util.HashMap;
62
 import java.util.HashMap;
63
+import java.util.List;
64
 import java.util.Map;
64
 import java.util.Map;
65
 
65
 
66
 import javax.inject.Inject;
66
 import javax.inject.Inject;
147
         scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
147
         scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
148
         scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
148
         scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
149
         scrollPane.setMinimumSize(new Dimension(0, BUTTON_HEIGHT
149
         scrollPane.setMinimumSize(new Dimension(0, BUTTON_HEIGHT
150
-                + ((int) PlatformDefaults.getUnitValueX("related")
151
-                .getValue()) * 2));
150
+                + (int) PlatformDefaults.getUnitValueX("related").getValue() * 2));
152
 
151
 
153
         position = FramemanagerPosition.getPosition(
152
         position = FramemanagerPosition.getPosition(
154
                 globalConfig.getOption("ui", "framemanagerPosition"));
153
                 globalConfig.getOption("ui", "framemanagerPosition"));
205
                 parent.add(scrollPane);
204
                 parent.add(scrollPane);
206
                 parent.addComponentListener(ButtonBar.this);
205
                 parent.addComponentListener(ButtonBar.this);
207
                 ButtonBar.this.buttonWidth = position.isHorizontal()
206
                 ButtonBar.this.buttonWidth = position.isHorizontal()
208
-                        ? 150 : (parent.getWidth() / NUM_CELLS);
207
+                        ? 150 : parent.getWidth() / NUM_CELLS;
209
                 initButtons(windowManager.getRootWindows());
208
                 initButtons(windowManager.getRootWindows());
210
 
209
 
211
                 final TextFrame activeFrame = activeFrameManager.getActiveFrame();
210
                 final TextFrame activeFrame = activeFrameManager.getActiveFrame();
226
      *
225
      *
227
      * @since 0.6.4
226
      * @since 0.6.4
228
      */
227
      */
229
-    private void initButtons(
230
-            final Collection<FrameContainer> windowCollection) {
231
-        TextFrame window;
232
-        TextFrame parentWindow;
228
+    private void initButtons(final Iterable<FrameContainer> windowCollection) {
233
         for (FrameContainer frame : windowCollection) {
229
         for (FrameContainer frame : windowCollection) {
234
-            window = windowFactory.getSwingWindow(frame);
235
-            parentWindow = windowFactory.getSwingWindow(frame.getParent().orNull());
230
+            final TextFrame window = windowFactory.getSwingWindow(frame);
231
+            final TextFrame parentWindow = windowFactory.getSwingWindow(frame.getParent().orNull());
236
             if (window != null) {
232
             if (window != null) {
237
                 windowAdded(new SwingWindowAddedEvent(Optional.fromNullable(parentWindow), window));
233
                 windowAdded(new SwingWindowAddedEvent(Optional.fromNullable(parentWindow), window));
238
             }
234
             }
239
 
235
 
240
             if (!frame.getChildren().isEmpty()) {
236
             if (!frame.getChildren().isEmpty()) {
241
-                final ArrayList<FrameContainer> childList = new ArrayList<>(frame.getChildren());
242
-                initButtons(childList);
237
+                initButtons(new ArrayList<>(frame.getChildren()));
243
             }
238
             }
244
         }
239
         }
245
     }
240
     }
270
      *
265
      *
271
      * @since 0.6.4
266
      * @since 0.6.4
272
      */
267
      */
273
-    private void displayButtons(
274
-            final Collection<FrameContainer> windowCollection) {
275
-        FrameToggleButton button;
268
+    private void displayButtons(final Iterable<FrameContainer> windowCollection) {
276
         for (FrameContainer window : windowCollection) {
269
         for (FrameContainer window : windowCollection) {
277
-            button = getButton(window);
270
+            final FrameToggleButton button = getButton(window);
278
             if (button != null) {
271
             if (button != null) {
279
-                button.setPreferredSize(
280
-                        new Dimension(buttonWidth, BUTTON_HEIGHT));
272
+                button.setPreferredSize(new Dimension(buttonWidth, BUTTON_HEIGHT));
281
                 buttonPanel.add(button);
273
                 buttonPanel.add(button);
282
                 if (!window.getChildren().isEmpty()) {
274
                 if (!window.getChildren().isEmpty()) {
283
-                    final ArrayList<FrameContainer> childList
284
-                            = new ArrayList<>(window.getChildren());
275
+                    final List<FrameContainer> childList = new ArrayList<>(window.getChildren());
285
                     if (sortChildWindows) {
276
                     if (sortChildWindows) {
286
-                        Collections.sort(childList,
287
-                                new FrameContainerComparator());
277
+                        Collections.sort(childList, new FrameContainerComparator());
288
                     }
278
                     }
289
                     displayButtons(childList);
279
                     displayButtons(childList);
290
                 }
280
                 }
299
         buttonPanel.setVisible(false);
289
         buttonPanel.setVisible(false);
300
         buttonPanel.removeAll();
290
         buttonPanel.removeAll();
301
 
291
 
302
-        final ArrayList<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
292
+        final List<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
303
         if (sortRootWindows) {
293
         if (sortRootWindows) {
304
             Collections.sort(windowList, new FrameContainerComparator());
294
             Collections.sort(windowList, new FrameContainerComparator());
305
         }
295
         }
367
 
357
 
368
     @Override
358
     @Override
369
     public void componentResized(final ComponentEvent e) {
359
     public void componentResized(final ComponentEvent e) {
370
-        buttonWidth = position.isHorizontal() ? 150 : (parent.getWidth() / NUM_CELLS);
360
+        buttonWidth = position.isHorizontal() ? 150 : parent.getWidth() / NUM_CELLS;
371
         relayout();
361
         relayout();
372
     }
362
     }
373
 
363
 
408
             @Override
398
             @Override
409
             public void run() {
399
             public void run() {
410
                 activeWindow = window;
400
                 activeWindow = window;
411
-                FrameToggleButton button;
412
-                button = getButton(selected);
401
+                FrameToggleButton button = getButton(selected);
413
                 if (selected != null && button != null) {
402
                 if (selected != null && button != null) {
414
                     button.setSelected(false);
403
                     button.setSelected(false);
415
                 }
404
                 }

Loading…
Cancel
Save