Search in sources :

Example 1 with RoomState

use of org.jivesoftware.fastpath.workspace.Workpane.RoomState 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;
}
Also used : ChatRoom(org.jivesoftware.spark.ui.ChatRoom) RoomState(org.jivesoftware.fastpath.workspace.Workpane.RoomState)

Example 2 with RoomState

use of org.jivesoftware.fastpath.workspace.Workpane.RoomState in project Spark by igniterealtime.

the class FastpathTabHandler method handleFastpathRoom.

private void handleFastpathRoom(SparkTab tab, ChatRoom room, boolean isSelectedTab, boolean chatFrameFocused) {
    RoomState roomState = FastpathPlugin.getLitWorkspace().getRoomState(room);
    boolean isTyping = SparkManager.getChatManager().containsTypingNotification(room);
    // Check if is typing.
    if (isTyping) {
        tab.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
    } else {
        tab.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_16x16));
    }
    if (!chatFrameFocused || !isSelectedTab) {
        if (room.getUnreadMessageCount() > 0 || RoomState.incomingRequest == roomState || RoomState.invitationRequest == roomState) {
            // Make tab red.
            tab.setTitleColor(Color.red);
            tab.setTabBold(true);
        }
        // Handle unread message count.
        int unreadMessageCount = room.getUnreadMessageCount();
        String appendedMessage = "";
        if (unreadMessageCount > 1) {
            appendedMessage = " (" + unreadMessageCount + ")";
        }
        tab.setTabTitle(room.getTabTitle() + appendedMessage);
    }
    // and the tab is the selected component.
    if (isSelectedTab && chatFrameFocused) {
        tab.setTitleColor(Color.black);
        tab.setTabFont(tab.getDefaultFont());
        tab.setTabTitle(room.getTabTitle());
        // Clear unread message count.
        room.clearUnreadMessageCount();
    }
}
Also used : RoomState(org.jivesoftware.fastpath.workspace.Workpane.RoomState)

Aggregations

RoomState (org.jivesoftware.fastpath.workspace.Workpane.RoomState)2 ChatRoom (org.jivesoftware.spark.ui.ChatRoom)1