|
@@ -29,10 +29,11 @@ import com.dmdirc.addons.dcc.io.DCCTransfer;
|
29
|
29
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
30
|
30
|
import com.dmdirc.addons.ui_swing.components.frames.SwingFrameComponent;
|
31
|
31
|
import com.dmdirc.events.UserErrorEvent;
|
|
32
|
+import com.dmdirc.interfaces.Connection;
|
32
|
33
|
import com.dmdirc.interfaces.WindowModel;
|
33
|
34
|
import com.dmdirc.logger.ErrorLevel;
|
|
35
|
+import com.dmdirc.parser.events.SocketCloseEvent;
|
34
|
36
|
import com.dmdirc.parser.interfaces.Parser;
|
35
|
|
-import com.dmdirc.parser.interfaces.callbacks.SocketCloseListener;
|
36
|
37
|
import com.dmdirc.util.DateUtils;
|
37
|
38
|
|
38
|
39
|
import java.awt.Desktop;
|
|
@@ -40,7 +41,6 @@ import java.awt.event.ActionEvent;
|
40
|
41
|
import java.awt.event.ActionListener;
|
41
|
42
|
import java.io.File;
|
42
|
43
|
import java.io.IOException;
|
43
|
|
-import java.util.Date;
|
44
|
44
|
|
45
|
45
|
import javax.swing.JButton;
|
46
|
46
|
import javax.swing.JLabel;
|
|
@@ -49,13 +49,15 @@ import javax.swing.JProgressBar;
|
49
|
49
|
|
50
|
50
|
import net.miginfocom.swing.MigLayout;
|
51
|
51
|
|
|
52
|
+import net.engio.mbassy.listener.Handler;
|
|
53
|
+
|
52
|
54
|
/**
|
53
|
55
|
* A panel for displaying the progress of DCC transfers.
|
54
|
56
|
*
|
55
|
57
|
* @since 0.6.6
|
56
|
58
|
*/
|
57
|
59
|
public class TransferPanel extends JPanel implements ActionListener,
|
58
|
|
- SocketCloseListener, DCCTransferHandler, SwingFrameComponent {
|
|
60
|
+ DCCTransferHandler, SwingFrameComponent {
|
59
|
61
|
|
60
|
62
|
/** A version number for this class. */
|
61
|
63
|
private static final long serialVersionUID = 1L;
|
|
@@ -92,7 +94,10 @@ public class TransferPanel extends JPanel implements ActionListener,
|
92
|
94
|
dcc = transferContainer.getDCC();
|
93
|
95
|
|
94
|
96
|
dcc.addHandler(this);
|
95
|
|
- transferContainer.addSocketCloseCallback(this);
|
|
97
|
+ transferContainer.getConnection()
|
|
98
|
+ .flatMap(Connection::getParser)
|
|
99
|
+ .map(Parser::getCallbackManager)
|
|
100
|
+ .ifPresent(cm -> cm.subscribe(this));
|
96
|
101
|
|
97
|
102
|
setLayout(new MigLayout("hidemode 0"));
|
98
|
103
|
|
|
@@ -164,8 +169,8 @@ public class TransferPanel extends JPanel implements ActionListener,
|
164
|
169
|
}
|
165
|
170
|
}
|
166
|
171
|
|
167
|
|
- @Override
|
168
|
|
- public void onSocketClosed(final Parser parser, final Date date) {
|
|
172
|
+ @Handler
|
|
173
|
+ public void onSocketClosed(final SocketCloseEvent event) {
|
169
|
174
|
if ("Resend".equals(button.getText())) {
|
170
|
175
|
button.setText("Close Window");
|
171
|
176
|
}
|