Parcourir la 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 il y a 9 ans
Parent
révision
e03723f60d

+ 4
- 3
mediasource_dbus/src/com/dmdirc/addons/mediasource_dbus/DBusMediaSourceManager.java Voir le fichier

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

+ 8
- 8
scriptplugin/src/com/dmdirc/addons/scriptplugin/TypedProperties.java Voir le fichier

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

+ 6
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanel.java Voir le fichier

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

+ 16
- 27
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java Voir le fichier

@@ -43,8 +43,8 @@ import com.dmdirc.events.NotificationSetEvent;
43 43
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
44 44
 import com.dmdirc.interfaces.config.ConfigChangeListener;
45 45
 import com.dmdirc.interfaces.ui.Window;
46
-import com.dmdirc.util.colours.Colour;
47 46
 import com.dmdirc.ui.WindowManager;
47
+import com.dmdirc.util.colours.Colour;
48 48
 
49 49
 import com.google.common.base.Optional;
50 50
 
@@ -58,9 +58,9 @@ import java.awt.event.MouseEvent;
58 58
 import java.awt.event.MouseListener;
59 59
 import java.io.Serializable;
60 60
 import java.util.ArrayList;
61
-import java.util.Collection;
62 61
 import java.util.Collections;
63 62
 import java.util.HashMap;
63
+import java.util.List;
64 64
 import java.util.Map;
65 65
 
66 66
 import javax.inject.Inject;
@@ -147,8 +147,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
147 147
         scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
148 148
         scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
149 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 152
         position = FramemanagerPosition.getPosition(
154 153
                 globalConfig.getOption("ui", "framemanagerPosition"));
@@ -205,7 +204,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
205 204
                 parent.add(scrollPane);
206 205
                 parent.addComponentListener(ButtonBar.this);
207 206
                 ButtonBar.this.buttonWidth = position.isHorizontal()
208
-                        ? 150 : (parent.getWidth() / NUM_CELLS);
207
+                        ? 150 : parent.getWidth() / NUM_CELLS;
209 208
                 initButtons(windowManager.getRootWindows());
210 209
 
211 210
                 final TextFrame activeFrame = activeFrameManager.getActiveFrame();
@@ -226,20 +225,16 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
226 225
      *
227 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 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 232
             if (window != null) {
237 233
                 windowAdded(new SwingWindowAddedEvent(Optional.fromNullable(parentWindow), window));
238 234
             }
239 235
 
240 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,21 +265,16 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
270 265
      *
271 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 269
         for (FrameContainer window : windowCollection) {
277
-            button = getButton(window);
270
+            final FrameToggleButton button = getButton(window);
278 271
             if (button != null) {
279
-                button.setPreferredSize(
280
-                        new Dimension(buttonWidth, BUTTON_HEIGHT));
272
+                button.setPreferredSize(new Dimension(buttonWidth, BUTTON_HEIGHT));
281 273
                 buttonPanel.add(button);
282 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 276
                     if (sortChildWindows) {
286
-                        Collections.sort(childList,
287
-                                new FrameContainerComparator());
277
+                        Collections.sort(childList, new FrameContainerComparator());
288 278
                     }
289 279
                     displayButtons(childList);
290 280
                 }
@@ -299,7 +289,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
299 289
         buttonPanel.setVisible(false);
300 290
         buttonPanel.removeAll();
301 291
 
302
-        final ArrayList<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
292
+        final List<FrameContainer> windowList = new ArrayList<>(windowManager.getRootWindows());
303 293
         if (sortRootWindows) {
304 294
             Collections.sort(windowList, new FrameContainerComparator());
305 295
         }
@@ -367,7 +357,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
367 357
 
368 358
     @Override
369 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 361
         relayout();
372 362
     }
373 363
 
@@ -408,8 +398,7 @@ public final class ButtonBar implements FrameManager, ActionListener, ComponentL
408 398
             @Override
409 399
             public void run() {
410 400
                 activeWindow = window;
411
-                FrameToggleButton button;
412
-                button = getButton(selected);
401
+                FrameToggleButton button = getButton(selected);
413 402
                 if (selected != null && button != null) {
414 403
                     button.setSelected(false);
415 404
                 }

Chargement…
Annuler
Enregistrer