/** * Returns the Active ChatRoom. * * @return the ChatRoom active in the tabbed pane. * @throws ChatRoomNotFoundException is thrown if no chat room is found. */ public ChatRoom getActiveChatRoom() throws ChatRoomNotFoundException { int location = getSelectedIndex(); if (location != -1) { return getChatRoom(location); } throw new ChatRoomNotFoundException(); }
/** * Returns a ChatRoom in the specified tab location. * * @param location the tab location. * @return the ChatRoom found. * @throws ChatRoomNotFoundException thrown if the room is not found. */ public ChatRoom getChatRoom(int location) throws ChatRoomNotFoundException { if (getTabCount() < location) { throw new ChatRoomNotFoundException(); } try { Component comp = getComponentAt(location); if (comp instanceof ChatRoom) { return (ChatRoom)comp; } } catch (ArrayIndexOutOfBoundsException outOfBoundsEx) { Log.error("Error getting Chat Room", outOfBoundsEx); } throw new ChatRoomNotFoundException(); }
/** * Returns a ChatRoom by name. * * @param roomAddress the name of the ChatRoom. * @return the ChatRoom * @throws ChatRoomNotFoundException if the room was not found. */ public ChatRoom getChatRoom(EntityBareJid roomAddress) throws ChatRoomNotFoundException { for (int i = 0; i < getTabCount(); i++) { ChatRoom room = null; try { room = getChatRoom(i); } catch (ChatRoomNotFoundException e1) { // Ignore } if (room != null && room.getRoomJid().equals(roomAddress) && room.isActive()) { return room; } } throw new ChatRoomNotFoundException(roomAddress + " not found."); }