Refactored to the new contact related classes in envoy-common
This commit is contained in:
parent
128d5bec4a
commit
c90bbbc262
2
pom.xml
2
pom.xml
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.informatik-ag-ngl</groupId>
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
<artifactId>envoy-common</artifactId>
|
<artifactId>envoy-common</artifactId>
|
||||||
<version>f~contacts-SNAPSHOT</version>
|
<version>develop-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package envoy.client.event;
|
package envoy.client.event;
|
||||||
|
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
import envoy.event.ContactOperation.Operation;
|
import envoy.event.ContactOperationEvent.Operation;
|
||||||
import envoy.event.Event;
|
import envoy.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,7 @@ public class AddContactEvent implements Event<User> {
|
|||||||
private static final long serialVersionUID = 7855669140917046709L;
|
private static final long serialVersionUID = 7855669140917046709L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a {@link AddContactEvent}
|
* Initializes a {@link AddContactEvent}.
|
||||||
*
|
*
|
||||||
* @param contact the user to be added to the contacts
|
* @param contact the user to be added to the contacts
|
||||||
* @param operation the operation, which should be executed
|
* @param operation the operation, which should be executed
|
||||||
@ -38,5 +38,4 @@ public class AddContactEvent implements Event<User> {
|
|||||||
* @return the operation, which should be executed
|
* @return the operation, which should be executed
|
||||||
*/
|
*/
|
||||||
public Operation getOperation() { return operation; }
|
public Operation getOperation() { return operation; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import envoy.data.Message.MessageStatus;
|
|||||||
import envoy.data.MessageBuilder;
|
import envoy.data.MessageBuilder;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
import envoy.event.*;
|
import envoy.event.*;
|
||||||
import envoy.event.ContactOperation.Operation;
|
import envoy.event.ContactOperationEvent.Operation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>envoy-client</strong><br>
|
* Project: <strong>envoy-client</strong><br>
|
||||||
@ -262,7 +262,7 @@ public class ChatWindow extends JFrame {
|
|||||||
if (client.isOnline()) {
|
if (client.isOnline()) {
|
||||||
try {
|
try {
|
||||||
if (!searchField.getText().isEmpty()) {
|
if (!searchField.getText().isEmpty()) {
|
||||||
client.sendEvent(new ContactsRequest(searchField.getText(), client.getSender()));
|
client.sendEvent(new ContactSearchRequest(searchField.getText()));
|
||||||
} else {
|
} else {
|
||||||
contactsModel.clear();
|
contactsModel.clear();
|
||||||
revalidate();
|
revalidate();
|
||||||
@ -278,9 +278,7 @@ public class ChatWindow extends JFrame {
|
|||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
if (client.isOnline()) {
|
if (client.isOnline()) {
|
||||||
try {
|
try {
|
||||||
if(!searchField.getText().isEmpty()) {
|
if (!searchField.getText().isEmpty()) { client.sendEvent(new ContactSearchRequest(searchField.getText())); }
|
||||||
client.sendEvent(new ContactsRequest(searchField.getText(), client.getSender()));
|
|
||||||
}
|
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -410,7 +408,7 @@ public class ChatWindow extends JFrame {
|
|||||||
User contact = ((AddContactEvent) evt).get();
|
User contact = ((AddContactEvent) evt).get();
|
||||||
Operation operation = ((AddContactEvent) evt).getOperation();
|
Operation operation = ((AddContactEvent) evt).getOperation();
|
||||||
try {
|
try {
|
||||||
client.sendEvent(new ContactOperation(contact, operation));
|
client.sendEvent(new ContactOperationEvent(contact, operation));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -565,7 +563,6 @@ public class ChatWindow extends JFrame {
|
|||||||
contentPane.remove(scrollPane);
|
contentPane.remove(scrollPane);
|
||||||
contentPane.add(searchPane, gbc_searchPane);
|
contentPane.add(searchPane, gbc_searchPane);
|
||||||
contentPane.revalidate();
|
contentPane.revalidate();
|
||||||
contactRenderer.setScrollPane(possibleContacts);
|
|
||||||
contentPane.repaint();
|
contentPane.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,9 +572,7 @@ public class ChatWindow extends JFrame {
|
|||||||
* @param client the {@link Client} used to send and receive messages
|
* @param client the {@link Client} used to send and receive messages
|
||||||
* @since Envoy v0.2-alpha
|
* @since Envoy v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public void setClient(Client client) {
|
public void setClient(Client client) { this.client = client; }
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link LocalDb} used by this {@link ChatWindow}. After
|
* Sets the {@link LocalDb} used by this {@link ChatWindow}. After
|
||||||
|
@ -11,7 +11,7 @@ import envoy.client.event.AddContactEvent;
|
|||||||
import envoy.client.ui.list.ComponentList;
|
import envoy.client.ui.list.ComponentList;
|
||||||
import envoy.client.ui.list.ComponentListCellRenderer;
|
import envoy.client.ui.list.ComponentListCellRenderer;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
import envoy.event.ContactOperation.Operation;
|
import envoy.event.ContactOperationEvent;
|
||||||
import envoy.event.EventBus;
|
import envoy.event.EventBus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,8 +27,6 @@ import envoy.event.EventBus;
|
|||||||
*/
|
*/
|
||||||
public class ContactsSearchRenderer implements ComponentListCellRenderer<User> {
|
public class ContactsSearchRenderer implements ComponentListCellRenderer<User> {
|
||||||
|
|
||||||
private PrimaryScrollPane scrollPane = new PrimaryScrollPane();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JComponent getListCellComponent(ComponentList<? extends User> list, User value, boolean isSelected) {
|
public JComponent getListCellComponent(ComponentList<? extends User> list, User value, boolean isSelected) {
|
||||||
final JPanel panel = new JPanel();
|
final JPanel panel = new JPanel();
|
||||||
@ -64,9 +62,7 @@ public class ContactsSearchRenderer implements ComponentListCellRenderer<User> {
|
|||||||
add.setBackground(list.getBackground());
|
add.setBackground(list.getBackground());
|
||||||
add.setForeground(list.getForeground());
|
add.setForeground(list.getForeground());
|
||||||
|
|
||||||
add.addActionListener((evt) -> {
|
add.addActionListener((evt) -> { EventBus.getInstance().dispatch(new AddContactEvent(value, ContactOperationEvent.Operation.ADD)); });
|
||||||
EventBus.getInstance().dispatch(new AddContactEvent(value, Operation.ADD));
|
|
||||||
});
|
|
||||||
|
|
||||||
panel.add(add);
|
panel.add(add);
|
||||||
|
|
||||||
@ -81,7 +77,4 @@ public class ContactsSearchRenderer implements ComponentListCellRenderer<User> {
|
|||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use this method properly
|
|
||||||
public void setScrollPane(PrimaryScrollPane scrollPane) { this.scrollPane = scrollPane; }
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user