Adjusted to event system refactoring
This commit is contained in:
parent
84fb28cb34
commit
c0954036a5
@ -92,12 +92,13 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
@ -126,4 +127,4 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
@ -1,41 +0,0 @@
|
||||
package envoy.client.event;
|
||||
|
||||
import envoy.data.User;
|
||||
import envoy.event.ContactOperationEvent.Operation;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>AddContactEvent.java</strong><br>
|
||||
* Created: <strong>09.02.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy v0.3-alpha
|
||||
*/
|
||||
public class AddContactEvent implements Event<User> {
|
||||
|
||||
private User contact;
|
||||
private Operation operation;
|
||||
|
||||
private static final long serialVersionUID = 7855669140917046709L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link AddContactEvent}.
|
||||
*
|
||||
* @param contact the user to be added to the contacts
|
||||
* @param operation the operation, which should be executed
|
||||
* @since Envoy v0.3-alpha
|
||||
*/
|
||||
public AddContactEvent(User contact, Operation operation) {
|
||||
this.contact = contact;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User get() { return contact; }
|
||||
|
||||
/**
|
||||
* @return the operation, which should be executed
|
||||
*/
|
||||
public Operation getOperation() { return operation; }
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package envoy.client.event;
|
||||
|
||||
import envoy.data.Message;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
@ -10,7 +11,7 @@ import envoy.data.Message;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class MessageCreationEvent extends MessageEvent {
|
||||
public class MessageCreationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = -6451021678064566774L;
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
package envoy.client.event;
|
||||
|
||||
import envoy.data.Message;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>MessageCreationEvent.java</strong><br>
|
||||
* Created: <strong>4 Dec 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class MessageEvent implements Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 7658989461923112804L;
|
||||
|
||||
/**
|
||||
* the {@link Message} attached to this {@link MessageEvent}.
|
||||
*/
|
||||
protected final Message message;
|
||||
|
||||
/**
|
||||
* Initializes a {@link MessageEvent} conveying information about a
|
||||
* {@link Message} object.
|
||||
*
|
||||
* @param message the {@link Message} object to attach to this event
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public MessageEvent(Message message) { this.message = message; }
|
||||
|
||||
@Override
|
||||
public Message get() { return message; }
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package envoy.client.event;
|
||||
|
||||
import envoy.data.Message;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
@ -10,7 +11,7 @@ import envoy.data.Message;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class MessageModificationEvent extends MessageEvent {
|
||||
public class MessageModificationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 4650039506439563116L;
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
package envoy.client.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import envoy.data.User;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>SearchResultEvent.java</strong><br>
|
||||
* Created: <strong>08.02.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy v0.3-alpha
|
||||
*/
|
||||
public class SearchResultEvent implements Event<List<User>> {
|
||||
|
||||
private final List<User> resultList;
|
||||
|
||||
private static final long serialVersionUID = 2540321329192201277L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link SearchResultEvent}
|
||||
*
|
||||
* @param resultList the List containing the contacts sent from the server
|
||||
* @since Envoy v0.3-alpha
|
||||
*/
|
||||
public SearchResultEvent(List<User> resultList) { this.resultList = resultList; }
|
||||
|
||||
@Override
|
||||
public List<User> get() { return resultList; }
|
||||
}
|
@ -11,10 +11,9 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class ThemeChangeEvent implements Event<Theme> {
|
||||
public class ThemeChangeEvent extends Event<Theme> {
|
||||
|
||||
private static final long serialVersionUID = 6756772448803774547L;
|
||||
private final Theme theme;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ThemeChangeEvent} conveying information about the change
|
||||
@ -23,8 +22,5 @@ public class ThemeChangeEvent implements Event<Theme> {
|
||||
* @param theme the new currently used {@link Theme} object
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public ThemeChangeEvent(Theme theme) { this.theme = theme; }
|
||||
|
||||
@Override
|
||||
public Theme get() { return theme; }
|
||||
public ThemeChangeEvent(Theme theme) { super(theme); }
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import javax.naming.TimeLimitExceededException;
|
||||
import envoy.client.data.Cache;
|
||||
import envoy.client.data.Config;
|
||||
import envoy.client.data.LocalDb;
|
||||
import envoy.client.event.SearchResultEvent;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
import envoy.data.*;
|
||||
import envoy.event.*;
|
||||
@ -115,7 +114,7 @@ public class Client implements Closeable {
|
||||
receiver.registerProcessor(IdGenerator.class, localDb::setIdGenerator);
|
||||
|
||||
// Process contact searches
|
||||
receiver.registerProcessor(Contacts.class, contacts -> EventBus.getInstance().dispatch(new SearchResultEvent(contacts.getContacts())));
|
||||
receiver.registerProcessor(ContactSearchResult.class, EventBus.getInstance()::dispatch);
|
||||
|
||||
// Request a generator if none is present or the existing one is consumed
|
||||
if (!localDb.hasIdGenerator() || !localDb.getIdGenerator().hasNext()) requestIdGenerator();
|
||||
|
@ -35,7 +35,6 @@ public class Receiver implements Runnable {
|
||||
*/
|
||||
public Receiver(InputStream in) { this.in = in; }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
@ -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();
|
||||
|
@ -7,7 +7,6 @@ import java.awt.Font;
|
||||
import javax.swing.*;
|
||||
|
||||
import envoy.client.Settings;
|
||||
import envoy.client.event.AddContactEvent;
|
||||
import envoy.client.ui.list.ComponentList;
|
||||
import envoy.client.ui.list.ComponentListCellRenderer;
|
||||
import envoy.data.User;
|
||||
@ -62,7 +61,7 @@ public class ContactsSearchRenderer implements ComponentListCellRenderer<User> {
|
||||
add.setBackground(list.getBackground());
|
||||
add.setForeground(list.getForeground());
|
||||
|
||||
add.addActionListener((evt) -> { EventBus.getInstance().dispatch(new AddContactEvent(value, ContactOperationEvent.Operation.ADD)); });
|
||||
add.addActionListener((evt) -> { EventBus.getInstance().dispatch(new ContactOperationEvent(value, ContactOperationEvent.Operation.ADD)); });
|
||||
|
||||
panel.add(add);
|
||||
|
||||
|
Reference in New Issue
Block a user