瀏覽代碼

Fixes broken trunk.

Add no warning dialog to taskbar.

Fixes issue CLIENT-91

Change-Id: Ib443990256d0e157043ed0361fa6123ad7dea7c5
Reviewed-on: http://gerrit.dmdirc.com/1562
Automatic-Compile: Chris Smith <chris@dmdirc.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5b1
Greg Holmes 13 年之前
父節點
當前提交
ceeae1c04c

+ 25
- 14
src/com/dmdirc/FrameContainer.java 查看文件

@@ -110,13 +110,14 @@ public abstract class FrameContainer<T extends Window> {
110 110
      * @since 0.6.4
111 111
      */
112 112
     protected FrameContainer(final String icon, final String name,
113
-            final String title, final Class<T> windowClass, final ConfigManager config) {
113
+            final String title, final Class<T> windowClass,
114
+            final ConfigManager config) {
114 115
         this.config = config;
115 116
         this.name = name;
116 117
         this.title = title;
117 118
         this.windowClass = windowClass;
118 119
         this.styliser = new Styliser(this);
119
-        this.document = new IRCDocument(this);
120
+        this.document = new IRCDocument(getConfigManager(), getStyliser());
120 121
 
121 122
         // Can't assign directly to transcoder as it's final, and Java doesn't
122 123
         // like the two paths in the try/catch.
@@ -267,7 +268,8 @@ public abstract class FrameContainer<T extends Window> {
267 268
     protected void setName(final String name) {
268 269
         this.name = name;
269 270
 
270
-        for (FrameInfoListener listener : listeners.get(FrameInfoListener.class)) {
271
+        for (FrameInfoListener listener : listeners.get(
272
+                FrameInfoListener.class)) {
271 273
             listener.nameChanged(this, name);
272 274
         }
273 275
     }
@@ -291,7 +293,8 @@ public abstract class FrameContainer<T extends Window> {
291 293
     public void setTitle(final String title) {
292 294
         this.title = title;
293 295
 
294
-        for (FrameInfoListener listener : listeners.get(FrameInfoListener.class)) {
296
+        for (FrameInfoListener listener : listeners.get(
297
+                FrameInfoListener.class)) {
295 298
             listener.titleChanged(this, title);
296 299
         }
297 300
     }
@@ -330,7 +333,8 @@ public abstract class FrameContainer<T extends Window> {
330 333
      * Called when this container's icon is updated.
331 334
      */
332 335
     private void iconUpdated() {
333
-        for (FrameInfoListener listener : listeners.get(FrameInfoListener.class)) {
336
+        for (FrameInfoListener listener : listeners.get(
337
+                FrameInfoListener.class)) {
334 338
             listener.iconChanged(this, icon);
335 339
         }
336 340
     }
@@ -378,7 +382,8 @@ public abstract class FrameContainer<T extends Window> {
378 382
         // TODO: This should default ot something colour independent
379 383
         notification = Color.BLACK;
380 384
 
381
-        for (NotificationListener listener : listeners.get(NotificationListener.class)) {
385
+        for (NotificationListener listener : listeners.get(
386
+                NotificationListener.class)) {
382 387
             listener.notificationCleared(this);
383 388
         }
384 389
     }
@@ -395,7 +400,8 @@ public abstract class FrameContainer<T extends Window> {
395 400
                 && !colour.equals(notification)) {
396 401
             notification = colour;
397 402
 
398
-            for (NotificationListener listener : listeners.get(NotificationListener.class)) {
403
+            for (NotificationListener listener : listeners.get(
404
+                    NotificationListener.class)) {
399 405
                 listener.notificationSet(this, colour);
400 406
             }
401 407
         }
@@ -473,7 +479,8 @@ public abstract class FrameContainer<T extends Window> {
473 479
      * Invoked when our window is activated.
474 480
      */
475 481
     public void windowActivated() {
476
-        for (SelectionListener listener : listeners.get(SelectionListener.class)) {
482
+        for (SelectionListener listener : listeners.get(
483
+                SelectionListener.class)) {
477 484
             listener.selectionChanged(this);
478 485
         }
479 486
 
@@ -501,9 +508,11 @@ public abstract class FrameContainer<T extends Window> {
501 508
      * @param args The message's arguments
502 509
      * @since 0.6.4
503 510
      */
504
-    public void addLine(final String type, final Date timestamp, final Object ... args) {
511
+    public void addLine(final String type, final Date timestamp,
512
+            final Object ... args) {
505 513
         if (type != null && !type.isEmpty()) {
506
-            addLine(Formatter.formatMessage(getConfigManager(), type, args), timestamp);
514
+            addLine(Formatter.formatMessage(getConfigManager(), type, args),
515
+                    timestamp);
507 516
         }
508 517
     }
509 518
 
@@ -527,7 +536,8 @@ public abstract class FrameContainer<T extends Window> {
527 536
      * @param args The message's arguments
528 537
      * @since 0.6.4
529 538
      */
530
-    public void addLine(final StringBuffer type, final Date timestamp, final Object ... args) {
539
+    public void addLine(final StringBuffer type, final Date timestamp,
540
+            final Object ... args) {
531 541
         if (type != null) {
532 542
             addLine(type.toString(), timestamp, args);
533 543
         }
@@ -569,7 +579,8 @@ public abstract class FrameContainer<T extends Window> {
569 579
         for (final String myLine : encodedLine.split("\n")) {
570 580
             if (timestamp != null) {
571 581
                 lines.add(new String[]{
572
-                    Formatter.formatMessage(getConfigManager(), "timestamp", timestamp),
582
+                    Formatter.formatMessage(getConfigManager(), "timestamp",
583
+                            timestamp),
573 584
                     myLine,
574 585
                 });
575 586
             } else {
@@ -645,7 +656,7 @@ public abstract class FrameContainer<T extends Window> {
645 656
      * @param window The window to be added
646 657
      * @since 0.6.4
647 658
      */
648
-    public void addWindow(T window) {
659
+    public void addWindow(final T window) {
649 660
         windows.add(window);
650 661
     }
651 662
 
@@ -655,7 +666,7 @@ public abstract class FrameContainer<T extends Window> {
655 666
      * @param window The window to be removed
656 667
      * @since 0.6.4
657 668
      */
658
-    public void removeWindow(T window) {
669
+    public void removeWindow(final T window) {
659 670
         windows.remove(window);
660 671
     }
661 672
 

+ 0
- 1
src/com/dmdirc/commandparser/commands/IntelligentCommand.java 查看文件

@@ -90,7 +90,6 @@ public interface IntelligentCommand {
90 90
         public String getPartial() {
91 91
             return partial;
92 92
         }
93
-
94 93
     }
95 94
 
96 95
     /**

+ 15
- 10
src/com/dmdirc/ui/WarningDialog.java 查看文件

@@ -1,17 +1,17 @@
1 1
 /*
2
- * 
2
+ *
3 3
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
4
+ *
5 5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
6 6
  * of this software and associated documentation files (the "Software"), to deal
7 7
  * in the Software without restriction, including without limitation the rights
8 8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 9
  * copies of the Software, and to permit persons to whom the Software is
10 10
  * furnished to do so, subject to the following conditions:
11
- * 
11
+ *
12 12
  * The above copyright notice and this permission notice shall be included in
13 13
  * all copies or substantial portions of the Software.
14
- * 
14
+ *
15 15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,16 +26,17 @@ package com.dmdirc.ui;
26 26
 import java.awt.BorderLayout;
27 27
 import java.awt.Font;
28 28
 import java.awt.Insets;
29
+import java.awt.Toolkit;
30
+import java.awt.Window;
29 31
 import java.awt.event.ActionEvent;
30 32
 import java.awt.event.ActionListener;
31 33
 import java.awt.event.WindowAdapter;
32 34
 import java.awt.event.WindowEvent;
33 35
 import java.util.concurrent.Semaphore;
34
-import javax.swing.BorderFactory;
35 36
 
37
+import javax.swing.BorderFactory;
36 38
 import javax.swing.JButton;
37 39
 import javax.swing.JDialog;
38
-import javax.swing.JFrame;
39 40
 import javax.swing.JPanel;
40 41
 import javax.swing.JTextPane;
41 42
 import javax.swing.SwingUtilities;
@@ -80,22 +81,26 @@ public class WarningDialog extends JDialog {
80 81
             + "jar, but this did not fix the problem. DMDirc is unable to "
81 82
             + "continue and will now exit.";
82 83
 
83
-    /** Create a new NoUIDialog */
84
+    /** Create a new NoUIDialog. */
84 85
     public WarningDialog() {
85 86
         this(NO_UIS_TITLE, NO_UIS_BODY);
86 87
     }
87 88
 
88 89
     /**
89
-     * Create a new NoUIDialog
90
+     * Create a new NoUIDialog.
90 91
      *
91 92
      * @param title Title of dialog
92 93
      * @param body Body of dialog
93 94
      */
94 95
     public WarningDialog(final String title, final String body) {
95
-        super((JFrame) null, "DMDirc: "+title);
96
+        super((Window) null);
97
+        setTitle("DMDirc: " + title);
98
+        setIconImage(Toolkit.getDefaultToolkit().getImage(
99
+                Thread.currentThread().getContextClassLoader()
100
+                .getResource("com/dmdirc/res/logo.png")));
96 101
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
97 102
         setResizable(false);
98
-        
103
+
99 104
         final JPanel panel = new JPanel(new BorderLayout(5, 5));
100 105
 
101 106
         final JButton button = new JButton("OK");

+ 41
- 33
src/com/dmdirc/ui/messages/IRCDocument.java 查看文件

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
-import com.dmdirc.FrameContainer;
25
+import com.dmdirc.config.ConfigManager;
26 26
 import com.dmdirc.interfaces.ConfigChangeListener;
27 27
 import com.dmdirc.util.ListenerList;
28 28
 import com.dmdirc.util.RollingList;
@@ -52,11 +52,13 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
52 52
     /** Listener list. */
53 53
     private final ListenerList listeners;
54 54
     /** Cached lines. */
55
-    private transient RollingList<Line> cachedLines;
55
+    private final RollingList<Line> cachedLines;
56 56
     /** Cached attributed strings. */
57
-    private transient RollingList<AttributedString> cachedStrings;
58
-    /** Container that owns this document. */
59
-    private final FrameContainer<?> container;
57
+    private final RollingList<AttributedString> cachedStrings;
58
+    /** Config Manager for getting settings. */
59
+    private final ConfigManager configManager;
60
+    /** This document's styliser. */
61
+    private final Styliser styliser;
60 62
     /** Font size. */
61 63
     private int fontSize;
62 64
     /** Font name. */
@@ -67,26 +69,25 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
67 69
     /**
68 70
      * Creates a new instance of IRCDocument.
69 71
      *
70
-     * @param container The container that owns this document
72
+     * @param configManager Config Manager for required settings.
73
+     * @param styliser Styliser to style text
71 74
      * @since 0.6.3
72 75
      */
73
-    public IRCDocument(final FrameContainer<?> container) {
74
-        this.container = container;
76
+    public IRCDocument(final ConfigManager configManager,
77
+            final Styliser styliser) {
78
+        this.configManager = configManager;
79
+        this.styliser = styliser;
75 80
 
76 81
         lines = new ArrayList<Line>();
77 82
         listeners = new ListenerList();
78 83
 
79 84
         cachedLines = new RollingList<Line>(50);
80 85
         cachedStrings = new RollingList<AttributedString>(50);
81
-        frameBufferSize = container.getConfigManager().getOptionInt("ui",
82
-                "frameBufferSize");
86
+        frameBufferSize = configManager.getOptionInt("ui", "frameBufferSize");
83 87
 
84
-        container.getConfigManager().addChangeListener("ui", "textPaneFontSize",
85
-                this);
86
-        container.getConfigManager().addChangeListener("ui", "textPaneFontName",
87
-                this);
88
-        container.getConfigManager().addChangeListener("ui", "frameBufferSize",
89
-                this);
88
+        configManager.addChangeListener("ui", "textPaneFontSize", this);
89
+        configManager.addChangeListener("ui", "textPaneFontName", this);
90
+        configManager.addChangeListener("ui", "frameBufferSize", this);
90 91
 
91 92
         setCachedSettings();
92 93
     }
@@ -123,7 +124,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
123 124
     public void addText(final String[] text) {
124 125
         final int index;
125 126
         synchronized (lines) {
126
-            final Line line = new Line(container.getStyliser(), text, fontSize, fontName);
127
+            final Line line = new Line(styliser, text, fontSize, fontName);
127 128
             lines.add(line);
128 129
             index = lines.indexOf(line);
129 130
         }
@@ -139,7 +140,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
139 140
     public void addText(final String[] text, final int lineHeight) {
140 141
         final int index;
141 142
         synchronized (lines) {
142
-            final Line line = new Line(container.getStyliser(), text, lineHeight, fontName);
143
+            final Line line = new Line(styliser, text, lineHeight, fontName);
143 144
             lines.add(line);
144 145
             index = lines.indexOf(line);
145 146
         }
@@ -156,7 +157,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
156 157
         synchronized (lines) {
157 158
             start = lines.size();
158 159
             for (String[] string : text) {
159
-                lines.add(new Line(container.getStyliser(), string, fontSize, fontName));
160
+                lines.add(new Line(styliser, string, fontSize, fontName));
160 161
             }
161 162
         }
162 163
         fireLinesAdded(start, text.size());
@@ -176,7 +177,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
176 177
             for (int i = 0; i < text.size(); i++) {
177 178
                 final String[] string = text.get(i);
178 179
                 final int lineHeight = lineHeights.get(i);
179
-                lines.add(new Line(container.getStyliser(), string, lineHeight, fontName));
180
+                lines.add(new Line(styliser, string, lineHeight, fontName));
180 181
             }
181 182
         }
182 183
         fireLinesAdded(start, text.size());
@@ -238,7 +239,8 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
238 239
      * @param index Index of the added line
239 240
      */
240 241
     protected void fireLineAdded(final int index) {
241
-        for (IRCDocumentListener listener : listeners.get(IRCDocumentListener.class)) {
242
+        for (IRCDocumentListener listener
243
+                : listeners.get(IRCDocumentListener.class)) {
242 244
             listener.lineAdded(index, lines.size());
243 245
         }
244 246
         trim(frameBufferSize);
@@ -251,7 +253,8 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
251 253
      * @param size Number of lines added
252 254
      */
253 255
     protected void fireLinesAdded(final int index, final int size) {
254
-        for (IRCDocumentListener listener : listeners.get(IRCDocumentListener.class)) {
256
+        for (IRCDocumentListener listener
257
+                : listeners.get(IRCDocumentListener.class)) {
255 258
             listener.linesAdded(index, size, lines.size());
256 259
         }
257 260
         trim(frameBufferSize);
@@ -264,7 +267,8 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
264 267
      * @param trimedLines Number of trimmed lines
265 268
      */
266 269
     protected void fireTrimmed(final int newSize, final int trimedLines) {
267
-        for (IRCDocumentListener listener : listeners.get(IRCDocumentListener.class)) {
270
+        for (IRCDocumentListener listener
271
+                : listeners.get(IRCDocumentListener.class)) {
268 272
             listener.trimmed(newSize, trimedLines);
269 273
         }
270 274
     }
@@ -273,7 +277,8 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
273 277
      * fires the cleared method on all listeners.
274 278
      */
275 279
     protected void fireCleared() {
276
-        for (IRCDocumentListener listener : listeners.get(IRCDocumentListener.class)) {
280
+        for (IRCDocumentListener listener
281
+                : listeners.get(IRCDocumentListener.class)) {
277 282
             listener.cleared();
278 283
         }
279 284
     }
@@ -282,7 +287,8 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
282 287
      * fires the need repaint method on all listeners.
283 288
      */
284 289
     protected void fireRepaintNeeded() {
285
-        for (IRCDocumentListener listener : listeners.get(IRCDocumentListener.class)) {
290
+        for (IRCDocumentListener listener
291
+                : listeners.get(IRCDocumentListener.class)) {
286 292
             listener.repaintNeeded();
287 293
         }
288 294
     }
@@ -326,7 +332,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
326 332
     }
327 333
 
328 334
     /**
329
-     * Returns the line height of the specified line
335
+     * Returns the line height of the specified line.
330 336
      *
331 337
      * @param line Line
332 338
      *
@@ -337,7 +343,7 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
337 343
     }
338 344
 
339 345
     /**
340
-     * Returns the line height of the specified line
346
+     * Returns the line height of the specified.
341 347
      *
342 348
      * @param line Line
343 349
      *
@@ -347,20 +353,22 @@ public class IRCDocument implements Serializable, ConfigChangeListener {
347 353
         return getLineHeight(getLine(line));
348 354
     }
349 355
 
356
+    /**
357
+     * Sets all the cached settings in this document.
358
+     */
350 359
     private void setCachedSettings() {
351 360
         final Font defaultFont = UIManager.getFont("TextPane.font");
352
-        if (container.getConfigManager().hasOptionString("ui", "textPaneFontName")) {
353
-            fontName = container.getConfigManager().getOption("ui", "textPaneFontName");
361
+        if (configManager.hasOptionString("ui", "textPaneFontName")) {
362
+            fontName = configManager.getOption("ui", "textPaneFontName");
354 363
         } else {
355 364
             fontName = defaultFont.getName();
356 365
         }
357
-        if (container.getConfigManager().hasOptionString("ui", "textPaneFontSize")) {
358
-            fontSize = container.getConfigManager().getOptionInt("ui", "textPaneFontSize");
366
+        if (configManager.hasOptionString("ui", "textPaneFontSize")) {
367
+            fontSize = configManager.getOptionInt("ui", "textPaneFontSize");
359 368
         } else {
360 369
             fontSize = defaultFont.getSize();
361 370
         }
362
-        frameBufferSize = container.getConfigManager().getOptionInt("ui",
363
-                "frameBufferSize");
371
+        frameBufferSize = configManager.getOptionInt("ui", "frameBufferSize");
364 372
         trim(frameBufferSize);
365 373
     }
366 374
 

Loading…
取消
儲存