Quellcode durchsuchen

Add back buffer entries based on events.

Any formattable DisplayableEvent received on a frame container's
event bus is now automatically added to the IRC Document.

Current problems:
  1) Every time this happens the old path still executes, so you
     end up with two lines
  2) Every event on a channel's event bus gets passed to the
     server's, so the lines appear there as well.
pull/205/head
Chris Smith vor 9 Jahren
Ursprung
Commit
e69d7aee10

+ 7
- 0
src/com/dmdirc/events/DisplayableEvent.java Datei anzeigen

61
      */
61
      */
62
     <T> Optional<T> getDisplayProperty(DisplayProperty<T> property);
62
     <T> Optional<T> getDisplayProperty(DisplayProperty<T> property);
63
 
63
 
64
+    /**
65
+     * Gets the timestamp at which the event occurred.
66
+     *
67
+     * @return The timestamp the event occurred at.
68
+     */
69
+    long getTimestamp();
70
+
64
 }
71
 }

+ 16
- 0
src/com/dmdirc/ui/core/BackBuffer.java Datei anzeigen

25
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
27
 import com.dmdirc.events.DisplayableEvent;
27
 import com.dmdirc.events.DisplayableEvent;
28
+import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.ui.messages.ColourManagerFactory;
29
 import com.dmdirc.ui.messages.ColourManagerFactory;
29
 import com.dmdirc.ui.messages.EventFormatter;
30
 import com.dmdirc.ui.messages.EventFormatter;
31
+import com.dmdirc.ui.messages.Formatter;
30
 import com.dmdirc.ui.messages.IRCDocument;
32
 import com.dmdirc.ui.messages.IRCDocument;
31
 import com.dmdirc.ui.messages.Styliser;
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
  * Models the history of a window in the client.
40
  * Models the history of a window in the client.
35
  */
41
  */
39
     private final Styliser styliser;
45
     private final Styliser styliser;
40
     private final DMDircMBassador eventBus;
46
     private final DMDircMBassador eventBus;
41
     private final EventFormatter formatter;
47
     private final EventFormatter formatter;
48
+    private final AggregateConfigProvider configProvider;
42
 
49
 
43
     public BackBuffer(
50
     public BackBuffer(
44
             final FrameContainer owner,
51
             final FrameContainer owner,
52
         this.document = new IRCDocument(owner.getConfigManager(), styliser, owner.getEventBus());
59
         this.document = new IRCDocument(owner.getConfigManager(), styliser, owner.getEventBus());
53
         this.eventBus = owner.getEventBus();
60
         this.eventBus = owner.getEventBus();
54
         this.formatter = formatter;
61
         this.formatter = formatter;
62
+        this.configProvider = owner.getConfigManager();
55
     }
63
     }
56
 
64
 
57
     /**
65
     /**
73
      *
81
      *
74
      * @param event The event to be displayed.
82
      * @param event The event to be displayed.
75
      */
83
      */
84
+    @Handler
76
     public void handleDisplayableEvent(final DisplayableEvent event) {
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
     public IRCDocument getDocument() {
96
     public IRCDocument getDocument() {

+ 0
- 1
src/com/dmdirc/ui/messages/IRCDocument.java Datei anzeigen

363
         }
363
         }
364
         fireRepaintNeeded();
364
         fireRepaintNeeded();
365
     }
365
     }
366
-
367
 }
366
 }

Laden…
Abbrechen
Speichern