|
@@ -47,6 +47,7 @@ import com.dmdirc.util.collections.RollingList;
|
47
|
47
|
import java.util.Date;
|
48
|
48
|
import java.util.HashMap;
|
49
|
49
|
import java.util.Map;
|
|
50
|
+import java.util.Optional;
|
50
|
51
|
import java.util.WeakHashMap;
|
51
|
52
|
|
52
|
53
|
import javax.inject.Inject;
|
|
@@ -135,7 +136,7 @@ public class LagDisplayManager implements ConfigChangeListener {
|
135
|
136
|
*/
|
136
|
137
|
protected RollingList<Long> getHistory(final Connection connection) {
|
137
|
138
|
if (!history.containsKey(connection)) {
|
138
|
|
- history.put(connection, new RollingList<Long>(historySize));
|
|
139
|
+ history.put(connection, new RollingList<>(historySize));
|
139
|
140
|
}
|
140
|
141
|
return history.get(connection);
|
141
|
142
|
}
|
|
@@ -162,11 +163,12 @@ public class LagDisplayManager implements ConfigChangeListener {
|
162
|
163
|
@Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)
|
163
|
164
|
public void selectionChanged(final SwingWindowSelectedEvent event) {
|
164
|
165
|
if (event.getWindow().isPresent()) {
|
165
|
|
- final Connection connection = event.getWindow().get().getContainer().getConnection();
|
166
|
|
- if (connection != null && connection.getState() != ServerState.CONNECTED) {
|
|
166
|
+ final Optional<Connection> connection = event.getWindow().get().getContainer()
|
|
167
|
+ .getOptionalConnection();
|
|
168
|
+ if (connection.isPresent() && connection.get().getState() != ServerState.CONNECTED) {
|
167
|
169
|
panel.getComponent().setText("Not connected");
|
168
|
170
|
} else {
|
169
|
|
- panel.getComponent().setText(getTime(connection));
|
|
171
|
+ panel.getComponent().setText(getTime(connection.get()));
|
170
|
172
|
}
|
171
|
173
|
} else {
|
172
|
174
|
panel.getComponent().setText("Unknown");
|
|
@@ -293,10 +295,9 @@ public class LagDisplayManager implements ConfigChangeListener {
|
293
|
295
|
}
|
294
|
296
|
|
295
|
297
|
private boolean isActiveWindow(final Connection connection) {
|
296
|
|
- return activeFrameManager.getActiveFrame().isPresent()
|
297
|
|
- && activeFrameManager.getActiveFrame().get().getContainer().getOptionalConnection()
|
298
|
|
- .isPresent() && activeFrameManager.getActiveFrame().get().getContainer()
|
299
|
|
- .getOptionalConnection().get().equals(connection);
|
|
298
|
+ return activeFrameManager.getActiveFrame().map(TextFrame::getContainer)
|
|
299
|
+ .flatMap(FrameContainer::getOptionalConnection)
|
|
300
|
+ .filter(connection::equals).isPresent();
|
300
|
301
|
}
|
301
|
302
|
|
302
|
303
|
}
|