Kaynağa Gözat

Style fixes

git-svn-id: http://svn.dmdirc.com/trunk@512 00569f92-eb28-0410-84fd-f71c24880f
tags/0.3
Gregory Holmes 17 yıl önce
ebeveyn
işleme
a729dc22aa

+ 4
- 4
src/uk/org/ownage/dmdirc/logger/DebugLevel.java Dosyayı Görüntüle

@@ -23,11 +23,11 @@
23 23
 package uk.org.ownage.dmdirc.logger;
24 24
 
25 25
 /**
26
- * Specific debug levels allowed by Logger
26
+ * Specific debug levels allowed by Logger.
27 27
  */
28 28
 public enum DebugLevel {        
29 29
     /**
30
-     * Normal debug messages
30
+     * debug levels recognised by the logger.
31 31
      */
32
-    NORMAL
33
-}
32
+    NORMAL,
33
+}

+ 4
- 16
src/uk/org/ownage/dmdirc/logger/ErrorLevel.java Dosyayı Görüntüle

@@ -23,23 +23,11 @@
23 23
 package uk.org.ownage.dmdirc.logger;
24 24
 
25 25
 /**
26
- * Specific error levels allowed by Logger
26
+ * Specific error levels allowed by Logger.
27 27
  */
28 28
 public enum ErrorLevel {        
29 29
     /**
30
-     * Fatal error
30
+     * error levels recognised by the logger.
31 31
      */
32
-    FATAL, 
33
-    /**
34
-     * Standard error
35
-     */
36
-    ERROR, 
37
-    /**
38
-     * Warning error
39
-     */
40
-    WARNING, 
41
-    /**
42
-     * Informational error
43
-     */
44
-    INFO
45
-}
32
+    FATAL, ERROR, WARNING, INFO,
33
+}

+ 5
- 20
src/uk/org/ownage/dmdirc/logger/LogLevel.java Dosyayı Görüntüle

@@ -23,27 +23,12 @@
23 23
 package uk.org.ownage.dmdirc.logger;
24 24
 
25 25
 /**
26
- * Specific log levels allowed by the Logger
26
+ * Specific log levels allowed by the Logger.
27 27
  */
28 28
 public enum LogLevel {        
29 29
     /**
30
-     * Core log messages
30
+     * log levels recognised by the logger.
31 31
      */
32
-    CORE, 
33
-    /**
34
-     * Command parser log messages
35
-     */
36
-    COMMAND, 
37
-    /**
38
-     * Parser log messages
39
-     */
40
-    PARSER, 
41
-    /**
42
-     * Plugin log messages
43
-     */
44
-    PLUGIN, 
45
-    /**
46
-     * UI log messages
47
-     */
48
-    UI
49
-}
32
+    CORE, COMMAND, PARSER,PLUGIN, UI,
33
+}
34
+

+ 79
- 74
src/uk/org/ownage/dmdirc/logger/Logger.java Dosyayı Görüntüle

@@ -22,105 +22,107 @@
22 22
 
23 23
 package uk.org.ownage.dmdirc.logger;
24 24
 
25
-import java.awt.event.WindowAdapter;
26
-import java.awt.event.WindowEvent;
27
-import java.beans.PropertyChangeEvent;
28
-import java.beans.PropertyChangeListener;
29
-import java.io.BufferedWriter;
30 25
 import java.io.FileWriter;
31 26
 import java.io.IOException;
32 27
 import java.io.PrintWriter;
33 28
 import java.text.SimpleDateFormat;
34 29
 import java.util.Date;
30
+
35 31
 import javax.swing.JDialog;
36 32
 import javax.swing.JOptionPane;
33
+
37 34
 import uk.org.ownage.dmdirc.Config;
38 35
 import uk.org.ownage.dmdirc.ui.FatalErrorDialog;
39 36
 import uk.org.ownage.dmdirc.ui.MainFrame;
40 37
 
41 38
 /**
42 39
  * Logger class for an applications, provides logging, error logging and debug
43
- * logging
40
+ * logging.
44 41
  */
