Parcourir la source

Remove some deprecated method usages.

Conflicts:
        src/com/dmdirc/addons/ui_swing/components/statusbar/SwingStatusBar.java

Change-Id: I1f3a097c2c0077ad55092e810bf23eae2849569e
Reviewed-on: http://gerrit.dmdirc.com/3262
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
Reviewed-on: http://gerrit.dmdirc.com/3340
Reviewed-by: Greg Holmes <greg@dmdirc.com>
changes/40/3340/3
Greg Holmes il y a 10 ans
Parent
révision
f2d1d7261f

+ 19
- 14
src/com/dmdirc/addons/ui_swing/components/statusbar/MessageLabel.java Voir le fichier

@@ -22,12 +22,14 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingController;
25
+import com.dmdirc.ClientModule.GlobalConfig;
26
+import com.dmdirc.addons.ui_swing.MainFrame;
26 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
28
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 29
 import com.dmdirc.interfaces.ui.StatusBarComponent;
30
+import com.dmdirc.ui.IconManager;
28 31
 import com.dmdirc.ui.StatusMessage;
29 32
 
30
-import java.awt.Window;
31 33
 import java.awt.event.MouseEvent;
32 34
 import java.awt.event.MouseListener;
33 35
 import java.util.Date;
@@ -36,6 +38,7 @@ import java.util.Timer;
36 38
 import java.util.TimerTask;
37 39
 import java.util.concurrent.ConcurrentLinkedQueue;
38 40
 
41
+import javax.inject.Inject;
39 42
 import javax.swing.JLabel;
40 43
 import javax.swing.JPanel;
41 44
 import javax.swing.SwingUtilities;
@@ -65,25 +68,28 @@ public class MessageLabel extends JPanel implements StatusBarComponent,
65 68
     private StatusMessage currentMessage;
66 69
     /** Timer to clear the message. */
67 70
     private transient TimerTask messageTimer;
68
-    /** Swing controller. */
69
-    private final SwingController controller;
71
+    /** Icon manager to retrieve icons from. */
72
+    private final IconManager iconManager;
70 73
 
71 74
     /**
72 75
      * Instantiates a new message label.
73 76
      *
74
-     * @param controller   Swing controller
77
+     * @param iconManager  Icon manager to retrieve icons from
78
+     * @param config       Config to read settings from
75 79
      * @param parentWindow Parent window
76 80
      */
77
-    public MessageLabel(final SwingController controller,
78
-            final Window parentWindow) {
81
+    @Inject
82
+    public MessageLabel(
83
+            @GlobalConfig final AggregateConfigProvider config,
84
+            @GlobalConfig final IconManager iconManager,
85
+            final MainFrame parentWindow) {
79 86
         super(new MigLayout("fill, ins 0, gap 0  0"));
80
-        this.controller = controller;
87
+        this.iconManager = iconManager;
81 88
         queue = new ConcurrentLinkedQueue<>();
82
-        defaultMessage = new StatusMessage(null, "Ready.", null, -1,
83
-                controller.getGlobalConfig());
89
+        defaultMessage = new StatusMessage(null, "Ready.", null, -1, config);
84 90
         currentMessage = defaultMessage;
85 91
         label = new JLabel();
86
-        historyLabel = new MessagePopup(this, parentWindow, controller);
92
+        historyLabel = new MessagePopup(this, parentWindow, iconManager);
87 93
         label.setText("Ready.");
88 94
         label.setBorder(new SidelessEtchedBorder(
89 95
                 SidelessEtchedBorder.Side.RIGHT));
@@ -120,8 +126,7 @@ public class MessageLabel extends JPanel implements StatusBarComponent,
120 126
                 if (currentMessage.getIconType() == null) {
121 127
                     label.setIcon(null);
122 128
                 } else {
123
-                    label.setIcon(controller.getIconManager().getIcon(
124
-                            currentMessage.getIconType()));
129
+                    label.setIcon(iconManager.getIcon(currentMessage.getIconType()));
125 130
                 }
126 131
                 label.setText(UIUtilities.clipStringifNeeded(MessageLabel.this,
127 132
                         currentMessage.getMessage(), getWidth()));
@@ -135,7 +140,7 @@ public class MessageLabel extends JPanel implements StatusBarComponent,
135 140
                     messageTimer = new MessageTimerTask(MessageLabel.this);
136 141
                     new Timer("SwingStatusBar messageTimer").schedule(
137 142
                             messageTimer, new Date(System.currentTimeMillis()
138
-                            + 250 + currentMessage.getTimeout() * 1000L));
143
+                                    + 250 + currentMessage.getTimeout() * 1000L));
139 144
                 }
