|
@@ -25,11 +25,17 @@ package com.dmdirc.ui.core;
|
25
|
25
|
import com.dmdirc.DMDircMBassador;
|
26
|
26
|
import com.dmdirc.FrameContainer;
|
27
|
27
|
import com.dmdirc.events.DisplayableEvent;
|
|
28
|
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
28
|
29
|
import com.dmdirc.ui.messages.ColourManagerFactory;
|
29
|
30
|
import com.dmdirc.ui.messages.EventFormatter;
|
|
31
|
+import com.dmdirc.ui.messages.Formatter;
|
30
|
32
|
import com.dmdirc.ui.messages.IRCDocument;
|
31
|
33
|
import com.dmdirc.ui.messages.Styliser;
|
32
|
34
|
|
|
35
|
+import java.util.Date;
|
|
36
|
+
|
|
37
|
+import net.engio.mbassy.listener.Handler;
|
|
38
|
+
|
33
|
39
|
/**
|
34
|
40
|
* Models the history of a window in the client.
|
35
|
41
|
*/
|
|
@@ -39,6 +45,7 @@ public class BackBuffer {
|
39
|
45
|
private final Styliser styliser;
|
40
|
46
|
private final DMDircMBassador eventBus;
|
41
|
47
|
private final EventFormatter formatter;
|
|
48
|
+ private final AggregateConfigProvider configProvider;
|
42
|
49
|
|
43
|
50
|
public BackBuffer(
|
44
|
51
|
final FrameContainer owner,
|
|
@@ -52,6 +59,7 @@ public class BackBuffer {
|
52
|
59
|
this.document = new IRCDocument(owner.getConfigManager(), styliser, owner.getEventBus());
|
53
|
60
|
this.eventBus = owner.getEventBus();
|
54
|
61
|
this.formatter = formatter;
|
|
62
|
+ this.configProvider = owner.getConfigManager();
|
55
|
63
|
}
|
56
|
64
|
|
57
|
65
|
/**
|
|
@@ -73,8 +81,16 @@ public class BackBuffer {
|
73
|
81
|
*
|
74
|
82
|
* @param event The event to be displayed.
|
75
|
83
|
*/
|
|
84
|
+ @Handler
|
76
|
85
|
public void handleDisplayableEvent(final DisplayableEvent event) {
|
|
86
|
+ formatter.format(event)
|
|
87
|
+ .map(l -> new String[]{getTimestamp(event), l})
|
|
88
|
+ .ifPresent(document::addText);
|
|
89
|
+ }
|
77
|
90
|
|
|
91
|
+ private String getTimestamp(final DisplayableEvent event) {
|
|
92
|
+ return Formatter.formatMessage(configProvider, "timestamp",
|
|
93
|
+ new Date(event.getTimestamp()));
|
78
|
94
|
}
|
79
|
95
|
|
80
|
96
|
public IRCDocument getDocument() {
|