setClosable(true);
setCollapsible(false);
setLayout(new FitLayout());
LayoutContainer main = new LayoutContainer();
main.setLayout(new RowLayout(Orientation.VERTICAL));
ListStore<Service> rooms = new ListStore<Service>();
rooms.add(serviceDisco.getMUCRoomServices());
roomField = new ComboBox<Service>();
roomField.setFieldLabel(JabberApp.getConstants().Chat_Rooms());
roomField.setStore(rooms);
roomField.setDisplayField("name");
roomField.setTypeAhead(true);
roomField.addSelectionChangedListener(new SelectionChangedListener<Service>()
{
public void selectionChanged(SelectionChangedEvent<Service> se)
{
Service service = se.getSelectedItem();
getRooms(service.getJid());
}
});
roomField.setValue(rooms.getAt(0));
//create the grid to show the room list
columnConfigs = new ArrayList<ColumnConfig>();
ColumnModel cm = new ColumnModel(columnConfigs);
ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Room Name");
columnConfigs.add(column);
store = new ListStore<Room>();
roomGrid = new Grid<Room>(store, cm);
roomGrid.setStyleAttribute("borderTop", "none");
roomGrid.setBorders(true);
roomGrid.setAutoExpandColumn("name");
roomGrid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
roomGrid.setHideHeaders(true);
roomGrid.addListener(Events.RowDoubleClick , new Listener<GridEvent>()
{
public void handleEvent(GridEvent be)
{
List<Room> rooms = store.getModels();
Room room = rooms.get(be.rowIndex);
String jid = room.jid();
if(jid != null&&!jid.isEmpty())
joinRoom(jid);
}
});
roomGrid.getSelectionModel().addListener(Events.SelectionChange, new Listener<SelectionEvent<Room>>()
{
public void handleEvent(SelectionEvent<Room> be)
{
if(!be.selection.isEmpty())
currentJid = be.selection.get(0).jid();
else
currentJid = null;
}
});
ButtonBar topBar = new ButtonBar();
Button refreshButton = new Button("Refresh");
refreshButton.addSelectionListener(new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent ce)
{
refreshRooms();
}
});
roomField.setWidth(250);
topBar.add(new ButtonAdapter(roomField));
topBar.add(new FillButton());
topBar.add(refreshButton);
this.setTopComponent(topBar);
//main.add(roomField,new RowData(1,-1));
main.add(roomGrid,new RowData(1,1));
add(main);
ButtonBar bar = new ButtonBar();
Button createButton = new Button("Create Room");
createButton.addSelectionListener(new SelectionListener<ButtonEvent>()