/** * Returns a ChatRoom by name. * * @param roomName the name of the ChatRoom. * @return the ChatRoom * @throws ChatRoomNotFoundException if the room was not found. */ public ChatRoom getChatRoom(CharSequence roomName) throws ChatRoomNotFoundException { EntityBareJid roomAddress = JidCreate.entityBareFromOrThrowUnchecked(roomName); return getChatRoom(roomAddress); }
/** * Checks if a <code>ChatRoom</code> exists. * * @param jid the jid of the user. * @return true if the ChatRoom exists. */ public boolean chatRoomExists(String jid) { try { getChatContainer().getChatRoom(jid); } catch (ChatRoomNotFoundException e) { return false; } return true; }
/** * 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(); }
public Object construct() { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error("Error in activate chat.", e); } ChatContainer chatRooms = chatManager.getChatContainer(); try { chatRoom = chatRooms.getChatRoom(jid); } catch (ChatRoomNotFoundException e) { // Do nothing } return chatRoom; }
public void cancelledNotification(final Jid from, final ChatState state) { SwingUtilities.invokeLater( () -> { ContactList contactList = SparkManager.getWorkspace().getContactList(); ChatRoom chatRoom; try { chatRoom = getChatContainer().getChatRoom(from.asBareJid()); if (chatRoom != null && chatRoom instanceof ChatRoomImpl) { typingNotificationList.remove(chatRoom); // Notify Decorators notifySparkTabHandlers(chatRoom); ((ChatRoomImpl)chatRoom).notifyChatStateChange(state); } } catch (ChatRoomNotFoundException e) { // Do nothing } contactList.useDefaults(from); } ); }
public void windowActivated(WindowEvent windowEvent) { stopFlashing(); int sel = getSelectedIndex(); if (sel == -1) { return; } final ChatRoom room; try { room = getChatRoom(sel); focusChat(); // Set the title of the room. chatFrame.setTitle(room.getRoomTitle()); } catch (ChatRoomNotFoundException e1) { // Nothing to do } }
public void composingNotification(final Jid from) { SwingUtilities.invokeLater( () -> { final ContactList contactList = SparkManager.getWorkspace().getContactList(); ChatRoom chatRoom; try { chatRoom = getChatContainer().getChatRoom( from.asBareJid() ); if (chatRoom != null && chatRoom instanceof ChatRoomImpl) { typingNotificationList.add(chatRoom); // Notify Decorators notifySparkTabHandlers(chatRoom); ((ChatRoomImpl)chatRoom).notifyChatStateChange(ChatState.composing); } } catch (ChatRoomNotFoundException e) { // Do nothing } contactList.setIconFor(from, SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE)); } ); }
public void updateActiveTab() { for (int i = 0; i < pane.getTabCount(); ++i) { Component com = pane.getTabComponentAt(i); TabPanel panel = (TabPanel) com; Font oldFont = panel.getFont(); try { if (SparkManager.getChatManager().getChatContainer().getChatRoom(i).getUnreadMessageCount() == 0) { if (i == getSelectedIndex()) { panel.setTitleFont(new Font(oldFont.getFontName(), Font.BOLD, oldFont.getSize())); panel.setTitleColor((Color) UIManager.get("Chat.activeTabColor")); } else { panel.setTitleFont(new Font(oldFont.getFontName(), Font.PLAIN, oldFont.getSize())); panel.setTitleColor((Color) UIManager.get("Chat.inactiveTabColor")); } } } catch (ChatRoomNotFoundException e) { //Do nothing } } }
/** * Creates and/or opens a chat room with the specified user. * * @param userJID the jid of the user to chat with. * @param nicknameCs the nickname to use for the user. * @param title the title to use for the room. * @return the newly created <code>ChatRoom</code>. */ public ChatRoom createChatRoom(EntityJid userJID, CharSequence nicknameCs, CharSequence title) { Resourcepart nickname = Resourcepart.fromOrThrowUnchecked(nicknameCs); ChatRoom chatRoom; try { chatRoom = getChatContainer().getChatRoom(userJID); } catch (ChatRoomNotFoundException e) { chatRoom = UIComponentRegistry.createChatRoom(userJID, nickname, title); getChatContainer().addChatRoom(chatRoom); } return chatRoom; }
private void insertMessage(final BareJid bareJID, final Message message) throws ChatRoomNotFoundException { ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); chatRoom.insertMessage(message); int chatLength = chatRoom.getTranscriptWindow().getDocument().getLength(); chatRoom.getTranscriptWindow().setCaretPosition(chatLength); chatRoom.getChatInputEditor().requestFocusInWindow(); }
/** * 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."); }
private void enterRoom() { int selectedRow = roomsTable.getSelectedRow(); UIManager.put("OptionPane.okButtonText", Res.getString("ok")); if (-1 == selectedRow) { JOptionPane.showMessageDialog(dlg, Res.getString("message.select.room.to.enter"), Res.getString("title.group.chat"), JOptionPane.INFORMATION_MESSAGE); return; } final String roomJIDString = roomsTable.getValueAt(selectedRow, 2) + "@" + serviceName; EntityBareJid roomJID = JidCreate.entityBareFromUnescapedOrThrowUnchecked(roomJIDString); final String roomDescription = (String) roomsTable.getValueAt( selectedRow, 1); try { chatManager.getChatContainer().getChatRoom(roomJID); } catch (ChatRoomNotFoundException e1) { ConferenceUtils.joinConferenceOnSeperateThread(roomDescription, roomJID, null); } }
@Override public void finished() { final EntityBareJid roomName = roomJID; try { final ChatRoom room = SparkManager.getChatManager().getChatContainer().getChatRoom( roomName ); final TranscriptWindow transcriptWindow = room.getTranscriptWindow(); for ( final EntityBareJid jid : (Set<EntityBareJid>) getValue() ) { final String notification = Res.getString( "message.waiting.for.user.to.join", jid ); transcriptWindow.insertNotificationMessage( notification, ChatManager.NOTIFICATION_COLOR ); } } catch ( ChatRoomNotFoundException e ) { Log.error( "Unable to identify chat room tab by name: " + roomName ); } } }
/** * Displays the Serverbroadcast like all other messages * in its on chatcontainer with transcript history * @param message * @param from */ private void broadcastInChat(Message message) { String from = message.getFrom() != null ? message.getFrom().toString() : ""; ChatManager chatManager = SparkManager.getChatManager(); ChatContainer container = chatManager.getChatContainer(); ChatRoomImpl chatRoom; try { chatRoom = (ChatRoomImpl)container.getChatRoom(from); } catch (ChatRoomNotFoundException e) { String windowtitle = message.getSubject()!=null ? message.getSubject() : Res.getString("administrator"); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked("serveralert@" + from); Resourcepart resourcepart = Resourcepart.fromOrThrowUnchecked(Res.getString("broadcast")); chatRoom = new ChatRoomImpl(jid, resourcepart, windowtitle); chatRoom.getBottomPanel().setVisible(false); chatRoom.hideToolbar(); SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom); } chatRoom.getTranscriptWindow().insertNotificationMessage(message.getBody(), ChatManager.NOTIFICATION_COLOR); broadcastRooms.add(chatRoom); }
ChatRoom chatRoom; try { chatRoom = getChatContainer().getChatRoom(jid);
protected void startChat(ChatRoom groupChat, EntityFullJid groupJID) { Resourcepart userNickname = groupJID.getResourcepart(); String roomTitle = userNickname + " - " + groupChat.getRoomJid(); // TODO: Remove duplicate variable userNickname and nicknameOfUser. Resourcepart nicknameOfUser = userNickname; Resourcepart nickname = groupChat.getNickname(); if (nicknameOfUser.equals(nickname)) { return; } ChatRoom chatRoom; try { chatRoom = chatManager.getChatContainer().getChatRoom(groupJID); } catch (ChatRoomNotFoundException e) { Log.debug("Could not find chat room - " + groupJID); // Create new room chatRoom = new ChatRoomImpl(groupJID.asEntityBareJid(), nicknameOfUser, roomTitle); chatManager.getChatContainer().addChatRoom(chatRoom); } chatManager.getChatContainer().activateChatRoom(chatRoom); }
ChatRoom chatRoom; try { chatRoom = getChatRoom(roomname);
room = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID);
chatManager.getChatContainer().getChatRoom(room.getRoomname());
try { room = SparkManager.getChatManager().getChatContainer() .getChatRoom(bareJID); } catch (ChatRoomNotFoundException e) {