Adjusted to event system refactoring
This commit is contained in:
@ -4,6 +4,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -15,7 +16,8 @@ import javax.swing.event.DocumentListener;
|
||||
import envoy.client.Settings;
|
||||
import envoy.client.data.Chat;
|
||||
import envoy.client.data.LocalDb;
|
||||
import envoy.client.event.*;
|
||||
import envoy.client.event.MessageCreationEvent;
|
||||
import envoy.client.event.ThemeChangeEvent;
|
||||
import envoy.client.net.Client;
|
||||
import envoy.client.net.WriteProxy;
|
||||
import envoy.client.ui.list.ComponentList;
|
||||
@ -27,7 +29,6 @@ import envoy.data.Message.MessageStatus;
|
||||
import envoy.data.MessageBuilder;
|
||||
import envoy.data.User;
|
||||
import envoy.event.*;
|
||||
import envoy.event.ContactOperationEvent.Operation;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
@ -189,7 +190,6 @@ public class ChatWindow extends JFrame {
|
||||
userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
userList.addListSelectionListener((listSelectionEvent) -> {
|
||||
if (client != null && localDb != null && !listSelectionEvent.getValueIsAdjusting()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final JList<User> selectedUserList = (JList<User>) listSelectionEvent.getSource();
|
||||
final User user = selectedUserList.getSelectedValue();
|
||||
|
||||
@ -400,24 +400,25 @@ public class ChatWindow extends JFrame {
|
||||
repaint();
|
||||
});
|
||||
|
||||
EventBus.getInstance().register(SearchResultEvent.class, (evt) -> {
|
||||
EventBus.getInstance().register(ContactSearchResult.class, (evt) -> {
|
||||
contactsModel.clear();
|
||||
final java.util.List<User> contacts = ((SearchResultEvent) evt).get();
|
||||
final java.util.List<User> contacts = (List<User>) evt.get();
|
||||
logger.info("Received contact search result " + contacts);
|
||||
contacts.forEach(contactsModel::add);
|
||||
revalidate();
|
||||
repaint();
|
||||
});
|
||||
|
||||
EventBus.getInstance().register(AddContactEvent.class, (evt) -> {
|
||||
User contact = ((AddContactEvent) evt).get();
|
||||
Operation operation = ((AddContactEvent) evt).getOperation();
|
||||
EventBus.getInstance().register(ContactOperationEvent.class, (evt) -> {
|
||||
|
||||
try {
|
||||
client.sendEvent(new ContactOperationEvent(contact, operation));
|
||||
client.sendEvent(evt);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
User contact = (User) evt.get();
|
||||
|
||||
// Clearing the search field and the searchResultList
|
||||
searchField.setText("");
|
||||
contactsModel.clear();
|
||||
|
Reference in New Issue
Block a user