140 145
             }
141 146
         });

+ 8
- 9
src/com/dmdirc/addons/ui_swing/components/statusbar/MessagePopup.java Voir le fichier

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.statusbar;
24 24
 
25
-import com.dmdirc.addons.ui_swing.SwingController;
25
+import com.dmdirc.ui.IconManager;
26 26
 import com.dmdirc.ui.StatusMessage;
27 27
 import com.dmdirc.util.collections.RollingList;
28 28
 
@@ -55,24 +55,24 @@ class MessagePopup extends StatusbarTogglePanel<JLabel> {
55 55
     private final RollingList<StatusMessage> messages;
56 56
     /** Parent panel. */
57 57
     private final JPanel parent;
58
-    /** Swing controller. */
59
-    private final SwingController controller;
58
+    /** Icon manager to retrieve icons from. */
59
+    private final IconManager iconManager;
60 60
 
61 61
     /**
62 62
      * Creates a new message history popup.
63 63
      *
64 64
      * @param parent       Parent to size against
65 65
      * @param parentWindow Parent window
66
-     * @param controller   Swing controller
66
+     * @param iconManager  Icon manager to retrieve icons from
67 67
      */
68 68
     public MessagePopup(final JPanel parent, final Window parentWindow,
69
-            final SwingController controller) {
69
+            final IconManager iconManager) {
70 70
         super(new JLabel("^"),
71 71
                 new SidelessEtchedBorder(SidelessEtchedBorder.Side.LEFT),
72 72
                 new SidelessEtchedBorder(SidelessEtchedBorder.Side.TOP));
73 73
         this.parentWindow = parentWindow;
74 74
         this.parent = parent;
75
-        this.controller = controller;
75
+        this.iconManager = iconManager;
76 76
         messages = new RollingList<>(5);
77 77
     }
78 78
 
@@ -167,9 +167,8 @@ class MessagePopup extends StatusbarTogglePanel<JLabel> {
167 167
 
168 168
             for (final StatusMessage message : messages.getList()) {
169 169
                 panel.add(new JLabel(message.getMessage(), message.getIconType()
170
-                        == null ? null : controller.getIconManager()
171
-                        .getIcon(message.getIconType()), SwingConstants.LEFT),
172
-                        "grow, push, wrap");
170
+                        == null ? null : iconManager.getIcon(message.getIconType()),
171
+                        SwingConstants.LEFT), "grow, push, wrap");
173 172
             }
174 173
         }
175 174
 

+ 4
- 4
src/com/dmdirc/addons/ui_swing/components/statusbar/SwingStatusBar.java Voir le fichier

@@ -72,22 +72,22 @@ public class SwingStatusBar extends JPanel implements StatusBar {
72 72
      * @param mainFrame    Main frame
73 73
      * @param inviteLabel  The invite label to add to the status bar.
74 74
      * @param updaterLabel The updater label to add to the status bar.
75
+     * @param messageLabel The message label to add to the status bar.
75 76
      */
76 77
     @Inject
77 78
     public SwingStatusBar(
78 79
             final SwingController controller,
79 80
             final MainFrame mainFrame,
80 81
             final InviteLabel inviteLabel,
81
-            final UpdaterLabel updaterLabel) {
82
-        super();
83
-
82
+            final UpdaterLabel updaterLabel,
83
+            final MessageLabel messageLabel) {
84 84
         height = getFontMetrics(UIManager.getFont("Table.font")).getHeight()
85 85
                 + (int) PlatformDefaults.getUnitValueX("related").getValue()
86 86
                 + (int) PlatformDefaults.getUnitValueX("related").getValue();
87 87
         componentConstraints = "sgy components, hmax " + height + ", hmin " + height
88 88
                 + ", wmin 20, shrink 0";
89 89
 
90
-        messageLabel = new MessageLabel(controller, mainFrame);
90
+        this.messageLabel = messageLabel;
91 91
         errorPanel = new ErrorPanel(controller, mainFrame, this);
92 92
         this.updateLabel = updaterLabel;
93 93
         this.inviteLabel = inviteLabel;

Chargement…
Annuler
Enregistrer