Compare commits
7 commits
415b477ef8
...
3485adfe7e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3485adfe7e | ||
|
|
9cba46cd28 | ||
|
|
45e07299e9 | ||
|
|
c59fc318f0 | ||
|
|
811537dec8 | ||
|
|
93266eb429 | ||
|
|
def6af9515 |
33 changed files with 525 additions and 237 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package fr.insa.clavardator.chat;
|
||||
|
||||
import fr.insa.clavardator.users.CurrentUser;
|
||||
import fr.insa.clavardator.users.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -22,4 +23,8 @@ public class Message implements Serializable {
|
|||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public User getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChatController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private ListView<String> messageList;
|
||||
|
||||
private List<ButtonPressEvent> attachmentListeners;
|
||||
private List<ButtonPressEvent> sendListeners;
|
||||
private List<ButtonPressEvent> editListeners;
|
||||
|
||||
public void addAttachmentListener(ButtonPressEvent listener) {
|
||||
attachmentListeners.add(listener);
|
||||
}
|
||||
|
||||
public void addSendListener(ButtonPressEvent listener) {
|
||||
sendListeners.add(listener);
|
||||
}
|
||||
|
||||
public void addEditListener(ButtonPressEvent listener) {
|
||||
editListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onAttachmentPress() {
|
||||
attachmentListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
public void onSendPress() {
|
||||
sendListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
public void onEditPress() {
|
||||
editListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
attachmentListeners = new ArrayList<>();
|
||||
sendListeners = new ArrayList<>();
|
||||
editListeners = new ArrayList<>();
|
||||
|
||||
ObservableList<String> messages = FXCollections.observableArrayList(
|
||||
"test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "no", "no", "test", "no", "no", "test", "no", "test");
|
||||
messageList.setItems(messages);
|
||||
messageList.scrollTo(messageList.getItems().size() - 1);
|
||||
messageList.setSelectionModel(new NoSelectionModel());
|
||||
messageList.setCellFactory(listView -> new MessageListItemCell());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import fr.insa.clavardator.ui.chat.ChatController;
|
||||
import fr.insa.clavardator.ui.users.UserListController;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
|
|
@ -18,6 +20,9 @@ public class MainController implements Initializable {
|
|||
userListController.addRefreshUserListener(() -> {
|
||||
System.out.println("refresh event");
|
||||
});
|
||||
userListController.addUserSelectedListener((user) -> {
|
||||
System.out.println(user.getUsername());
|
||||
});
|
||||
chatController.addAttachmentListener(() -> {
|
||||
System.out.println("attach event");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.MultipleSelectionModel;
|
||||
|
||||
public class NoSelectionModel extends MultipleSelectionModel<String> {
|
||||
public class NoSelectionModel<T> extends MultipleSelectionModel<T> {
|
||||
@Override
|
||||
public ObservableList<Integer> getSelectedIndices() {
|
||||
return FXCollections.emptyObservableList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObservableList<String> getSelectedItems() {
|
||||
public ObservableList<T> getSelectedItems() {
|
||||
return FXCollections.emptyObservableList();
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ public class NoSelectionModel extends MultipleSelectionModel<String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void select(String obj) {
|
||||
public void select(T obj) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import com.jfoenix.controls.JFXListCell;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class UserListController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private ListView<String> userList;
|
||||
private List<ButtonPressEvent> refreshUserListeners;
|
||||
|
||||
public void addRefreshUserListener(ButtonPressEvent listener) {
|
||||
refreshUserListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onRefreshUserListPress() {
|
||||
refreshUserListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
refreshUserListeners = new ArrayList<>();
|
||||
ObservableList<String> activeList = FXCollections.observableArrayList(
|
||||
"Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise", "Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise");
|
||||
userList.setItems(activeList);
|
||||
|
||||
userList.setCellFactory(listView -> new UserListItemCell());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import com.jfoenix.controls.JFXListCell;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UserListItemCell extends ListCell<String> {
|
||||
|
||||
public UserListItemCell() {
|
||||
setStyle("-fx-padding: 0px");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
final FXMLLoader cellLoader = new FXMLLoader(getClass().getResource("userListItem.fxml"));
|
||||
try {
|
||||
setGraphic(cellLoader.load());
|
||||
final UserListItemController userListItemController = cellLoader.getController();
|
||||
userListItemController.setName(item);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class UserListItemController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private JFXButton button;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
|
||||
public void setName(String string) {
|
||||
button.setText(string);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
|
||||
import fr.insa.clavardator.users.User;
|
||||
|
||||
public interface UserSelectedEvent {
|
||||
public void onSelected(User user);
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package fr.insa.clavardator.ui.chat;
|
||||
|
||||
import fr.insa.clavardator.chat.Message;
|
||||
import fr.insa.clavardator.ui.ButtonPressEvent;
|
||||
import fr.insa.clavardator.ui.NoSelectionModel;
|
||||
import fr.insa.clavardator.users.CurrentUser;
|
||||
import fr.insa.clavardator.users.PeerUser;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChatController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private ListView<Message> messageList;
|
||||
@FXML
|
||||
private ChatFooterController chatFooterController;
|
||||
@FXML
|
||||
private ChatHeaderController chatHeaderController;
|
||||
|
||||
private CurrentUser currentUser;
|
||||
private PeerUser remoteUser;
|
||||
|
||||
public void addAttachmentListener(ButtonPressEvent listener) {
|
||||
chatFooterController.addAttachmentListener(listener);
|
||||
}
|
||||
|
||||
public void addSendListener(ButtonPressEvent listener) {
|
||||
chatFooterController.addSendListener(listener);
|
||||
}
|
||||
|
||||
public void addEditListener(ButtonPressEvent listener) {
|
||||
chatHeaderController.addEditListener(listener);
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentUser(CurrentUser currentUser) {
|
||||
this.currentUser = currentUser;
|
||||
}
|
||||
|
||||
public void setRemoteUser(PeerUser remoteUser) {
|
||||
this.remoteUser = remoteUser;
|
||||
loadMessageList();
|
||||
}
|
||||
|
||||
private void loadMessageList() {
|
||||
ObservableList<Message> messages = FXCollections.observableArrayList(
|
||||
new Message(remoteUser, currentUser, "Messsssage 1"),
|
||||
new Message(remoteUser, currentUser, "Messsssage 2"),
|
||||
new Message(currentUser, remoteUser, "Messsssage 3"),
|
||||
new Message(remoteUser, currentUser, "Messsssage 4")
|
||||
);
|
||||
messageList.setItems(messages);
|
||||
messageList.scrollTo(messageList.getItems().size() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
messageList.setItems(null);
|
||||
messageList.setSelectionModel(new NoSelectionModel<Message>());
|
||||
messageList.setCellFactory(listView -> new MessageListItemCell());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package fr.insa.clavardator.ui.chat;
|
||||
|
||||
import fr.insa.clavardator.ui.ButtonPressEvent;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChatFooterController implements Initializable {
|
||||
|
||||
private List<ButtonPressEvent> attachmentListeners;
|
||||
private List<ButtonPressEvent> sendListeners;
|
||||
|
||||
public void addAttachmentListener(ButtonPressEvent listener) {
|
||||
attachmentListeners.add(listener);
|
||||
}
|
||||
public void addSendListener(ButtonPressEvent listener) {
|
||||
sendListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onAttachmentPress() {
|
||||
attachmentListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
public void onSendPress() {
|
||||
sendListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
attachmentListeners = new ArrayList<>();
|
||||
sendListeners = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package fr.insa.clavardator.ui.chat;
|
||||
|
||||
import fr.insa.clavardator.ui.ButtonPressEvent;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ChatHeaderController implements Initializable {
|
||||
|
||||
private List<ButtonPressEvent> editListeners;
|
||||
|
||||
public void addEditListener(ButtonPressEvent listener) {
|
||||
editListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onEditPress() {
|
||||
editListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
public void onAboutPress() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
editListeners = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,26 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
package fr.insa.clavardator.ui.chat;
|
||||
|
||||
import fr.insa.clavardator.chat.Message;
|
||||
import fr.insa.clavardator.users.CurrentUser;
|
||||
import fr.insa.clavardator.users.User;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MessageListItemCell extends ListCell<String> {
|
||||
public class MessageListItemCell extends ListCell<Message> {
|
||||
|
||||
public MessageListItemCell() {
|
||||
setStyle("-fx-padding: 0px");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
protected void updateItem(Message item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
FXMLLoader cellLoader;
|
||||
if (item.equals("test")) {
|
||||
final User sender = item.getSender();
|
||||
if (sender instanceof CurrentUser) {
|
||||
cellLoader = new FXMLLoader(getClass().getResource("messageListItemSelf.fxml"));
|
||||
} else {
|
||||
cellLoader = new FXMLLoader(getClass().getResource("messageListItemOther.fxml"));
|
||||
|
|
@ -24,7 +28,7 @@ public class MessageListItemCell extends ListCell<String> {
|
|||
try {
|
||||
setGraphic(cellLoader.load());
|
||||
final MessageListItemController userListItemController = cellLoader.getController();
|
||||
userListItemController.setMessage(item);
|
||||
userListItemController.setMessage(item.getText());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.insa.clavardator.ui;
|
||||
package fr.insa.clavardator.ui.chat;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.fxml.FXML;
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package fr.insa.clavardator.ui.users;
|
||||
|
||||
import fr.insa.clavardator.users.ActiveUser;
|
||||
import fr.insa.clavardator.users.User;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class UserActiveIndicatorController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private Circle circle;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
circle.getStyleClass().clear();
|
||||
if (user instanceof ActiveUser) {
|
||||
circle.getStyleClass().add("active-user-dot");
|
||||
} else {
|
||||
circle.getStyleClass().add("inactive-user-dot");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package fr.insa.clavardator.ui.users;
|
||||
|
||||
import fr.insa.clavardator.ui.ButtonPressEvent;
|
||||
import fr.insa.clavardator.ui.UserSelectedEvent;
|
||||
import fr.insa.clavardator.users.ActiveUser;
|
||||
import fr.insa.clavardator.users.PeerUser;
|
||||
import fr.insa.clavardator.users.User;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListView;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class UserListController implements Initializable {
|
||||
|
||||
final private List<ButtonPressEvent> refreshUserListeners;
|
||||
final private List<UserSelectedEvent> userSelectedListeners;
|
||||
@FXML
|
||||
private ListView<User> userList;
|
||||
|
||||
public UserListController() {
|
||||
super();
|
||||
refreshUserListeners = new ArrayList<>();
|
||||
userSelectedListeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addRefreshUserListener(ButtonPressEvent listener) {
|
||||
refreshUserListeners.add(listener);
|
||||
}
|
||||
|
||||
public void addUserSelectedListener(UserSelectedEvent listener) {
|
||||
userSelectedListeners.add(listener);
|
||||
}
|
||||
|
||||
public void onRefreshUserListPress() {
|
||||
refreshUserListeners.forEach(ButtonPressEvent::onPress);
|
||||
}
|
||||
|
||||
private void onUserSelected(@org.jetbrains.annotations.NotNull User user) {
|
||||
final User currentSelectedUser = userList.getSelectionModel().getSelectedItem();
|
||||
if (!user.equals(currentSelectedUser)) {
|
||||
userList.getSelectionModel().select(user);
|
||||
userSelectedListeners.forEach(l -> l.onSelected(user));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
ObservableList<User> activeList = null;
|
||||
try {
|
||||
activeList = FXCollections.observableArrayList(
|
||||
new PeerUser("Dodo"),
|
||||
new ActiveUser("Coucou", InetAddress.getLocalHost())
|
||||
);
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
userList.setItems(activeList);
|
||||
userList.setCellFactory(listView -> {
|
||||
final UserListItemCell cell = new UserListItemCell();
|
||||
cell.setOnUserSelectedListener(this::onUserSelected);
|
||||
return cell;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package fr.insa.clavardator.ui.users;
|
||||
|
||||
import fr.insa.clavardator.ui.UserSelectedEvent;
|
||||
import fr.insa.clavardator.users.User;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ListCell;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UserListItemCell extends ListCell<User> {
|
||||
|
||||
private UserSelectedEvent listener;
|
||||
|
||||
public UserListItemCell() {
|
||||
setStyle("-fx-padding: 0px");
|
||||
}
|
||||
|
||||
public void setOnUserSelectedListener(UserSelectedEvent listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(User item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (!empty && item != null) {
|
||||
final FXMLLoader cellLoader = new FXMLLoader(getClass().getResource("userListItem.fxml"));
|
||||
try {
|
||||
setGraphic(cellLoader.load());
|
||||
UserListItemController userListItemController = cellLoader.getController();
|
||||
userListItemController.setUser(item);
|
||||
userListItemController.setOnPressListener(() -> {
|
||||
if (listener != null) {
|
||||
listener.onSelected(item);
|
||||
}
|
||||
});
|
||||
userListItemController.setSelected(isSelected());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package fr.insa.clavardator.ui.users;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import fr.insa.clavardator.ui.ButtonPressEvent;
|
||||
import fr.insa.clavardator.users.ActiveUser;
|
||||
import fr.insa.clavardator.users.User;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class UserListItemController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private JFXButton button;
|
||||
@FXML
|
||||
private UserActiveIndicatorController indicatorController;
|
||||
|
||||
private ButtonPressEvent listener;
|
||||
|
||||
private User user;
|
||||
|
||||
public void setOnPressListener(ButtonPressEvent listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void onPress() {
|
||||
if (listener != null) {
|
||||
listener.onPress();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
if (selected)
|
||||
setBackgroundSelected();
|
||||
else
|
||||
resetBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
resetBackground();
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
indicatorController.setUser(user);
|
||||
button.setText(user.getUsername());
|
||||
resetBackground();
|
||||
}
|
||||
|
||||
private void resetBackground() {
|
||||
if (user != null && user instanceof ActiveUser) {
|
||||
button.getStyleClass().remove("inactive-user-item");
|
||||
button.getStyleClass().add("active-user-item");
|
||||
} else {
|
||||
button.getStyleClass().remove("active-user-item");
|
||||
button.getStyleClass().add("inactive-user-item");
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundSelected() {
|
||||
button.getStyleClass().remove("inactive-user-item");
|
||||
button.getStyleClass().remove("active-user-item");
|
||||
button.getStyleClass().add("selected-user-item");
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,8 @@ public class ActiveUser extends PeerUser {
|
|||
|
||||
private transient PeerConnection connection;
|
||||
|
||||
public ActiveUser(InetAddress ipAddr) {
|
||||
public ActiveUser(String username, InetAddress ipAddr) {
|
||||
super(username);
|
||||
connection = new PeerConnection(ipAddr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package fr.insa.clavardator.users;
|
|||
|
||||
public class CurrentUser extends User {
|
||||
|
||||
public CurrentUser(UserList userList) {
|
||||
public CurrentUser(String username, UserList userList) {
|
||||
super(username);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ public class PeerUser extends User {
|
|||
|
||||
protected transient ChatHistory history;
|
||||
|
||||
public PeerUser() {
|
||||
public PeerUser(String username) {
|
||||
super(username);
|
||||
history = new ChatHistory(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ public class User implements Serializable, Comparable<User> {
|
|||
pcs.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public User() {}
|
||||
public User(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current value of username
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class UserList {
|
|||
*/
|
||||
public void discoverActiveUsers() {
|
||||
NetDiscoverer.discoverActiveUsers("CLAVARDATOR_BROADCAST", (ipAddr, data) -> {
|
||||
ActiveUser newUser = new ActiveUser(ipAddr);
|
||||
ActiveUser newUser = new ActiveUser("", ipAddr); // TODO find username
|
||||
activeUsers.add(newUser);
|
||||
pcs.firePropertyChange("activeUsers", null, newUser);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.ChatController"
|
||||
stylesheets="@styles.css" styleClass="container">
|
||||
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<HBox alignment="CENTER_LEFT" prefHeight="64.0" spacing="10">
|
||||
<padding>
|
||||
<Insets left="20" right="20"/>
|
||||
</padding>
|
||||
<Label text="Connecté en tant que : "/>
|
||||
<Label text="<USERNAME>"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onEditPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-user-edit" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<Pane HBox.hgrow="ALWAYS"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onEditPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-info" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" spacing="5" prefHeight="45">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<Circle radius="7.0" styleClass="active-user-dot"/>
|
||||
<Label text="USER NAME" styleClass="current-user"/>
|
||||
</HBox>
|
||||
<ListView fx:id="messageList" VBox.vgrow="ALWAYS"/>
|
||||
<HBox alignment="CENTER" spacing="10.0">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
<JFXTextField HBox.hgrow="ALWAYS"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onAttachmentPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paperclip" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<JFXButton mnemonicParsing="false" text="Envoyer" onMouseClicked="#onSendPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paper-plane" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
</HBox>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
15
src/main/resources/fr/insa/clavardator/ui/chat/chat.fxml
Normal file
15
src/main/resources/fr/insa/clavardator/ui/chat/chat.fxml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.chat.ChatController"
|
||||
stylesheets="@../styles.css" styleClass="container">
|
||||
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<fx:include source="chatHeader.fxml" fx:id="chatHeader"/>
|
||||
<ListView fx:id="messageList" VBox.vgrow="ALWAYS"/>
|
||||
<fx:include source="chatFooter.fxml" fx:id="chatFooter"/>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<HBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="fr.insa.clavardator.ui.chat.ChatFooterController"
|
||||
stylesheets="@../styles.css" styleClass="container" alignment="CENTER" spacing="10.0">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
<JFXTextField HBox.hgrow="ALWAYS"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onAttachmentPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paperclip" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<JFXButton mnemonicParsing="false" text="Envoyer" onMouseClicked="#onSendPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paper-plane" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
</HBox>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="fr.insa.clavardator.ui.chat.ChatHeaderController"
|
||||
stylesheets="@../styles.css" styleClass="container">
|
||||
<HBox alignment="CENTER_LEFT" prefHeight="64.0" spacing="10">
|
||||
<padding>
|
||||
<Insets left="20" right="20"/>
|
||||
</padding>
|
||||
<Label text="Connecté en tant que : "/>
|
||||
<Label text="<USERNAME>"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onEditPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-user-edit" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<Pane HBox.hgrow="ALWAYS"/>
|
||||
<JFXButton mnemonicParsing="false" onMouseClicked="#onAboutPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-info" iconSize="24"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" spacing="5" prefHeight="45">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<Circle radius="7.0" styleClass="active-user-dot"/>
|
||||
<Label text="USER NAME" styleClass="current-user"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane prefHeight="80.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.MessageListItemController"
|
||||
stylesheets="@styles.css" styleClass="inner">
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.chat.MessageListItemController"
|
||||
stylesheets="@../styles.css" styleClass="inner">
|
||||
<VBox prefHeight="200.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<AnchorPane prefHeight="80.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.MessageListItemController"
|
||||
stylesheets="@styles.css" styleClass="inner">
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.chat.MessageListItemController"
|
||||
stylesheets="@../styles.css" styleClass="inner">
|
||||
<VBox prefHeight="200.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.MainController">
|
||||
<HBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<fx:include source="userList.fxml" fx:id="userList"/>
|
||||
<fx:include source="chat.fxml" fx:id="chat" HBox.hgrow="ALWAYS"/>
|
||||
<fx:include source="users/userList.fxml" fx:id="userList"/>
|
||||
<fx:include source="chat/chat.fxml" fx:id="chat" HBox.hgrow="ALWAYS"/>
|
||||
</HBox>
|
||||
</AnchorPane>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.label, .button {
|
||||
.label, .button, .jfx-text-field {
|
||||
-fx-text-fill: #EAEAEA;
|
||||
-fx-font-size: 20;
|
||||
}
|
||||
|
|
@ -15,10 +15,30 @@
|
|||
-fx-background-color: #36383E;
|
||||
}
|
||||
|
||||
.jfx-button {
|
||||
-fx-background-color: #32338F;
|
||||
}
|
||||
|
||||
.active-user-item {
|
||||
-fx-background-color: #3e4046;
|
||||
}
|
||||
|
||||
.inactive-user-item {
|
||||
-fx-background-color: #36383E;
|
||||
}
|
||||
|
||||
.selected-user-item {
|
||||
-fx-background-color: #32338F;
|
||||
}
|
||||
|
||||
.active-user-dot {
|
||||
-fx-fill: #32b612;
|
||||
}
|
||||
|
||||
.inactive-user-dot {
|
||||
-fx-fill: #5b5b5b;
|
||||
}
|
||||
|
||||
.message-self, .message-other {
|
||||
-fx-font-size: 18;
|
||||
}
|
||||
|
|
@ -42,8 +62,16 @@
|
|||
|
||||
.list-view {
|
||||
-fx-padding: 0;
|
||||
-fx-background-color: #36383E;
|
||||
}
|
||||
|
||||
.list-cell:empty {
|
||||
-fx-background-color: #36383E;
|
||||
}
|
||||
|
||||
.jfx-text-field {
|
||||
-jfx-focus-color: #32338F;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
SCROLLBARS
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="fr.insa.clavardator.ui.users.UserActiveIndicatorController"
|
||||
stylesheets="@../styles.css"
|
||||
styleClass="inner">
|
||||
<Circle fx:id="circle" radius="5.0" styleClass="active-user-dot"/>
|
||||
</AnchorPane>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<?import javafx.scene.layout.*?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.UserListController"
|
||||
stylesheets="@styles.css" styleClass="container">
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.ui.users.UserListController"
|
||||
stylesheets="@../styles.css" styleClass="container">
|
||||
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<HBox alignment="CENTER" prefHeight="64.0" spacing="10.0">
|
||||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<AnchorPane prefHeight="40.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="fr.insa.clavardator.ui.UserListItemController" stylesheets="@styles.css"
|
||||
fx:controller="fr.insa.clavardator.ui.users.UserListItemController" stylesheets="@../styles.css"
|
||||
styleClass="inner">
|
||||
<JFXButton fx:id="button" alignment="CENTER_LEFT" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0">
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" onAction="#onPress">
|
||||
<graphic>
|
||||
<Circle radius="5.0" styleClass="active-user-dot"/>
|
||||
<fx:include source="userActiveIndicator.fxml" fx:id="indicator"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
</AnchorPane>
|
||||
Loading…
Reference in a new issue