tabbedPane = new TabbedPane();
tabbedPane.getStyle().setBgTransparency(0);
conversationForm = new Container();
conversationForm.setScrollableY(true);
conversationForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
//conversationForm.getStyle().setBgColor()
Vector msgs = currentConversation.messages;
Message msg;
//if (currentConversation.isMulti || canAnswer) {
TextArea tf = new TextArea(2,100,TextArea.ANY); //settare stile
tf.setFocus(true);
//TextBox tf = new TextBox("", ">", 128, TextArea.ANY);
infopool.put("text2send", tf);
conversationForm.addComponent(tf);
int maxText = 11; //max texts displayed
if (history || msgs.size() < maxText)
maxText = msgs.size();//all texts
history = false; //reset
//int lin = 0; //links count
for (int i=msgs.size()-1; i>=msgs.size()-maxText; i--) {
msg = (Message) msgs.elementAt(i);
int j,p = -1;
//TODO: mettere sfondo di colore alternato
String m;
if (currentConversation.isMulti)
m = msg.getTextNick(); //cambiare
else
m = msg.getText(); //cambiare
Container text = new Container(new BoxLayout(BoxLayout.X_AXIS));
/*if (i%2 != 0) {
text.getStyle().setBgTransparency(255);
}*/
text.getStyle().setBorder(Border.createEmpty()); //no border
Label txt = new Label(m.substring(0, m.indexOf(">")+1));
txt.getStyle().setFgColor(0xF1F57C);
txt.getStyle().setBgTransparency(0);
text.addComponent(txt);
m = m.substring(m.indexOf(">")+1, m.length());
if ((p = m.indexOf("1smile")) != -1) { //check smiles
//conversationForm.addComponent(txt);
if (p > 0) {
text.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
text.addComponent(new MyTextArea(m.substring(0, p),0,p));
}
Label l = new Label(Contents.displayImage(m.substring(p, p + 7)));
l.getStyle().setBgTransparency(0);
text.addComponent( l);
if (p + 8 < m.length()-1)
text.addComponent(new MyTextArea(m.substring(p + 8, m.length()),0,(m.length()-(p+8))));
}
if ((j = m.indexOf("+url+")) != -1) { //check links
//conversationForm.addComponent(txt);
//String name_link = "link";
/* if (lin == 0)
lin++;
else {
name_link += lin;
lin++;
}*/
int k = m.indexOf("-url-");
if (j > 0) {
text.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
text.addComponent(new MyTextArea(m.substring(0, j), 0,j));
}
j = j + 5;
Button link = new Button(m.substring(j, k));
link.getStyle().setBgTransparency(100);
link.getStyle().setBorder(Border.createEmpty()); //no border
link.addActionListener(new ButtonActionListener());
text.addComponent(link); k = k + 5;
if (k < m.length()-1)
text.addComponent(new MyTextArea(m.substring(k, m.length()), 0, 100));
}
else if (j == -1 && p == -1) {
MyTextArea t = new MyTextArea(m, 0,50);
t.setEnabled(true);
text.addComponent(t);
}
conversationForm.addComponent(text);
}
//if it is multi chat
if (currentConversation.isMulti) {
//conversationForm.append(new util.CustomSpacer(conversationForm.getWidth()));
// res.append("Room Members: ");
Container multi = new Container();
multi.setLayout(new BorderLayout());
multi.addComponent(BorderLayout.NORTH,new MyLabel("Room Members:"));
GroupChat chat = (GroupChat)Datas.multichat.get(currentConversation.name);
//conversationForm.append(new util.CustomStringItem("Room Members:", /*chat.jids,*/ conversationForm.getWidth()));
Container friends = new Container();
for (int j=0; j<chat.jids.size(); j++){
String temp = (String)chat.jids.elementAt(j);
if (temp.equals(currentConversation.name))
continue;
else if (temp.indexOf('@') != -1)
friends.addComponent(new Label(temp.substring(0, temp.indexOf('@'))));
else
friends.addComponent(new Label(temp));
}
multi.addComponent(BorderLayout.CENTER, friends);
//conversationForm.append(new util.CustomSpacer(conversationForm.getWidth()));
TextField tf1 = new TextField(Contents.invite_textbox, 64);
infopool.put("invite", tf1);
multi.addComponent(BorderLayout.SOUTH, tf1);
conversationForm.addComponent(multi);
}
Button his = new Button("Show History");
his.getStyle().setBgTransparency(100);
his.getStyle().setBorder(Border.createEmpty());
his.addActionListener(new ButtonActionListener());
conversationForm.addComponent(his);
//his.addCommand(Contents.history);
//TODO: se mettessimo un tastino send sotto la textarea?
if (currentConversation.isMulti)
mainForm.addCommand(Contents.invite,2);
tabbedPane.addTab("Contacts", new Container());
if (tab == 0) { //nuova tab da aggiungere
if (Datas.conversations.size() > 0)
{
Vector chats = Datas.conversations;
for (int k = 0; k < chats.size()-1; k++)
{
Conversation c = (Conversation)chats.elementAt(k);
String name = c.name;
if (name.indexOf("@") != -1) {
name = name.substring(0, name.indexOf("@"));
}
tabbedPane.addTab(name, new Container());
}
}
//System.out.println("add tab:"+tab);
listener.keypressed = false;
String name = currentConversation.name;
if (name.indexOf("@") != -1) {
name = name.substring(0, name.indexOf("@"));
}
tabbedPane.addTab(name, conversationForm);
tabbedPane.setSelectedIndex(tabbedPane.getTabCount()-1);
listener.keypressed = true;
// System.out.println("dopo add");
}else {
//System.out.println("insert tab:"+tab);
if (Datas.conversations.size() > 0)
{
Vector chats = Datas.conversations;
for (int k = 0; k < chats.size(); k++)
{
Conversation c = (Conversation)chats.elementAt(k);
String name = c.name;
if (!name.equals(currentConversation.name)) {
if (name.indexOf("@") != -1) {
name = name.substring(0, name.indexOf("@"));
}
tabbedPane.addTab(name, new Container());
}else {
if (name.indexOf("@") != -1) {
name = name.substring(0, name.indexOf("@"));
}
tabbedPane.addTab(name, conversationForm);