45
-public class Logger {
42
+public final class Logger {
46 43
     
47 44
     /**
48
-     * Logging Printwriter
45
+     * Logging Printwriter.
49 46
      */
50
-    private static PrintWriter logWriter = null;
47
+    private static PrintWriter logWriter;
51 48
     
52 49
     /**
53
-     * Debug Printwriter
50
+     * Debug Printwriter.
54 51
      */
55
-    private static PrintWriter debugWriter = null;
52
+    private static PrintWriter debugWriter;
56 53
     
57 54
     /**
58
-     * Error Printwriter
55
+     * Error Printwriter.
59 56
      */
60
-    private static PrintWriter errorWriter = null;
57
+    private static PrintWriter errorWriter;
61 58
     
62 59
     /**
63
-     * dialog used to report errors to the ui
60
+     * dialog used to report errors to the ui.
64 61
      */
65 62
     private static JDialog dialog;
66 63
     
67 64
     /**
68
-     * JOptionPane used as part of some dialogs
65
+     * JOptionPane used as part of some dialogs.
69 66
      */
70 67
     private static JOptionPane optionPane;
71 68
     
72 69
     /**
73
-     * Date formatter, used for logging and displaying messages
70
+     * Date formatter, used for logging and displaying messages.
74 71
      */
75 72
     private static SimpleDateFormat formatter;
76 73
     
77 74
     /**
78
-     * Prevents creation a new instance of Logger
75
+     * Prevents creation a new instance of Logger.
79 76
      */
80 77
     private Logger() {
81 78
     }
82 79
     
83 80
     /**
84
-     * Record an error message for the application, notifying the user if appropriate
85
-     * @param level error level
86
-     * @param message Error message/cause
81
+     * Record an error message for the application, notifying the user
82
+     * if appropriate.
83
+     * @param level error level.
84
+     * @param message Error message/cause.
87 85
      */
88
-    public static void error(ErrorLevel level, String message) {
86
+    public static void error(final ErrorLevel level, final String message) {
89 87
         if (logWriter == null || debugWriter == null || errorWriter == null) {
90 88
             createWriters();
91 89
         }
92 90
         
93 91
         switch (level) {
94 92
             case FATAL:
95
-                errorWriter.println(formatter.format(new Date())+": ERROR: "+level+" :"+message);
96
-                dialog = new FatalErrorDialog(MainFrame.getMainFrame(), true, new String[]{message});
93
+                errorWriter.println(formatter.format(new Date()) + ": ERROR: "
94
+                        + level + " :" + message);
95
+                dialog = new FatalErrorDialog(MainFrame.getMainFrame(), true,
96
+                        new String[]{message});
97 97
                 dialog.pack();
98 98
                 dialog.setLocationRelativeTo(MainFrame.getMainFrame());
99 99
                 dialog.setVisible(true);
100 100
                 break;
101 101
             default:
102
-                errorWriter.println(formatter.format(new Date())+": ERROR: "+level+" :"+message);
103
-                System.err.println(formatter.format(new Date())+": ERROR: "+level+" :"+message);
102
+                errorWriter.println(formatter.format(new Date()) + ": ERROR: "
103
+                        + level + " :" + message);
104
+                System.err.println(formatter.format(new Date()) + ": ERROR: "
105
+                        + level + " :" + message);
104 106
                 break;
105 107
         }
106 108
     }
107 109
     
108 110
     /**
109 111
      * Record an error message for the application at the error error level,
110
-     * notifying the user if appropriate
111
-     * @param message Error message/cause
112
+     * notifying the user if appropriate.
113
+     * @param message Error message/cause.
112 114
      */
113
-    public static void error(String message) {
115
+    public static void error(final String message) {
114 116
         error(ErrorLevel.ERROR, message);
115 117
     }
116 118
     
117 119
     /**
118 120
      * Record an error message for the application, notifying the user if
119
-     * appropriate
120
-     * @param level error level
121
-     * @param exception Cause of error
121
+     * appropriate.
122
+     * @param level error level.
123
+     * @param exception Cause of error.
122 124
      */
123
-    public static void error(ErrorLevel level, Exception exception) {
125
+    public static void error(final ErrorLevel level, final Exception exception) {
124 126
         String[] message;
125 127
         int i;
126 128
         
@@ -128,17 +130,17 @@ public class Logger {
128 130
             createWriters();
129 131
         }
130 132
         
131
-        StackTraceElement[] stackTrace = exception.getStackTrace();
133
+        final StackTraceElement[] stackTrace = exception.getStackTrace();
132 134
         switch (level) {
133 135
             case FATAL:
134
-                errorWriter.println(formatter.format(new Date())+
135
-                        ": ERROR: "+level+" :"+exception);
136
-                message = new String[stackTrace.length+1];
136
+                errorWriter.println(formatter.format(new Date())
137
+                + ": ERROR: " + level + " :" + exception);
138
+                message = new String[stackTrace.length + 1];
137 139
                 message[0] = exception.toString();
138 140
                 i = 1;
139
-                for (StackTraceElement traceElement: stackTrace) {
140
-                    message[i] = "\t"+traceElement.toString();
141
-                    errorWriter.println("\t"+traceElement);
141
+                for (StackTraceElement traceElement : stackTrace) {
142
+                    message[i] = "\t" + traceElement.toString();
143
+                    errorWriter.println("\t" + traceElement);
142 144
                     i++;
143 145
                 }
144 146
                 dialog = new FatalErrorDialog(MainFrame.getMainFrame(),
@@ -148,13 +150,13 @@ public class Logger {
148 150
                 dialog.setVisible(true);
149 151
                 break;
150 152
             default:
151
-                System.err.println(formatter.format(new Date())+
152
-                        ": ERROR: "+level+" :"+exception);
153
-                errorWriter.println(formatter.format(new Date())+
154
-                        ": ERROR: "+level+" :"+exception);
155
-                for (StackTraceElement traceElement: stackTrace) {
156
-                    System.err.println("\t"+traceElement);
157
-                    errorWriter.println("\t"+traceElement);
153
+                System.err.println(formatter.format(new Date())
154
+                + ": ERROR: " + level + " :" + exception);
155
+                errorWriter.println(formatter.format(new Date())
156
+                + ": ERROR: " + level + " :" + exception);
157
+                for (StackTraceElement traceElement : stackTrace) {
158
+                    System.err.println("\t" + traceElement);
159
+                    errorWriter.println("\t" + traceElement);
158 160
                 }
159 161
                 break;
160 162
         }
@@ -162,21 +164,21 @@ public class Logger {
162 164
     
163 165
     /**
164 166
      * Record an error message for the application at the error error level,
165
-     * notifying the user if appropriate
166
-     * @param exception Cause of error
167
+     * notifying the user if appropriate.
168
+     * @param exception Cause of error.
167 169
      */
168
-    public static void error(Exception exception) {
170
+    public static void error(final Exception exception) {
169 171
         error(ErrorLevel.ERROR, exception);
170 172
     }
171 173
     
172 174
     /**
173 175
      * Record an debug message for the application, notifying the user if
174
-     * appropriate
175
-     * @param level debug level
176
-     * @param message Debug message
176
+     * appropriate.
177
+     * @param level debug level.
178
+     * @param message Debug message.
177 179
      */
178
-    public static void debug(DebugLevel level, String message) {
179
-        if (!Config.hasOption("logging","debugLogging")
180
+    public static void debug(final DebugLevel level, final String message) {
181
+        if (!Config.hasOption("logging", "debugLogging")
180 182
         && !Config.getOption("logging", "debugLogging").equals("true")) {
181 183
             return;
182 184
         }
@@ -186,35 +188,35 @@ public class Logger {
186 188
         
187 189
         switch(level) {
188 190
             default:
189
-                if (Config.hasOption("logging","debugLoggingSysOut")
191
+                if (Config.hasOption("logging", "debugLoggingSysOut")
190 192
                 && Config.getOption("logging", "debugLoggingSysOut")
191 193
                 .equals("true")) {
192
-                    System.out.println(formatter.format(new Date())+
193
-                            ": DEBUG: "+level+" :"+message);
194
+                    System.out.println(formatter.format(new Date()) 
195
+                    + ": DEBUG: " + level + " :" + message);
194 196
                 }
195 197
                 
196
-                debugWriter.println(formatter.format(new Date())+
197
-                        ": DEBUG: "+level+" :"+message);
198
+                debugWriter.println(formatter.format(new Date()) 
199
+                + ": DEBUG: " + level + " :" + message);
198 200
                 break;
199 201
         }
200 202
     }
201 203
     
202 204
     /**
203 205
      * Record an debug message for the application at the normal debug level,
204
-     * notifying the user if appropriate
205
-     * @param message Debug message
206
+     * notifying the user if appropriate.
207
+     * @param message Debug message.
206 208
      */
207
-    public static void debug(String message) {
209
+    public static void debug(final String message) {
208 210
         debug(DebugLevel.NORMAL, message);
209 211
     }
210 212
     
211 213
     /**
212
-     * Record a log message for the application
213
-     * @param level log level
214
-     * @param message Log message
214
+     * Record a log message for the application.
215
+     * @param level log level.
216
+     * @param message Log message.
215 217
      */
216
-    public static void log(LogLevel level, String message) {
217
-        if (!Config.hasOption("logging","programLogging")
218
+    public static void log(final LogLevel level, final String message) {
219
+        if (!Config.hasOption("logging", "programLogging")
218 220
         && !Config.getOption("logging", "programLogging").equals("true")) {
219 221
             return;
220 222
         }
@@ -224,28 +226,31 @@ public class Logger {
224 226
         
225 227
         switch(level) {
226 228
             default:
227
-                logWriter.println(formatter.format(new Date())+
228
-                        ": LOG: "+level+" :"+message);
229
+                logWriter.println(formatter.format(new Date()) 
230
+                + ": LOG: " + level + " :" + message);
229 231
                 break;
230 232
         }
231 233
     }
232 234
     
233 235
     /**
234
-     * Initialises the the loggers writers (debug, error, log) and date formatter
236
+     * Initialises the the loggers writers (debug, error, log) and date formatter.
235 237
      */
236 238
     private static void createWriters() {
237 239
         try {
238 240
             if (logWriter == null) {
239 241
                 logWriter = new PrintWriter(
240
-                        new FileWriter(Config.getConfigDir()+"log.log", true), true);
242
+                        new FileWriter(Config.getConfigDir() 
243
+                        + "log.log", true), true);
241 244
             }
242 245
             if (debugWriter == null) {
243 246
                 debugWriter = new PrintWriter(
244
-                        new FileWriter(Config.getConfigDir()+"debug.log", true), true);
247
+                        new FileWriter(Config.getConfigDir() 
248
+                        + "debug.log", true), true);
245 249
             }
246 250
             if (errorWriter == null) {
247 251
                 errorWriter = new PrintWriter(
248
-                        new FileWriter(Config.getConfigDir()+"error.log", true), true);
252
+                        new FileWriter(Config.getConfigDir() 
253
+                        + "error.log", true), true);
249 254
             }
250 255
         } catch (IOException ex) {
251 256
             Logger.error(ErrorLevel.WARNING, ex);
@@ -257,4 +262,4 @@ public class Logger {
257 262
             formatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
258 263
         }
259 264
     }
260
-}
265
+}

+ 182
- 184
src/uk/org/ownage/dmdirc/ui/framemanager/tree/TreeFrameManager.java Dosyayı Görüntüle

@@ -35,6 +35,7 @@ import java.awt.event.MouseMotionListener;
35 35
 import java.awt.event.MouseWheelEvent;
36 36
 import java.awt.event.MouseWheelListener;
37 37
 import java.util.Hashtable;
38
+
38 39
 import javax.swing.JComponent;
39 40
 import javax.swing.JMenuItem;
40 41
 import javax.swing.JPopupMenu;
@@ -54,6 +55,7 @@ import javax.swing.tree.DefaultTreeModel;
54 55
 import javax.swing.tree.ExpandVetoException;
55 56
 import javax.swing.tree.TreePath;
56 57
 import javax.swing.tree.TreeSelectionModel;
58
+
57 59
 import uk.org.ownage.dmdirc.Channel;
58 60
 import uk.org.ownage.dmdirc.Config;
59 61
 import uk.org.ownage.dmdirc.FrameContainer;
@@ -65,86 +67,86 @@ import uk.org.ownage.dmdirc.logger.Logger;
65 67
 import uk.org.ownage.dmdirc.ui.framemanager.FrameManager;
66 68
 
67 69
 /**
68
- * Manages open windows in the application in a tree style view
70
+ * Manages open windows in the application in a tree style view.
69 71
  */
70
-public class TreeFrameManager implements FrameManager, TreeModelListener,
72
+public final class TreeFrameManager implements FrameManager, TreeModelListener,
71 73
         TreeSelectionListener, TreeExpansionListener, TreeWillExpandListener,
72 74
         MouseListener, ActionListener, MouseMotionListener, MouseWheelListener,
73 75
         KeyListener {
74 76
     
75 77
     /**
76
-     * display tree
78
+     * display tree.
77 79
      */
78 80
     private JTree tree;
79 81
     
80 82
     /**
81
-     * Scrollpane for the tree
83
+     * Scrollpane for the tree.
82 84
      */
83 85
     private JScrollPane scrollPane;
84 86
     
85 87
     /**
86
-     * root node
88
+     * root node.
87 89
      */
88 90
     private DefaultMutableTreeNode root;
89 91
     
90 92
     /**
91
-     * node renderer
93
+     * node renderer.
92 94
      */
93 95
     private TreeViewTreeCellRenderer renderer;
94 96
     
95 97
     /**
96
-     * data model
98
+     * data model.
97 99
      */
98 100
     private TreeViewModel model;
99 101
     
100 102
     /**
101
-     * node storage, used for adding and deleting nodes correctly
103
+     * node storage, used for adding and deleting nodes correctly.
102 104
      */
103 105
     private Hashtable<FrameContainer, DefaultMutableTreeNode> nodes;
104 106
     
105 107
     /**
106
-     * stores colour associated with a node, cheap hack till i rewrite the model
108
+     * stores colour associated with a node, cheap hack till i rewrite the model.
107 109
      */
108 110
     private Hashtable<FrameContainer, Color> nodeColours;
109 111
     
110 112
     /**
111 113
      * stores background colour associated with a node,
112
-     * cheap hack till i rewrite the model
114
+     * cheap hack till i rewrite the model.
113 115
      */
114 116
     private DefaultMutableTreeNode rolloverNode;
115 117
     
116 118
     /**
117
-     * popup menu for menu items on nodes
119
+     * popup menu for menu items on nodes.
118 120
      */
119 121
     private JPopupMenu popup;
120 122
     
121 123
     /**
122
-     * close menu item used in popup menus
124
+     * close menu item used in popup menus.
123 125
      */
124 126
     private JMenuItem closeMenuItem;
125 127
     
126 128
     /**
127
-     * The object that is currently selected
129
+     * The object that is currently selected.
128 130
      */
129 131
     private FrameContainer selected;
130 132
     
131 133
     /**
132
-     *Parent component for the frame manager
134
+     *Parent component for the frame manager.
133 135
      */
134 136
     private JComponent parent;
135 137
     
136 138
     /**
137
-     * whether the mouse button is currently pressed
139
+     * whether the mouse button is currently pressed.
138 140
      */
139 141
     private boolean mouseClicked = true;
140 142
     
141 143
     /**
142
-     *node under right click operation
144
+     *node under right click operation.
143 145
      */
144 146
     private DefaultMutableTreeNode popupNode;
145 147
     
146 148
     /**
147
-     * creates a new instance of the TreeFrameManager
149
+     * creates a new instance of the TreeFrameManager.
148 150
      */
149 151
     public TreeFrameManager() {
150 152
         nodes = new Hashtable<FrameContainer, DefaultMutableTreeNode>();
@@ -172,8 +174,8 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
172 174
     }
173 175
     /**
174 176
      * Indicates whether this frame manager can be positioned vertically
175
-     * (i.e., at the side of the screen)
176
-     * @return True iff the frame manager can be positioned vertically
177
+     * (i.e., at the side of the screen).
178
+     * @return True iff the frame manager can be positioned vertically.
177 179
      */
178 180
     public boolean canPositionVertically() {
179 181
         return true;
@@ -181,18 +183,18 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
181 183
     
182 184
     /**
183 185
      * Indicates whether this frame manager can be positioned horizontally
184
-     * (i.e., at the top or bottom of the screen)
185
-     * @return True iff the frame manager can be positioned horizontally
186
+     * (i.e., at the top or bottom of the screen).
187
+     * @return True iff the frame manager can be positioned horizontally.
186 188
      */
187 189
     public boolean canPositionHorizontally() {
188 190
         return false;
189 191
     }
190 192
     
191 193
     /**
192
-     * Indicates that there is a new active frame
193
-     * @param source The object that now has focus
194
+     * Indicates that there is a new active frame.
195
+     * @param source The object that now has focus.
194 196
      */
195
-    public void setSelected(FrameContainer source) {
197
+    public void setSelected(final FrameContainer source) {
196 198
         selected = source;
197 199
         SwingUtilities.invokeLater(new Runnable() {
198 200
             public void run() {
@@ -202,16 +204,16 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
202 204
     }
203 205
     
204 206
     /**
205
-     * Retrieves the currently selected object
206
-     * @return The object that is currently selected
207
+     * Retrieves the currently selected object.
208
+     * @return The object that is currently selected.
207 209
      */
208 210
     public FrameContainer getSelected() {
209 211
         return selected;
210 212
     }
211 213
     
212 214
     /**
213
-     * Retrieves the currently selected node
214
-     * @return The node that is currently selected
215
+     * Retrieves the currently selected node.
216
+     * @return The node that is currently selected.
215 217
      */
216 218
     public DefaultMutableTreeNode getSelectedNode() {
217 219
         return nodes.get(selected);
@@ -219,11 +221,11 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
219 221
     
220 222
     /**
221 223
      * Shows an event notification to the user by colouring the corresponding
222
-     * element to the source a specific colour
223
-     * @param source The object requesting notification
224
-     * @param colour The colour that should be used to indicate the notification
224
+     * element to the source a specific colour.
225
+     * @param source The object requesting notification.
226
+     * @param colour The colour that should be used to indicate the notification.
225 227
      */
226
-    public void showNotification(FrameContainer source, Color colour) {
228
+    public void showNotification(final FrameContainer source, final Color colour) {
227 229
         if (nodeColours != null) {
228 230
             nodeColours.put(source, colour);
229 231
             SwingUtilities.invokeLater(new Runnable() {
@@ -235,10 +237,10 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
235 237
     }
236 238
     
237 239
     /**
238
-     * Sets the rollover node and repaints the tree
239
-     * @param node rollover node
240
+     * Sets the rollover node and repaints the tree.
241
+     * @param node rollover node.
240 242
      */
241
-    public void showRollover(DefaultMutableTreeNode node) {
243
+    public void showRollover(final DefaultMutableTreeNode node) {
242 244
         rolloverNode = node;
243 245
         SwingUtilities.invokeLater(new Runnable() {
244 246
             public void run() {
@@ -248,29 +250,29 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
248 250
     }
249 251
     
250 252
     /**
251
-     * retrives the rollover node
252
-     * @return rollover node
253
+     * retrives the rollover node.
254
+     * @return rollover node.
253 255
      */
254 256
     public DefaultMutableTreeNode getRollover() {
255 257
         return rolloverNode;
256 258
     }
257 259
     
258 260
     /**
259
-     * Clears a notification from a frame and its node
260
-     * @param source Frame to remove notification from
261
+     * Clears a notification from a frame and its node.
262
+     * @param source Frame to remove notification from.
261 263
      */
262
-    public void clearNotification(FrameContainer source) {
264
+    public void clearNotification(final FrameContainer source) {
263 265
         if (nodeColours != null && nodeColours.containsKey(source)) {
264 266
             nodeColours.remove(source);
265 267
         }
266 268
     }
267 269
     
268 270
     /**
269
-     * retrieves the colour of a specific node
270
-     * @param source node to check colour of
271
-     * @return colour of the node
271
+     * retrieves the colour of a specific node.
272
+     * @param source node to check colour of.
273
+     * @return colour of the node.
272 274
      */
273
-    public Color getNodeColour(FrameContainer source) {
275
+    public Color getNodeColour(final FrameContainer source) {
274 276
         if (nodeColours != null && nodeColours.containsKey(source)) {
275 277
             return nodeColours.get(source);
276 278
         }
@@ -278,16 +280,16 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
278 280
     }
279 281
     
280 282
     /**
281
-     * Sets the parent component in the main UI
282
-     * @param parent parent component
283
+     * Sets the parent component in the main UI.
284
+     * @param newParent parent component.
283 285
      */
284
-    public void setParent(JComponent parent) {
285
-        this.parent = parent;
286
+    public void setParent(final JComponent newParent) {
287
+        this.parent = newParent;
286 288
         scrollPane = new JScrollPane(tree);
287 289
         scrollPane.setAutoscrolls(false);
288 290
         parent.setLayout(new BorderLayout());
289 291
         parent.add(scrollPane);
290
-        scrollPane.setPreferredSize(new Dimension(parent.getWidth(), 0));;
292
+        scrollPane.setPreferredSize(new Dimension(parent.getWidth(), 0));
291 293
         tree.setForeground(parent.getForeground());
292 294
         tree.setBorder(new EmptyBorder(5, 5, 5, 5));
293 295
         tree.setVisible(true);
@@ -295,11 +297,11 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
295 297
     }
296 298
     
297 299
     /**
298
-     * adds a server to the tree
299
-     * @param server associated server
300
+     * adds a server to the tree.
301
+     * @param server associated server.
300 302
      */
301
-    public void addServer(Server server) {
302
-        DefaultMutableTreeNode node = new DefaultMutableTreeNode();
303
+    public void addServer(final Server server) {
304
+        final DefaultMutableTreeNode node = new DefaultMutableTreeNode();
303 305
         nodes.put(server, node);
304 306
         node.setUserObject(server);
305 307
         model.insertNodeInto(node, root);
@@ -310,20 +312,20 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
310 312
     }
311 313
     
312 314
     /**
313
-     * removes a server from the tree
314
-     * @param server associated server
315
+     * removes a server from the tree.
316
+     * @param server associated server.
315 317
      */
316
-    public void delServer(Server server) {
318
+    public void delServer(final Server server) {
317 319
         model.removeNodeFromParent(nodes.get(server));
318 320
     }
319 321
     
320 322
     /**
321
-     * adds a channel to the tree
322
-     * @param server associated server
323
-     * @param channel associated framecontainer
323
+     * adds a channel to the tree.
324
+     * @param server associated server.
325
+     * @param channel associated framecontainer.
324 326
      */
325
-    public void addChannel(Server server, Channel channel) {
326
-        DefaultMutableTreeNode node = new DefaultMutableTreeNode();
327
+    public void addChannel(final Server server, final Channel channel) {
328
+        final DefaultMutableTreeNode node = new DefaultMutableTreeNode();
327 329
         nodes.put(channel, node);
328 330
         node.setUserObject(channel);
329 331
         model.insertNodeInto(node, nodes.get(server));
@@ -331,21 +333,21 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
331 333
     }
332 334
     
333 335
     /**
334
-     * deletes a channel from the tree
335
-     * @param server associated server
336
-     * @param channel associated framecontainer
336
+     * deletes a channel from the tree.
337
+     * @param server associated server.
338
+     * @param channel associated framecontainer.
337 339
      */
338
-    public void delChannel(Server server, Channel channel) {
340
+    public void delChannel(final Server server, final Channel channel) {
339 341
         model.removeNodeFromParent(nodes.get(channel));
340 342
     }
341 343
     
342 344
     /**
343
-     * adds a query to the tree
344
-     * @param server associated server
345
-     * @param query associated framecontainer
345
+     * adds a query to the tree.
346
+     * @param server associated server.
347
+     * @param query associated framecontainer.
346 348
      */
347
-    public void addQuery(Server server, Query query) {
348
-        DefaultMutableTreeNode node = new DefaultMutableTreeNode();
349
+    public void addQuery(final Server server, final Query query) {
350
+        final DefaultMutableTreeNode node = new DefaultMutableTreeNode();
349 351
         nodes.put(query, node);
350 352
         node.setUserObject(query);
351 353
         model.insertNodeInto(node, nodes.get(server));
@@ -353,134 +355,134 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
353 355
     }
354 356
     
355 357
     /**
356
-     * deletes a query from the tree
357
-     * @param server associated server
358
-     * @param query associated framecontainer
358
+     * deletes a query from the tree.
359
+     * @param server associated server.
360
+     * @param query associated framecontainer.
359 361
      */
360
-    public void delQuery(Server server, Query query) {
362
+    public void delQuery(final Server server, final Query query) {
361 363
         model.removeNodeFromParent(nodes.get(query));
362 364
     }
363 365
     
364 366
     /**
365
-     * adds a raw to the tree
366
-     * @param server associated server
367
-     * @param raw associated framecontainer
367
+     * adds a raw to the tree.
368
+     * @param server associated server.
369
+     * @param raw associated framecontainer.
368 370
      */
369
-    public void addRaw(Server server, Raw raw) {
370
-        DefaultMutableTreeNode node = new DefaultMutableTreeNode();
371
+    public void addRaw(final Server server, final Raw raw) {
372
+        final DefaultMutableTreeNode node = new DefaultMutableTreeNode();
371 373
         nodes.put(raw, node);
372 374
         node.setUserObject(raw);
373 375
         model.insertNodeInto(node, nodes.get(server));
374 376
     }
375 377
     
376 378
     /**
377
-     * deletes a raw from the tree
378
-     * @param server associated server
379
-     * @param raw associated framecontainer
379
+     * deletes a raw from the tree.
380
+     * @param server associated server.
381
+     * @param raw associated framecontainer.
380 382
      */
381
-    public void delRaw(Server server, Raw raw) {
383
+    public void delRaw(final Server server, final Raw raw) {
382 384
         model.removeNodeFromParent(nodes.get(raw));
383 385
     }
384 386
     
385 387
     /**
386
-     * valled whenever the value of the selection changes
387
-     * @param e selection event
388
+     * valled whenever the value of the selection changes.
389
+     * @param e selection event.
388 390
      */
389
-    public void valueChanged(TreeSelectionEvent e) {
390
-        DefaultMutableTreeNode node =
391
+    public void valueChanged(final TreeSelectionEvent e) {
392
+        final DefaultMutableTreeNode node =
391 393
                 (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
392 394
         
393
-        if (node == null) return;
395
+        if (node == null) { return; }
394 396
         
395
-        Object nodeInfo = node.getUserObject();
397
+        final Object nodeInfo = node.getUserObject();
396 398
         if (nodeInfo instanceof FrameContainer) {
397
-            ((FrameContainer)nodeInfo).activateFrame();
399
+            ((FrameContainer) nodeInfo).activateFrame();
398 400
         } else {
399 401
             Logger.error(ErrorLevel.WARNING, "Unknown node type.");
400 402
         }
401 403
     }
402 404
     
403 405
     /**
404
-     * Called after the tree has been expanded
405
-     * @param event expansion event
406
+     * Called after the tree has been expanded.
407
+     * @param event expansion event.
406 408
      */
407
-    public void treeExpanded(TreeExpansionEvent event) {
409
+    public void treeExpanded(final TreeExpansionEvent event) {
408 410
     }
409 411
     
410 412
     /**
411
-     * Called after the tree has been collapsed
412
-     * @param event expansion event
413
+     * Called after the tree has been collapsed.
414
+     * @param event expansion event.
413 415
      */
414
-    public void treeCollapsed(TreeExpansionEvent event) {
416
+    public void treeCollapsed(final TreeExpansionEvent event) {
415 417
     }
416 418
     
417 419
     /**
418
-     * Called when the tree is about to expand
419
-     * @param event expansion event
420
-     * @throws javax.swing.tree.ExpandVetoException thrown to prevent
420
+     * Called when the tree is about to expand.
421
+     * @param event expansion event.
422
+     * @throws javax.swing.tree.ExpandVetoException thrown to prevent.
421 423
      * node expanding
422 424
      */
423
-    public void treeWillExpand(TreeExpansionEvent event) throws
425
+    public void treeWillExpand(final TreeExpansionEvent event) throws
424 426
             ExpandVetoException {
425 427
     }
426 428
     
427 429
     /**
428
-     * Called when the tree is about to collapse
429
-     * @param event expansion event
430
-     * @throws javax.swing.tree.ExpandVetoException throw to prevent
430
+     * Called when the tree is about to collapse.
431
+     * @param event expansion event.
432
+     * @throws javax.swing.tree.ExpandVetoException throw to prevent.
431 433
      * node collapsing
432 434
      */
433
-    public void treeWillCollapse(TreeExpansionEvent event) throws
435
+    public void treeWillCollapse(final TreeExpansionEvent event) throws
434 436
             ExpandVetoException {
435 437
     }
436 438
     
437 439
     /**
438
-     * called after a node, or set of nodes, changes
439
-     * @param e change event
440
+     * called after a node, or set of nodes, changes.
441
+     * @param e change event.
440 442
      */
441
-    public void treeNodesChanged(TreeModelEvent e) {
443
+    public void treeNodesChanged(final TreeModelEvent e) {
442 444
     }
443 445
     
444 446
     /**
445
-     * called after a node has been inserted into the tree
446
-     * @param e change event
447
+     * called after a node has been inserted into the tree.
448
+     * @param e change event.
447 449
      */
448
-    public void treeNodesInserted(TreeModelEvent e) {
450
+    public void treeNodesInserted(final TreeModelEvent e) {
449 451
     }
450 452
     
451 453
     /**
452
-     * Called when a node is removed from the tree
453
-     * @param e change event
454
+     * Called when a node is removed from the tree.
455
+     * @param e change event.
454 456
      */
455
-    public void treeNodesRemoved(TreeModelEvent e) {
457
+    public void treeNodesRemoved(final TreeModelEvent e) {
456 458
     }
457 459
     
458 460
     /**
459
-     * Called when a tree changes structure
460
-     * @param e change event
461
+     * Called when a tree changes structure.
462
+     * @param e change event.
461 463
      */
462
-    public void treeStructureChanged(TreeModelEvent e) {
464
+    public void treeStructureChanged(final TreeModelEvent e) {
463 465
     }
464 466
     
465 467
     /**
466 468
      * Invoked when the mouse button has been clicked (pressed and released)
467 469
      * on a component.
468
-     * @param e mouse event
470
+     * @param e mouse event.
469 471
      */
470
-    public void mouseClicked(MouseEvent e) {
472
+    public void mouseClicked(final MouseEvent e) {
471 473
     }
472 474
     
473 475
     /**
474 476
      * Invoked when a mouse button has been pressed on a component.
475
-     * @param e mouse event
477
+     * @param e mouse event.
476 478
      */
477
-    public void mousePressed(MouseEvent e) {
479
+    public void mousePressed(final MouseEvent e) {
478 480
         mouseClicked = true;
479 481
         if (e.isPopupTrigger()) {
480
-            JTree source = (JTree)e.getSource();
481
-            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
482
+            final JTree source = (JTree) e.getSource();
483
+            final TreePath path = tree.getPathForLocation(e.getX(), e.getY());
482 484
             if (path != null) {
483
-                popupNode = (DefaultMutableTreeNode)path.getLastPathComponent();
485
+                popupNode = (DefaultMutableTreeNode) path.getLastPathComponent();
484 486
                 popup.show(source, e.getX(), e.getY());
485 487
             }
486 488
         }
@@ -488,75 +490,74 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
488 490
     
489 491
     /**
490 492
      * Invoked when a mouse button has been released on a component.
491
-     * @param e mouse event
493
+     * @param e mouse event.
492 494
      */
493
-    public void mouseReleased(MouseEvent e) {
495
+    public void mouseReleased(final MouseEvent e) {
494 496
         mouseClicked = false;
495 497
     }
496 498
     
497 499
     /**
498 500
      * Invoked when the mouse enters a component.
499
-     * @param e mouse event
501
+     * @param e mouse event.
500 502
      */
501
-    public void mouseEntered(MouseEvent e) {
503
+    public void mouseEntered(final MouseEvent e) {
502 504
     }
503 505
     
504 506
     /**
505 507
      * Invoked when the mouse exits a component.
506
-     * @param e mouse event
508
+     * @param e mouse event.
507 509
      */
508
-    public void mouseExited(MouseEvent e) {
510
+    public void mouseExited(final MouseEvent e) {
509 511
     }
510 512
     
511 513
     /**
512 514
      * Invoked when an action occurs.
513
-     * @param e action event
515
+     * @param e action event.
514 516
      */
515
-    public void actionPerformed(ActionEvent e) {
517
+    public void actionPerformed(final ActionEvent e) {
516 518
         if (e.getSource() == closeMenuItem && popupNode != null) {
517
-            ((FrameContainer)popupNode.getUserObject()).close();
519
+            ((FrameContainer) popupNode.getUserObject()).close();
518 520
             popupNode = null;
519 521
         }
520 522
     }
521 523
     
522 524
     /**
523 525
      * Invoked when a mouse button is pressed on a component and then dragged.
524
-     * @param e mouse event
526
+     * @param e mouse event.
525 527
      */
526
-    public void mouseDragged(MouseEvent e) {
528
+    public void mouseDragged(final MouseEvent e) {
527 529
         TreePath selectedPath, currentSelectedPath, oldSelectedPath = null;
528 530
         DefaultMutableTreeNode node = null;
529
-        DefaultTreeModel treeModel = (DefaultTreeModel)tree.getModel();
530
-        int selRow = tree.getRowForLocation(e.getX(), e.getY());
531
-        if (selRow < 0) {
531
+        final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
532
+        if (tree.getRowForLocation(e.getX(), e.getY()) < 0) {
532 533
             currentSelectedPath = oldSelectedPath;
533 534
             oldSelectedPath = null;
534 535
             if (currentSelectedPath != null) {
535
-                node = (DefaultMutableTreeNode)currentSelectedPath.getLastPathComponent();
536
-                if (Config.hasOption("ui", "rolloverEnabled") &&
537
-                        Config.getOption("ui", "rolloverEnabled").equals("true")) {
536
+                node = (DefaultMutableTreeNode) currentSelectedPath.getLastPathComponent();
537
+                if (Config.hasOption("ui", "rolloverEnabled") 
538
+                && Config.getOption("ui", "rolloverEnabled").equals("true")) {
538 539
                     this.showRollover(node);
539 540
                 }
540
-                ((FrameContainer)node.getUserObject()).activateFrame();
541
+                ((FrameContainer) node.getUserObject()).activateFrame();
541 542
             } else {
542
-                if (Config.hasOption("ui", "rolloverEnabled") &&
543
-                        Config.getOption("ui", "rolloverEnabled").equals("true")) {
543
+                if (Config.hasOption("ui", "rolloverEnabled") 
544
+                && Config.getOption("ui", "rolloverEnabled").equals("true")) {
544 545
                     this.showRollover(node);
545 546
                 }
546 547
             }
547 548
         } else {
548 549
             selectedPath = tree.getPathForLocation(e.getX(), e.getY());
549
-            if ((oldSelectedPath== null) || !selectedPath.equals(oldSelectedPath)) {
550
+            if ((oldSelectedPath == null) || !selectedPath.equals(oldSelectedPath)) {
550 551
                 oldSelectedPath = selectedPath;
551
-                node = (DefaultMutableTreeNode)oldSelectedPath.getLastPathComponent();
552
-                if (Config.hasOption("ui", "rolloverEnabled") &&
553
-                        Config.getOption("ui", "rolloverEnabled").equals("true")) {
552
+                node = (DefaultMutableTreeNode) oldSelectedPath.getLastPathComponent();
553
+                if (Config.hasOption("ui", "rolloverEnabled") 
554
+                && Config.getOption("ui", "rolloverEnabled").equals("true")) {
554 555
                     this.showRollover(node);
555 556
                 }
556
-                ((FrameContainer)node.getUserObject()).activateFrame();
557
+                ((FrameContainer) node.getUserObject()).activateFrame();
557 558
             } else {
558
-                if (Config.hasOption("ui", "rolloverEnabled") &&
559
-                        Config.getOption("ui", "rolloverEnabled").equals("true")) {
559
+                if (Config.hasOption("ui", "rolloverEnabled") 
560
+                && Config.getOption("ui", "rolloverEnabled").equals("true")) {
560 561
                     this.showRollover(node);
561 562
                 }
562 563
             }
@@ -566,29 +567,28 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
566 567
     /**
567 568
      * Invoked when the mouse cursor has been moved onto a component but no
568 569
      * buttons have been pushed.
569
-     * @param e mouse event
570
+     * @param e mouse event.
570 571
      */
571
-    public void mouseMoved(MouseEvent e) {
572
-        if (Config.hasOption("ui", "rolloverEnabled") &&
573
-                Config.getOption("ui", "rolloverEnabled").equals("true")) {
572
+    public void mouseMoved(final MouseEvent e) {
573
+        if (Config.hasOption("ui", "rolloverEnabled") 
574
+        && Config.getOption("ui", "rolloverEnabled").equals("true")) {
574 575
             TreePath selectedPath, currentSelectedPath, oldSelectedPath = null;
575 576
             DefaultMutableTreeNode node;
576
-            DefaultTreeModel treeModel = (DefaultTreeModel)tree.getModel();
577
-            int selRow = tree.getRowForLocation(e.getX(), e.getY());
578
-            if (selRow < 0) {
577
+            final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
578
+            if (tree.getRowForLocation(e.getX(), e.getY()) < 0) {
579 579
                 currentSelectedPath = oldSelectedPath;
580 580
                 oldSelectedPath = null;
581 581
                 if (currentSelectedPath != null) {
582
-                    node = (DefaultMutableTreeNode)currentSelectedPath.getLastPathComponent();
582
+                    node = (DefaultMutableTreeNode) currentSelectedPath.getLastPathComponent();
583 583
                     this.showRollover(node);
584 584
                 } else {
585 585
                     this.showRollover(null);
586 586
                 }
587 587
             } else {
588 588
                 selectedPath = tree.getPathForLocation(e.getX(), e.getY());
589
-                if ((oldSelectedPath== null) || !selectedPath.equals(oldSelectedPath)) {
589
+                if ((oldSelectedPath == null) || !selectedPath.equals(oldSelectedPath)) {
590 590
                     oldSelectedPath = selectedPath;
591
-                    node = (DefaultMutableTreeNode)oldSelectedPath.getLastPathComponent();
591
+                    node = (DefaultMutableTreeNode) oldSelectedPath.getLastPathComponent();
592 592
                     this.showRollover(node);
593 593
                 } else {
594 594
                     this.showRollover(null);
@@ -599,12 +599,11 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
599 599
     
600 600
     /**
601 601
      * Invoked when the mouse wheel is rotated.
602
-     * @param e mouse event
602
+     * @param e mouse event.
603 603
      */
604
-    public void mouseWheelMoved(MouseWheelEvent e) {
604
+    public void mouseWheelMoved(final MouseWheelEvent e) {
605 605
         //get the number of notches (used only for direction)
606
-        int notches = e.getWheelRotation();
607
-        if (notches < 0) {
606
+        if (e.getWheelRotation() < 0) {
608 607
             changeFocus(true);
609 608
         } else {
610 609
             changeFocus(false);
@@ -612,20 +611,19 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
612 611
     }
613 612
     
614 613
     /**
615
-     * Activates the node above or below the active node in the tree
614
+     * Activates the node above or below the active node in the tree.
616 615
      *
617
-     *@param direction true = up, false = down
616
+     *@param direction true = up, false = down.
618 617
      */
619
-    private void changeFocus(boolean direction) {
618
+    private void changeFocus(final boolean direction) {
620 619
         DefaultMutableTreeNode thisNode, nextNode;
621
-        TreePath path;
622 620
         
623 621
         if (getSelectedNode() == null) {
624 622
             //no selected node, get the root node
625 623
             thisNode = root;
626 624
             //are there any servers to select?
627 625
             if (thisNode.getChildCount() > 0) {
628
-                thisNode = (DefaultMutableTreeNode)thisNode.getChildAt(0);
626
+                thisNode = (DefaultMutableTreeNode) thisNode.getChildAt(0);
629 627
             } else {
630 628
                 //then wait till there are
631 629
                 return;
@@ -635,13 +633,13 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
635 633
             thisNode = getSelectedNode();
636 634
         }
637 635
         //are we going up or down?
638
-        if (direction){
636
+        if (direction) {
639 637
             //up
640 638
             if (thisNode.getUserObject() instanceof Server) {
641 639
                 if (thisNode.getParent().getIndex(thisNode) == 0) {
642 640
                     //first server - last child of parent's last child
643 641
                     nextNode = (DefaultMutableTreeNode)
644
-                    ((DefaultMutableTreeNode)((DefaultMutableTreeNode)
642
+                    ((DefaultMutableTreeNode) ((DefaultMutableTreeNode)
645 643
                     thisNode.getParent()).getLastChild()).getLastChild();
646 644
                 } else {
647 645
                     //other servers - last child of previous sibling
@@ -651,7 +649,7 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
651 649
             } else {
652 650
                 if (thisNode.getParent().getIndex(thisNode) == 0) {
653 651
                     //first frame - parent
654
-                    nextNode = (DefaultMutableTreeNode)thisNode.getParent();
652
+                    nextNode = (DefaultMutableTreeNode) thisNode.getParent();
655 653
                 } else {
656 654
                     //other frame - previous sibling
657 655
                     nextNode = thisNode.getPreviousSibling();
@@ -661,15 +659,15 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
661 659
             //down
662 660
             if (thisNode.getUserObject() instanceof Server) {
663 661
                 //all servers - get the first child
664
-                nextNode = (DefaultMutableTreeNode)thisNode.getFirstChild();
662
+                nextNode = (DefaultMutableTreeNode) thisNode.getFirstChild();
665 663
             } else {
666
-                if (thisNode.getParent().getIndex(thisNode) ==
667
-                        thisNode.getParent().getChildCount()-1) {
664
+                if (thisNode.getParent().getIndex(thisNode)
665
+                == thisNode.getParent().getChildCount() - 1) {
668 666
                     //last frame - get the parents next sibling
669
-                    nextNode = ((DefaultMutableTreeNode)thisNode.getParent()).getNextSibling();
667
+                    nextNode = ((DefaultMutableTreeNode) thisNode.getParent()).getNextSibling();
670 668
                     //parent doesnt have a next sibling, get the first child of the grandparent
671 669
                     if (nextNode == null) {
672
-                        nextNode = (DefaultMutableTreeNode)((DefaultMutableTreeNode)
670
+                        nextNode = (DefaultMutableTreeNode) ((DefaultMutableTreeNode)
673 671
                         thisNode.getParent().getParent()).getFirstChild();
674 672
                     }
675 673
                 } else {
@@ -679,21 +677,21 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
679 677
             }
680 678
         }
681 679
         //activate the nodes frame
682
-        ((FrameContainer)nextNode.getUserObject()).activateFrame();
680
+        ((FrameContainer) nextNode.getUserObject()).activateFrame();
683 681
     }
684 682
     
685 683
     /**
686 684
      * Invoked when a key has been typed.
687
-     * @param e key event
685
+     * @param e key event.
688 686
      */
689
-    public void keyTyped(KeyEvent e) {
687
+    public void keyTyped(final KeyEvent e) {
690 688
     }
691 689
     
692 690
     /**
693 691
      * Invoked when a key has been pressed.
694
-     * @param e key event
692
+     * @param e key event.
695 693
      */
696
-    public void keyPressed(KeyEvent e) {
694
+    public void keyPressed(final KeyEvent e) {
697 695
         if (e.getKeyCode() == KeyEvent.VK_DOWN) {
698 696
             changeFocus(false);
699 697
         } else if (e.getKeyCode() == KeyEvent.VK_UP) {
@@ -703,8 +701,8 @@ public class TreeFrameManager implements FrameManager, TreeModelListener,
703 701
     
704 702
     /**
705 703
      * Invoked when a key has been released.
706
-     * @param e key event
704
+     * @param e key event.
707 705
      */
708
-    public void keyReleased(KeyEvent e) {
706
+    public void keyReleased(final KeyEvent e) {
709 707
     }
710 708
 }

+ 15
- 15
src/uk/org/ownage/dmdirc/ui/framemanager/tree/TreeViewModel.java Dosyayı Görüntüle

@@ -41,9 +41,9 @@ public class TreeViewModel extends DefaultTreeModel {
41 41
     /**
42 42
      * Creates a tree in which any node can have children.
43 43
      *
44
-     * @param root a TreeNode object that is the root of the tree
44
+     * @param root a TreeNode object that is the root of the tree.
45 45
      */
46
-    public TreeViewModel(TreeNode root) {
46
+    public TreeViewModel(final TreeNode root) {
47 47
         super(root);
48 48
     }
49 49
     
@@ -51,21 +51,21 @@ public class TreeViewModel extends DefaultTreeModel {
51 51
      * Creates a tree specifying whether any node can have children,
52 52
      * or whether only certain nodes can have children.
53 53
      * @param asksAllowsChildren true = ask whether child can have chilren,
54
-     * false all nodes can have chilren
55
-     * @param root a root TreeNode
54
+     * false all nodes can have chilren.
55
+     * @param root a root TreeNode.
56 56
      */
57
-    public TreeViewModel(TreeNode root, boolean asksAllowsChildren) {
57
+    public TreeViewModel(final TreeNode root, final boolean asksAllowsChildren) {
58 58
         super(root, asksAllowsChildren);
59 59
     }
60 60
     
61 61
     /**
62
-     * Inserts a new node into the tree and fires the appropriate events
63
-     * @param newChild child to be added
64
-     * @param parent parent child is to be added too
62
+     * Inserts a new node into the tree and fires the appropriate events.
63
+     * @param newChild child to be added.
64
+     * @param parent parent child is to be added too.
65 65
      */
66
-    public void insertNodeInto(DefaultMutableTreeNode newChild, DefaultMutableTreeNode parent) {
66
+    public final void insertNodeInto(final DefaultMutableTreeNode newChild, final DefaultMutableTreeNode parent) {
67 67
         int index = 0;
68
-        index = doComparison(newChild, parent);
68
+        index = getIndex(newChild, parent);
69 69
         super.insertNodeInto(newChild, parent, index);
70 70
     }
71 71
     
@@ -74,13 +74,13 @@ public class TreeViewModel extends DefaultTreeModel {
74 74
      */
75 75
     /**
76 76
      * Compares the new child with the existing children or parent to decide
77
-     * where it needs to be inserted
77
+     * where it needs to be inserted.
78 78
      *
79
-     * @param newChild
80
-     * @param parent
81
-     * @return
79
+     * @param newChild new node to be inserted.
80
+     * @param parent node the new node will be inserted into.
81
+     * @return index where new node is to be inserted.
82 82
      */
83
-    private int doComparison(DefaultMutableTreeNode newChild, DefaultMutableTreeNode parent) {
83
+    private int getIndex(final DefaultMutableTreeNode newChild, final DefaultMutableTreeNode parent) {
84 84
         if (parent == root) {
85 85
             return root.getChildCount();
86 86
         }

+ 27
- 26
src/uk/org/ownage/dmdirc/ui/framemanager/tree/TreeViewTreeCellRenderer.java Dosyayı Görüntüle

@@ -27,19 +27,21 @@ import java.awt.Component;
27 27
 import java.awt.Dimension;
28 28
 import java.awt.Font;
29 29
 import java.net.URL;
30
+
30 31
 import javax.swing.ImageIcon;
31 32
 import javax.swing.JTree;
32 33
 import javax.swing.border.EmptyBorder;
33 34
 import javax.swing.border.LineBorder;
34 35
 import javax.swing.tree.DefaultMutableTreeNode;
35 36
 import javax.swing.tree.DefaultTreeCellRenderer;
37
+
36 38
 import uk.org.ownage.dmdirc.Config;
37 39
 import uk.org.ownage.dmdirc.FrameContainer;
38 40
 import uk.org.ownage.dmdirc.ui.MainFrame;
39 41
 import uk.org.ownage.dmdirc.ui.messages.ColourManager;
40 42
 
41 43
 /**
42
- * Displays a node in a tree according to its type
44
+ * Displays a node in a tree according to its type.
43 45
  */
44 46
 public class TreeViewTreeCellRenderer extends DefaultTreeCellRenderer {
45 47
     
@@ -51,50 +53,49 @@ public class TreeViewTreeCellRenderer extends DefaultTreeCellRenderer {
51 53
     private static final long serialVersionUID = 1;
52 54
     
53 55
     /**
54
-     * default icon
56
+     * default icon.
55 57
      */
56
-    ImageIcon defaultIcon;
58
+    private ImageIcon defaultIcon;
57 59
     
58 60
     /**
59
-     * Creates a new instance of TreeViewTreeCellRenderer
61
+     * Creates a new instance of TreeViewTreeCellRenderer.
60 62
      */
61 63
     public TreeViewTreeCellRenderer() {
62
-        ClassLoader cldr = this.getClass().getClassLoader();
63
-        URL imageURL = cldr.getResource("uk/org/ownage/dmdirc/res/icon.png");
64
+        final ClassLoader cldr = this.getClass().getClassLoader();
65
+        final URL imageURL = cldr.getResource("uk/org/ownage/dmdirc/res/icon.png");
64 66
         defaultIcon = new ImageIcon(imageURL);
65 67
     }
66 68
     
67 69
     /**
68
-     * Configures the renderer based on the passed parameters
69
-     * @param tree JTree for this renderer
70
-     * @param value node to be renderered
71
-     * @param sel whether the node is selected
72
-     * @param expanded whether the node is expanded
73
-     * @param leaf whether the node is a leaf
74
-     * @param row the node's row
75
-     * @param hasFocus whether the node has focus
76
-     * @return RendererComponent for this node
70
+     * Configures the renderer based on the passed parameters.
71
+     * @param tree JTree for this renderer.
72
+     * @param value node to be renderered.
73
+     * @param sel whether the node is selected.
74
+     * @param expanded whether the node is expanded.
75
+     * @param leaf whether the node is a leaf.
76
+     * @param row the node's row.
77
+     * @param hasFocus whether the node has focus.
78
+     * @return RendererComponent for this node.
77 79
      */
78
-    public Component getTreeCellRendererComponent(JTree tree, Object value,
79
-            boolean sel, boolean expanded, boolean leaf, int row,
80
-            boolean hasFocus) {
80
+    public final Component getTreeCellRendererComponent(final JTree tree, 
81
+            final Object value, final boolean sel, final boolean expanded, 
82
+            final boolean leaf, final int row, final boolean hasFocus) {
81 83
         
82
-        Component c = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
84
+        final Component c = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
83 85
                 row, hasFocus);
84 86
         
85
-        DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
87
+        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
86 88
         
87 89
         TreeFrameManager manager = null;
88 90
         
89 91
         if (MainFrame.hasMainFrame()) {
90
-            manager = (TreeFrameManager)MainFrame.getMainFrame().getFrameManager();
92
+            manager = (TreeFrameManager) MainFrame.getMainFrame().getFrameManager();
91 93
         }
92 94
         
93 95
         setBackground(null);
94 96
         
95 97
         if (manager != null) {
96
-            DefaultMutableTreeNode rolloverNode = manager.getRollover();
97
-            if (rolloverNode == value) {
98
+            if (manager.getRollover() == value) {
98 99
                 if (Config.hasOption("ui", "rolloverColour")) {
99 100
                     setBackground(ColourManager.getColour(
100 101
                             Config.getOption("ui", "rolloverColour")));
@@ -104,15 +105,15 @@ public class TreeViewTreeCellRenderer extends DefaultTreeCellRenderer {
104 105
             }
105 106
         }
106 107
         setForeground(tree.getForeground());
107
-        setPreferredSize(new Dimension(110, getFont().getSize()+5));
108
+        setPreferredSize(new Dimension(110, getFont().getSize() + 5));
108 109
         
109 110
         setOpaque(true);
110 111
         if (node.getUserObject() instanceof FrameContainer && manager != null) {
111
-            Color colour = manager.getNodeColour((FrameContainer)node.getUserObject());
112
+            final Color colour = manager.getNodeColour((FrameContainer) node.getUserObject());
112 113
             if (colour != null) {
113 114
                 setForeground(colour);
114 115
             }
115
-            setIcon(((FrameContainer)node.getUserObject()).getIcon());
116
+            setIcon(((FrameContainer) node.getUserObject()).getIcon());
116 117
         } else {
117 118
             
118 119
             setIcon(defaultIcon);

Loading…
İptal
Kaydet