Browse Source

Make local variables final where appropriate

Change-Id: Ied3a5a2d993bd74c04eaa357bcbef7218871f529
Reviewed-on: http://gerrit.dmdirc.com/2082
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.7rc1
Chris Smith 13 years ago
parent
commit
f8283731f4

+ 33
- 33
src/com/dmdirc/addons/dcc/DCCPlugin.java View File

@@ -150,45 +150,45 @@ public final class DCCPlugin extends BasePlugin implements ActionListener {
150 150
                 if (!handleExists(send, jc, nickname, parser,reverse, token)) {
151 151
                     return;
152 152
                 }
153
-                boolean resume = handleResume(jc);
154
-                    if (reverse && !token.isEmpty()) {
155
-                        new TransferContainer(DCCPlugin.this, send,
156
-                                "*Receive: " + nickname, nickname, null);
157
-                        send.setToken(token);
158
-                        if (resume) {
159
-                            if (IdentityManager.getGlobalConfig().getOptionBool(
160
-                                    getDomain(), "receive.reverse.sendtoken")) {
161
-                                parser.sendCTCP(nickname, "DCC", "RESUME "
162
-                                        + send.getShortFileName() + " 0 "
163
-                                        + jc.getSelectedFile().length() + " "
164
-                                        + token);
165
-                            } else {
166
-                                parser.sendCTCP(nickname, "DCC", "RESUME "
167
-                                        + send.getShortFileName() + " 0 "
168
-                                        + jc.getSelectedFile().length());
169
-                            }
153
+                final boolean resume = handleResume(jc);
154
+                if (reverse && !token.isEmpty()) {
155
+                    new TransferContainer(DCCPlugin.this, send,
156
+                            "*Receive: " + nickname, nickname, null);
157
+                    send.setToken(token);
158
+                    if (resume) {
159
+                        if (IdentityManager.getGlobalConfig().getOptionBool(
160
+                                getDomain(), "receive.reverse.sendtoken")) {
161
+                            parser.sendCTCP(nickname, "DCC", "RESUME "
162
+                                    + send.getShortFileName() + " 0 "
163
+                                    + jc.getSelectedFile().length() + " "
164
+                                    + token);
170 165
                         } else {
171
-                            if (listen(send)) {
172
-                                parser.sendCTCP(nickname, "DCC", "SEND "
173
-                                        + send.getShortFileName() + " "
174
-                                        + DCC.ipToLong(getListenIP(parser))
175
-                                        + " " + send.getPort() + " "
176
-                                        + send.getFileSize() + " " + token);
177
-                            }
166
+                            parser.sendCTCP(nickname, "DCC", "RESUME "
167
+                                    + send.getShortFileName() + " 0 "
168
+                                    + jc.getSelectedFile().length());
178 169
                         }
179 170
                     } else {
180
-                        new TransferContainer(DCCPlugin.this, send, "Receive: "
181
-                                + nickname, nickname, null);
182
-                        if (resume) {
183
-                            parser.sendCTCP(nickname, "DCC", "RESUME "
171
+                        if (listen(send)) {
172
+                            parser.sendCTCP(nickname, "DCC", "SEND "
184 173
                                     + send.getShortFileName() + " "
185
-                                    + send.getPort() + " "
186
-                                    + jc.getSelectedFile().length());
187
-                        } else {
188
-                            send.connect();
174
+                                    + DCC.ipToLong(getListenIP(parser))
175
+                                    + " " + send.getPort() + " "
176
+                                    + send.getFileSize() + " " + token);
189 177
                         }
190 178
                     }
179
+                } else {
180
+                    new TransferContainer(DCCPlugin.this, send, "Receive: "
181
+                            + nickname, nickname, null);
182
+                    if (resume) {
183
+                        parser.sendCTCP(nickname, "DCC", "RESUME "
184
+                                + send.getShortFileName() + " "
185
+                                + send.getPort() + " "
186
+                                + jc.getSelectedFile().length());
187
+                    } else {
188
+                        send.connect();
189
+                    }
191 190
                 }
191
+            }
192 192
 
193 193
         }, "saveFileThread: " + send.getShortFileName()).start();
194 194
     }
