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); }
setMinimumSize(new Dimension(400, 200)); enableDragAndDrop(); addChatRoomListener(new GroupChatRoomListener()); addSparkTabbedPaneListener(new SparkTabbedPaneListener() { public void tabRemoved(SparkTab tab, Component component, int index) { stateChanged(null); setCloseButtonEnabled(true); addKeyNavigation(); this.setFocusable(false); setOpaque(true); setBackground(Color.white);
chatManager.getChatContainer().addContainerComponent(this);
/** * Closes a tab of a room. * * @param component the component inside of the tab to close. */ public void closeTab(Component component) { int location = indexOfComponent(component); if (location == -1) { return; } if (getTabCount() == 0) { chatFrame.setTitle(""); } this.close(this.getTabAt(location)); }
public void finished() { if (chatRoom == null) { chatRoom = UIComponentRegistry.createChatRoom(jid, nickname, nickname); chatManager.getChatContainer().addChatRoom(chatRoom); } chatManager.getChatContainer().activateChatRoom(chatRoom); } };
createFrameIfNeeded(); StanzaListener myListener = stanza -> SwingUtilities.invokeLater( () -> handleRoomPresence((Presence)stanza) ); SparkTab tab = addTab(room.getTabTitle(), room.getTabIcon(), room, tooltip); tab.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { final String title = getTabAt(0).getActualText(); if (title.equals(WELCOME_TITLE)) { chatFrame.setTitle(room.getRoomTitle()); fireChatRoomOpened(room); focusChat();
public void addContainerComponent(ContainerComponent comp) { createFrameIfNeeded(); addTab(comp.getTabTitle(), comp.getTabIcon(), comp.getGUI(), comp.getToolTipDescription()); chatFrame.setTitle(comp.getFrameTitle()); checkVisibility(comp.getGUI()); if (getSelectedComponent() != comp) { // Notify Decorators SparkManager.getChatManager().notifySparkTabHandlers(comp.getGUI()); } }
/** * 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; }
ConferenceUtils.changePresenceToAvailableIfInvisible(); final ChatContainer container = SparkManager.getChatManager().getChatContainer(); if ( !container.getChatRooms().contains( room ) ) container.addChatRoom( room ); container.activateChatRoom( room );
try { room = SparkManager.getChatManager().getChatContainer() .getChatRoom(bareJID); } catch (ChatRoomNotFoundException e) { .getChatFrame(); if (chatFrame != null) { if (SettingsManager.getLocalPreferences().isBuzzEnabled()) { chatFrame.buzz(); SparkManager.getChatManager().getChatContainer() .activateChatRoom(room);
SparkManager.getChatManager().getChatContainer().getChatRoom(room.getRoom()); return; } catch (ChatRoomNotFoundException e) { ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); .fireNotifyOnMessage(chatRoom, true, message1, title); } catch (ChatRoomNotFoundException e) { groupChatRoom.setTabTitle(roomName); groupChatRoom.getToolBar().setVisible(true); SparkManager.getChatManager().getChatContainer().addChatRoom(groupChatRoom); groupChatRoom.getTranscriptWindow().addComponent(invitationUI); SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(groupChatRoom, true, message1, title);
@Override public void filesDropped(Collection<File> files, Component component) { if (component instanceof ChatRoomImpl) { ChatRoomImpl roomImpl = (ChatRoomImpl) component; for (File file : files) { SparkManager.getTransferManager().sendFile(file, roomImpl.getParticipantJID()); } SparkManager.getChatManager().getChatContainer() .activateChatRoom(roomImpl); } }
final int index = indexOfComponent(comp); if (index != -1) { if (((GroupChatRoom) comp).getLastMessage() != null) if (!((GroupChatRoom) comp).isBlocked(((GroupChatRoom) comp).getLastMessage().getFrom())) checkNotificationPreferences((ChatRoom) comp,customMsg,customMsgText,customMsgTitle); } else { checkNotificationPreferences((ChatRoom) comp, customMsg,customMsgText, customMsgTitle);
/** * Used to listen for rooms opening, closing or being * activated( already opened, but tabbed to ) * * @param listener the ChatRoomListener to add */ public void addChatRoomListener(ChatRoomListener listener) { getChatContainer().addChatRoomListener(listener); }
/** * Creates a new public Conference Room. * * @param roomName the name of the room. * @param serviceName the service name to use (ex.conference.jivesoftware.com) * @return the new ChatRoom created. If an error occured, null will be returned. */ public ChatRoom createConferenceRoom(Localpart roomName, DomainBareJid serviceName) { EntityBareJid roomAddress = JidCreate.entityBareFrom(roomName, serviceName); final MultiUserChat chatRoom = MultiUserChatManager.getInstanceFor( SparkManager.getConnection()).getMultiUserChat( roomAddress); final GroupChatRoom room = UIComponentRegistry.createGroupChatRoom(chatRoom); try { LocalPreferences pref = SettingsManager.getLocalPreferences(); Resourcepart nickname = pref.getNickname(); chatRoom.create(nickname); // Send an empty room configuration form which indicates that we want // an instant room chatRoom.sendConfigurationForm(new Form( DataForm.Type.submit )); } catch (XMPPException | SmackException | InterruptedException e1) { Log.error("Unable to send conference room chat configuration form.", e1); return null; } getChatContainer().addChatRoom(room); return room; }
ChatRoom chatRoom; try { chatRoom = getChatContainer().getChatRoom(jid); getChatContainer().addChatRoom(chatRoom);
chatManager.getChatContainer().addChatRoom(room); chatManager.getChatContainer().activateChatRoom(room);
public void finished() { ChatRoomImpl roomImpl = (ChatRoomImpl)room; sendFile(imageFile, roomImpl.getParticipantJID()); SparkManager.getChatManager().getChatContainer().activateChatRoom(room); room.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } };
chatManager.getChatContainer().getChatRoom(room.getRoomname()); chatManager.getChatContainer().addChatRoom(room); chatManager.getChatContainer().activateChatRoom(room);
/** * 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); }