use of org.jivesoftware.spark.ui.ChatRoom in project Spark by igniterealtime.
the class OnlineAgents method activateChat.
/**
* Activate a chat room with the selected user.
*/
private void activateChat(final String userJID, final String nickname) {
if (!ModelUtil.hasLength(userJID)) {
return;
}
SwingWorker worker = new SwingWorker() {
final ChatManager chatManager = SparkManager.getChatManager();
ChatRoom chatRoom;
public Object construct() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Log.error("Error in activate chat.", e);
}
ChatContainer chatRooms = chatManager.getChatContainer();
try {
chatRoom = chatRooms.getChatRoom(userJID);
} catch (ChatRoomNotFoundException e) {
Log.warning("Room not found for jid: " + userJID, e);
}
return chatRoom;
}
public void finished() {
if (chatRoom == null) {
chatRoom = new ChatRoomImpl(userJID, nickname, nickname);
chatManager.getChatContainer().addChatRoom(chatRoom);
}
chatManager.getChatContainer().activateChatRoom(chatRoom);
}
};
worker.start();
}
use of org.jivesoftware.spark.ui.ChatRoom in project Spark by igniterealtime.
the class ApplePlugin method handleIdle.
private void handleIdle() {
SparkManager.getMainWindow().addComponentListener(new ComponentListener() {
public void componentResized(ComponentEvent componentEvent) {
setActivity();
}
public void componentMoved(ComponentEvent componentEvent) {
setActivity();
}
public void componentShown(ComponentEvent componentEvent) {
setActivity();
}
public void componentHidden(ComponentEvent componentEvent) {
setActivity();
}
});
SparkManager.getChatManager().addChatRoomListener(new ChatRoomListenerAdapter() {
public void chatRoomOpened(ChatRoom room) {
if (!addedFrameListener) {
chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
chatFrame.addComponentListener(new ComponentListener() {
public void componentResized(ComponentEvent componentEvent) {
setActivity();
}
public void componentMoved(ComponentEvent componentEvent) {
setActivity();
}
public void componentShown(ComponentEvent componentEvent) {
setActivity();
}
public void componentHidden(ComponentEvent componentEvent) {
setActivity();
}
});
addedFrameListener = true;
}
setActivity();
}
public void chatRoomClosed(ChatRoom room) {
setActivity();
}
});
SparkManager.getSessionManager().addPresenceListener(new PresenceListener() {
public void presenceChanged(Presence presence) {
if (presence.isAvailable() && !presence.isAway()) {
lastActive = System.currentTimeMillis();
}
}
});
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
sparkIsIdle();
}
}, 10000, 10000);
lastActive = System.currentTimeMillis();
}
use of org.jivesoftware.spark.ui.ChatRoom in project Spark by igniterealtime.
the class FastpathTabHandler method isTabHandled.
public boolean isTabHandled(SparkTab tab, Component component, boolean isSelectedTab, boolean chatFrameFocused) {
if (component instanceof ChatRoom) {
RoomState roomState = FastpathPlugin.getLitWorkspace().getRoomState((ChatRoom) component);
if (roomState == null) {
// This is not a fastpath room.
return false;
}
// This is a fastpath room.
handleFastpathRoom(tab, (ChatRoom) component, isSelectedTab, chatFrameFocused);
return true;
}
return false;
}
use of org.jivesoftware.spark.ui.ChatRoom in project Spark by igniterealtime.
the class GrowlTalker method onClickCallback.
@Override
public void onClickCallback(GntpNotification notification) {
Log.debug("Callback clicked: " + notification);
final String jid = XmppStringUtils.parseBareJid((String) notification.getContext());
final ChatRoom room = SparkManager.getChatManager().getChatRoom(jid);
SparkManager.getChatManager().getChatContainer().activateChatRoom(room);
SparkManager.getChatManager().getChatContainer().requestFocusInWindow();
}
use of org.jivesoftware.spark.ui.ChatRoom in project Spark by igniterealtime.
the class AnswerFormDialog method sendAnswerForm.
/**
* Sends the Answer Form
* @param answer <u>must be an answer-form</u>
* @param chat
*/
private void sendAnswerForm(Form answer, MultiUserChat chat) {
ChatRoom room = SparkManager.getChatManager().getChatRoom(chat.getRoom());
for (String key : _map.keySet()) {
String value = getValueFromComponent(key);
answer.setAnswer(key, value);
}
try {
chat.sendRegistrationForm(answer);
String reg = Res.getString("message.groupchat.registered.member", chat.getRoom());
room.getTranscriptWindow().insertNotificationMessage(reg, ChatManager.NOTIFICATION_COLOR);
} catch (XMPPException | SmackException e) {
room.getTranscriptWindow().insertNotificationMessage(e.getMessage(), ChatManager.ERROR_COLOR);
}
}
Aggregations