@@ -454,7 +454,7 @@ public final class DCCPlugin extends BasePlugin implements ActionListener {
454 454
 
455 455
         // Ignore incorrect ports, or non-numeric IP/Port
456 456
         try {
457
-            int portInt = Integer.parseInt(port);
457
+            final int portInt = Integer.parseInt(port);
458 458
             if (portInt > 65535 || portInt < 0) {
459 459
                 return;
460 460
             }

+ 1
- 1
src/com/dmdirc/addons/dcc/TransferContainer.java View File

@@ -154,7 +154,7 @@ public class TransferContainer extends FrameContainer implements
154 154
             percent = getPercent();
155 155
         }
156 156
 
157
-        boolean percentageInTitle = IdentityManager.getGlobalConfig()
157
+        final boolean percentageInTitle = IdentityManager.getGlobalConfig()
158 158
                 .getOptionBool(plugin.getDomain(), "general.percentageInTitle");
159 159
 
160 160
         if (percentageInTitle) {

+ 2
- 2
src/com/dmdirc/addons/dcc/io/DCCTransfer.java View File

@@ -454,8 +454,8 @@ public class DCCTransfer extends DCC {
454 454
     protected boolean handleSend() {
455 455
         try {
456 456
             final byte[] data = new byte[blockSize];
457
-            int bytesRead = fileIn.read(data);
458
-            readSize = readSize + bytesRead;
457
+            final int bytesRead = fileIn.read(data);
458
+            readSize += bytesRead;
459 459
 
460 460
             if (bytesRead > 0) {
461 461
                 for (DCCTransferHandler handler : handlers.get(DCCTransferHandler.class)) {

+ 6
- 5
src/com/dmdirc/addons/lagdisplay/PingHistoryPanel.java View File

@@ -92,9 +92,10 @@ public class PingHistoryPanel extends JPanel {
92 92
         g.setFont(g.getFont().deriveFont(10f));
93 93
 
94 94
         float lastX = -1, lastY = -1;
95
-        float pixelsperpointX = (getWidth() - 3) / (float) (history.getList().size() == 1 ? 1
95
+        final float pixelsperpointX = (getWidth() - 3)
96
+                / (float) (history.getList().size() == 1 ? 1
96 97
                 : history.getList().size() - 1);
97
-        float pixelsperpointY = (getHeight() - 10) / (float) maximum;
98
+        final float pixelsperpointY = (getHeight() - 10) / (float) maximum;
98 99
 
99 100
         if (history.isEmpty()) {
100 101
             g.drawString("No data", getWidth() / 2 - 25, getHeight() / 2 + 5);
@@ -107,8 +108,8 @@ public class PingHistoryPanel extends JPanel {
107 108
         for (int i = 0; i < list.size(); i++) {
108 109
             final Long value = list.get(i);
109 110
 
110
-            float x = lastX == -1 ? 2 : lastX + pixelsperpointX;
111
-            float y = getHeight() - 5 - value * pixelsperpointY;
111
+            final float x = lastX == -1 ? 2 : lastX + pixelsperpointX;
112
+            final float y = getHeight() - 5 - value * pixelsperpointY;
112 113
 
113 114
             if (lastX > -1) {
114 115
                 g.drawLine((int) lastX, (int) lastY, (int) x, (int) y);
@@ -125,7 +126,7 @@ public class PingHistoryPanel extends JPanel {
125 126
                 final int diffy = (int) (last1 - (10 + rect.getHeight()) / pixelsperpointY);
126 127
 
127 128
                 float posX = lastX - width + 7;
128
-                float posY = (float) (lastY + rect.getHeight() / 2) - 1;
129
+                final float posY = (float) (lastY + rect.getHeight() / 2) - 1;
129 130
                 boolean failed = posX < 0;
130 131
 
131 132
                 // Check left

+ 1
- 1
src/com/dmdirc/addons/logging/LoggingPlugin.java View File

@@ -579,7 +579,7 @@ public class LoggingPlugin extends BasePlugin implements ActionListener,
579 579
         BufferedWriter out = null;
580 580
         try {
581 581
             if (openFiles.containsKey(filename)) {
582
-                OpenFile of = openFiles.get(filename);
582
+                final OpenFile of = openFiles.get(filename);
583 583
                 of.lastUsedTime = System.currentTimeMillis();
584 584
                 out = of.writer;
585 585
             } else {

+ 5
- 3
src/com/dmdirc/addons/parserdebug/ParserDebugCommand.java View File

@@ -68,7 +68,8 @@ public final class ParserDebugCommand extends Command {
68 68
     public void execute(final FrameContainer origin, final CommandArguments commandArgs, final CommandContext context) {
69 69
         final boolean isSilent = commandArgs.isSilent();
70 70
 
71
-        Parser parser = ((ServerCommandContext) context).getServer().getParser();
71
+        final Parser parser = ((ServerCommandContext) context).getServer()
72
+                .getParser();
72 73
 
73 74
         if (parser == null) {
74 75
             sendLine(origin, isSilent, FORMAT_ERROR, "Unable to get a parser for this window.");
@@ -77,7 +78,7 @@ public final class ParserDebugCommand extends Command {
77 78
         if (myPlugin.registeredParsers.containsKey(parser)) {
78 79
             try {
79 80
                 parser.getCallbackManager().delCallback(DebugInfoListener.class, myPlugin);
80
-                DebugWindow window = myPlugin.registeredParsers.get(parser);
81
+                final DebugWindow window = myPlugin.registeredParsers.get(parser);
81 82
                 window.addLine("======================", true);
82 83
                 window.addLine("No Longer Monitoring: " + parser + " (User Requested)", true);
83 84
                 window.addLine("======================", true);
@@ -89,7 +90,8 @@ public final class ParserDebugCommand extends Command {
89 90
         } else {
90 91
             try {
91 92
                 parser.getCallbackManager().addCallback(DebugInfoListener.class, myPlugin);
92
-                DebugWindow window = new DebugWindow(myPlugin, "Parser Debug", parser, origin.getServer());
93
+                final DebugWindow window = new DebugWindow(myPlugin,
94
+                        "Parser Debug", parser, origin.getServer());
93 95
                 myPlugin.registeredParsers.put(parser, window);
94 96
                 sendLine(origin, isSilent, FORMAT_OUTPUT, "Adding callback ok");
95 97
                 window.addLine("======================", true);

+ 1
- 1
src/com/dmdirc/addons/ui_swing/UIUtilities.java View File

@@ -332,7 +332,7 @@ public final class UIUtilities {
332 332
         int width = SwingUtilities.computeStringWidth(fm, clipString);
333 333
 
334 334
         int nChars = 0;
335
-        for (int max = string.length(); nChars < max; nChars++) {
335
+        for (final int max = string.length(); nChars < max; nChars++) {
336 336
             width += fm.charWidth(string.charAt(nChars));
337 337
             if (width > avaiableWidth) {
338 338
                 break;

+ 1
- 1
src/com/dmdirc/addons/ui_swing/components/vetoable/VetoableComboBoxModel.java View File

@@ -86,7 +86,7 @@ public class VetoableComboBoxModel extends DefaultComboBoxModel {
86 86
      */
87 87
     protected boolean fireVetoableSelectionChange(final Object newValue) {
88 88
         boolean result = true;
89
-        VetoableChangeEvent event = new VetoableChangeEvent(this, newValue);
89
+        final VetoableChangeEvent event = new VetoableChangeEvent(this, newValue);
90 90
         for (VetoableComboBoxSelectionListener listener :
91 91
             listeners.get(VetoableComboBoxSelectionListener.class)) {
92 92
                 result &= listener.selectionChanged(event);

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/prefs/CategoryPanel.java View File

@@ -131,7 +131,7 @@ public class CategoryPanel extends JPanel {
131 131
             @Override
132 132
             public void correctBounds(final ComponentWrapper cw) {
133 133
                 if (cw.getComponent() == scrollPane) {
134
-                    int newSize = Math.max(parent.getPanelHeight(),
134
+                    final int newSize = Math.max(parent.getPanelHeight(),
135 135
                             scrollPane.getViewport().getExtentSize().height);
136 136
                     parent.setPanelHeight((int) (newSize * 0.95));
137 137
                 }

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/prefs/PrefsCategoryLoader.java View File

@@ -192,7 +192,7 @@ public class PrefsCategoryLoader extends LoggingSwingWorker<JPanel, Object> {
192 192
         final TextLabel label = new TextLabel(setting.getTitle() + ": ", false);
193 193
 
194 194
 
195
-        JComponent option = UIUtilities.invokeAndWait(
195
+        final JComponent option = UIUtilities.invokeAndWait(
196 196
                 new ReturnableThread<JComponent>() {
197 197
 
198 198
             /** {@inheritDoc} */

+ 8
- 7
src/com/dmdirc/addons/ui_swing/dialogs/serversetting/PerformTab.java View File

@@ -84,15 +84,16 @@ public final class PerformTab extends JPanel implements ActionListener {
84 84
 
85 85
         add(target, "growx, pushx, wrap");
86 86
 
87
-        Collection<PerformDescription> performList = new ArrayList<PerformDescription>();
87
+        final Collection<PerformDescription> performList
88
+                = new ArrayList<PerformDescription>();
88 89
 
89
-        PerformDescription networkPerform = new PerformDescription(
90
+        final PerformDescription networkPerform = new PerformDescription(
90 91
                 PerformType.NETWORK, server.getNetwork());
91
-        PerformDescription networkProfilePerform = new PerformDescription(
92
+        final PerformDescription networkProfilePerform = new PerformDescription(
92 93
                 PerformType.NETWORK, server.getNetwork() ,server.getProfile().getName());
93
-        PerformDescription serverPerform = new PerformDescription(
94
+        final PerformDescription serverPerform = new PerformDescription(
94 95
                 PerformType.SERVER, server.getAddress());
95
-        PerformDescription serverProfilePerform = new PerformDescription(
96
+        final PerformDescription serverProfilePerform = new PerformDescription(
96 97
                 PerformType.SERVER, server.getAddress() ,server.getProfile().getName());
97 98
 
98 99
         model.addElement(networkPerform);
@@ -130,8 +131,8 @@ public final class PerformTab extends JPanel implements ActionListener {
130 131
      */
131 132
     @Override
132 133
     public void actionPerformed(final ActionEvent e) {
133
-        PerformDescription perform = (PerformDescription)((JComboBox) e.getSource())
134
-                .getSelectedItem();
134
+        final PerformDescription perform
135
+                = (PerformDescription)((JComboBox) e.getSource()).getSelectedItem();
135 136
         performPanel.switchPerform(perform);
136 137
     }
137 138
 

+ 2
- 2
src/com/dmdirc/addons/ui_swing/dialogs/sslcertificate/CertificateInfoPanel.java View File

@@ -87,13 +87,13 @@ public class CertificateInfoPanel extends JScrollPane {
87 87
                         "alignx right");
88 88
                 final TextLabel text = new TextLabel(info.getValue(), false);
89 89
                 if (info.isInvalid()) {
90
-                    SimpleAttributeSet sas = new SimpleAttributeSet();
90
+                    final SimpleAttributeSet sas = new SimpleAttributeSet();
91 91
                     StyleConstants.setForeground(sas, Color.RED);
92 92
                     text.getDocument().setParagraphAttributes(0, info.getValue().
93 93
                             length(), sas, true);
94 94
                 }
95 95
                 if (info.isMissing()) {
96
-                    SimpleAttributeSet sas = new SimpleAttributeSet();
96
+                    final SimpleAttributeSet sas = new SimpleAttributeSet();
97 97
                     StyleConstants.setItalic(sas, true);
98 98
                     text.getDocument().setParagraphAttributes(0, info.getValue().
99 99
                             length(), sas, true);

+ 1
- 1
src/com/dmdirc/addons/ui_swing/framemanager/windowmenu/WindowMenuFrameManager.java View File

@@ -254,7 +254,7 @@ public final class WindowMenuFrameManager extends JMenu implements
254 254
     }
255 255
 
256 256
     private JMenu getParentMenu(final FrameContainer window) {
257
-        FrameContainer parent = window.getParent();
257
+        final FrameContainer parent = window.getParent();
258 258
 
259 259
         if (parent == null) {
260 260
             return this;

+ 14
- 13
src/com/dmdirc/addons/ui_swing/wizard/StepLayout.java View File

@@ -171,14 +171,15 @@ public class StepLayout implements LayoutManager2, Serializable {
171 171
             }
172 172
         }
173 173
         synchronized (parent.getTreeLock()) {
174
-            int componentCount = parent.getComponentCount();
174
+            final int componentCount = parent.getComponentCount();
175 175
             for (int i = 0; i < componentCount; i++) {
176
-                Component comp = parent.getComponent(i);
176
+                final Component comp = parent.getComponent(i);
177 177
                 if (comp.isVisible()) {
178 178
                     comp.setVisible(false);
179 179
                     break;
180 180
                 }
181 181
             }
182
+
182 183
             if (componentCount > 0) {
183 184
                 currentStep = stepNumber;
184 185
                 parent.getComponent(currentStep).setVisible(true);
@@ -249,14 +250,14 @@ public class StepLayout implements LayoutManager2, Serializable {
249 250
     @Override
250 251
     public Dimension preferredLayoutSize(final Container parent) {
251 252
         synchronized (parent.getTreeLock()) {
252
-            Insets insets = parent.getInsets();
253
-            int componentCount = parent.getComponentCount();
253
+            final Insets insets = parent.getInsets();
254
+            final int componentCount = parent.getComponentCount();
254 255
             int width = 0;
255 256
             int height = 0;
256 257
 
257 258
             for (int i = 0; i < componentCount; i++) {
258
-                Component comp = parent.getComponent(i);
259
-                Dimension preferredDimension = comp.getPreferredSize();
259
+                final Component comp = parent.getComponent(i);
260
+                final Dimension preferredDimension = comp.getPreferredSize();
260 261
                 if (preferredDimension.width > width) {
261 262
                     width = preferredDimension.width;
262 263
                 }
@@ -277,14 +278,14 @@ public class StepLayout implements LayoutManager2, Serializable {
277 278
     @Override
278 279
     public Dimension minimumLayoutSize(final Container parent) {
279 280
         synchronized (parent.getTreeLock()) {
280
-            Insets insets = parent.getInsets();
281
-            int componentCount = parent.getComponentCount();
281
+            final Insets insets = parent.getInsets();
282
+            final int componentCount = parent.getComponentCount();
282 283
             int width = 0;
283 284
             int height = 0;
284 285
 
285 286
             for (int i = 0; i < componentCount; i++) {
286
-                Component comp = parent.getComponent(i);
287
-                Dimension minimumDimension = comp.getMinimumSize();
287
+                final Component comp = parent.getComponent(i);
288
+                final Dimension minimumDimension = comp.getMinimumSize();
288 289
                 if (minimumDimension.width > width) {
289 290
                     width = minimumDimension.width;
290 291
                 }
@@ -340,15 +341,15 @@ public class StepLayout implements LayoutManager2, Serializable {
340 341
      */
341 342
     @Override
342 343
     public void invalidateLayout(final Container target) {
343
-    //Ignore
344
+        //Ignore
344 345
     }
345 346
 
346 347
     /** {@inheritDoc} */
347 348
     @Override
348 349
     public void layoutContainer(final Container parent) {
349 350
         synchronized (parent.getTreeLock()) {
350
-            Insets insets = parent.getInsets();
351
-            int componentCount = parent.getComponentCount();
351
+            final Insets insets = parent.getInsets();
352
+            final int componentCount = parent.getComponentCount();
352 353
             Component comp = null;
353 354
             boolean currentFound = false;
354 355
 

+ 1
- 1
src/com/dmdirc/addons/ui_web/DynamicRequestHandler.java View File

@@ -185,7 +185,7 @@ public class DynamicRequestHandler extends AbstractHandler {
185 185
             List<Event> myEvents = client.retrieveEvents();
186 186
 
187 187
             if (myEvents.isEmpty()) {
188
-                Continuation continuation = ContinuationSupport
188
+                final Continuation continuation = ContinuationSupport
189 189
                         .getContinuation(request, client.getMutex());
190 190
                 client.setContinuation(continuation);
191 191
                 continuation.suspend(30000L);

Loading…
Cancel
Save