package org.simpleim.client;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;

import org.simpleim.client.model.container.Account;
import org.simpleim.client.model.netty.ChatClientHandler;

public class ChatController extends Controller {
	private ChatClientHandler mChatClientHandler;
	private ObservableList<Account> mUserList;
	@FXML
	private ListView<Account> userList;
	@FXML
	private TextArea chatLog;
	@FXML
	private TextArea inputMessage;
	@FXML
	private Button send;

	public ChatController setChatClientHandler(ChatClientHandler handler) {
		mChatClientHandler = handler;
		//TODO add chatListener
		return this;
	}
	public ChatController setUserList(ObservableList<Account> userList) {
		mUserList = userList;
		this.userList.setItems(mUserList);
		return this;
	}
}

@@ -126,16 +126,54 @@
 Button;%0A
+import javafx.scene.control.ListCell;%0A
 import j
@@ -239,16 +239,45 @@
 extArea;
+%0Aimport javafx.util.Callback;
 %0A%0Aimport
@@ -966,11 +966,555 @@
 this;%0A%09%7D
+%0A%0A%09@FXML%0A%09private void initialize() %7B%0A%09%09userList.setCellFactory(new Callback%3CListView%3CAccount%3E, ListCell%3CAccount%3E%3E() %7B%0A%09%09%09@Override%0A%09%09%09public ListCell%3CAccount%3E call(ListView%3CAccount%3E list) %7B%0A%09%09%09%09return new AccountFormatListCell();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%0A%09private static class AccountFormatListCell extends ListCell%3CAccount%3E %7B%0A%09%09@Override%0A%09%09protected void updateItem(Account item, boolean empty) %7B%0A%09%09%09super.updateItem(item, empty);%0A%09%09%09setText(item == null ? %22%22 : item.getNickname() == null ? item.getId() : item.getNickname());%0A%09%09%09// TODO online?%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

add userList's cell formatter