Search in sources :

Example 16 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class Workpane method decorateRoom.

public void decorateRoom(ChatRoom room, Map metadata) {
    String roomName = room.getRoomname();
    String sessionID = XmppStringUtils.parseLocalpart(roomName);
    RequestUtils utils = new RequestUtils(metadata);
    addRoomInfo(sessionID, utils, room);
    addButtons(sessionID, utils, room);
    // Specify to use Typing notifications.
    GroupChatRoom groupChat = (GroupChatRoom) room;
    groupChat.setChatStatEnabled(true);
    Properties props = FastpathPlugin.getLitWorkspace().getWorkgroupProperties();
    String initialResponse = props.getProperty(INITIAL_RESPONSE_PROPERTY);
    if (ModelUtil.hasLength(initialResponse)) {
        Message message = new Message();
        message.setBody(initialResponse);
        GroupChatRoom groupChatRoom = (GroupChatRoom) room;
        groupChatRoom.sendMessage(message);
    }
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) Message(org.jivesoftware.smack.packet.Message) RequestUtils(org.jivesoftware.fastpath.workspace.util.RequestUtils)

Example 17 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class Workpane method addRoomInfo.

private void addRoomInfo(final String sessionID, final RequestUtils utils, final ChatRoom room) {
    final JTabbedPane tabbedPane = new JTabbedPane();
    GroupChatParticipantList participantList = ((GroupChatRoom) room).getConferenceRoomInfo();
    room.getSplitPane().setRightComponent(tabbedPane);
    Form form = null;
    try {
        form = FastpathPlugin.getWorkgroup().getWorkgroupForm();
    } catch (XMPPException | SmackException e) {
        Log.error(e);
        return;
    }
    final BackgroundPane transcriptAlert = new BackgroundPane() {

        public Dimension getPreferredSize() {
            final Dimension size = super.getPreferredSize();
            size.width = 0;
            return size;
        }
    };
    transcriptAlert.setLayout(new GridBagLayout());
    JLabel userImage = new JLabel(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_24x24));
    userImage.setHorizontalAlignment(JLabel.LEFT);
    userImage.setText(utils.getUsername());
    transcriptAlert.add(userImage, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    userImage.setFont(new Font("Dialog", Font.BOLD, 12));
    final RoomInformation roomInformation = new RoomInformation();
    roomInformation.showFormInformation(form, utils);
    final UserHistory userHistory = new UserHistory(utils.getUserID());
    final JScrollPane userScroll = new JScrollPane(roomInformation);
    final JScrollPane historyScroll = new JScrollPane(userHistory);
    historyScroll.getVerticalScrollBar().setBlockIncrement(50);
    historyScroll.getVerticalScrollBar().setUnitIncrement(20);
    tabbedPane.addTab(FpRes.getString("tab.user.info"), userScroll);
    tabbedPane.addTab(FpRes.getString("tab.participants"), participantList);
    tabbedPane.addTab(FpRes.getString("tab.user.history"), historyScroll);
    final Notes notes = new Notes(sessionID, room);
    tabbedPane.addTab(FpRes.getString("tab.notes"), notes);
    tabbedPane.addChangeListener(new ChangeListener() {

        boolean loaded;

        public void stateChanged(ChangeEvent e) {
            if (!loaded) {
                if (tabbedPane.getSelectedComponent() == historyScroll) {
                    userHistory.loadHistory();
                    loaded = true;
                }
            }
        }
    });
    final GroupChatRoom groupRoom = (GroupChatRoom) room;
    room.getTranscriptWindow().clear();
    final ChatFrame frame = SparkManager.getChatManager().getChatContainer().getChatFrame();
    if (frame != null) {
        int height = frame.getHeight();
        int width = frame.getWidth();
        if (height < 400) {
            height = 400;
        }
        if (width < 600) {
            width = 600;
        }
        frame.setSize(width, height);
        frame.validate();
        frame.repaint();
    }
    fireFastPathChatOpened(room, sessionID, utils, tabbedPane);
    DataManager.getInstance().setMetadataForRoom(room, utils.getMetadata());
}
Also used : GroupChatParticipantList(org.jivesoftware.spark.ui.conferences.GroupChatParticipantList) Form(org.jivesoftware.smackx.xdata.Form) SmackException(org.jivesoftware.smack.SmackException) GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) XMPPException(org.jivesoftware.smack.XMPPException)

Example 18 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class CoBrowser method send.

private void send(Message message) {
    GroupChatRoom groupChatRoom = (GroupChatRoom) chatRoom;
    try {
        message.setTo(groupChatRoom.getRoomname());
        message.setType(Message.Type.groupchat);
        MessageEventManager.addNotificationsRequests(message, true, true, true, true);
        groupChatRoom.getMultiUserChat().sendMessage(message);
    } catch (SmackException ex) {
        Log.error("Unable to send message in conference chat.", ex);
    }
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) SmackException(org.jivesoftware.smack.SmackException)

Aggregations

GroupChatRoom (org.jivesoftware.spark.ui.rooms.GroupChatRoom)18 SmackException (org.jivesoftware.smack.SmackException)8 XMPPException (org.jivesoftware.smack.XMPPException)6 MultiUserChat (org.jivesoftware.smackx.muc.MultiUserChat)6 Form (org.jivesoftware.smackx.xdata.Form)4 ArrayList (java.util.ArrayList)3 ChatManager (org.jivesoftware.spark.ChatManager)3 MultiUserChatManager (org.jivesoftware.smackx.muc.MultiUserChatManager)2 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)2 ChatNotFoundException (org.jivesoftware.spark.ChatNotFoundException)2 ChatRoom (org.jivesoftware.spark.ui.ChatRoom)2 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)2 BorderLayout (java.awt.BorderLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1