Search in sources :

Example 1 with RequestUtils

use of org.jivesoftware.fastpath.workspace.util.RequestUtils 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 2 with RequestUtils

use of org.jivesoftware.fastpath.workspace.util.RequestUtils in project Spark by igniterealtime.

the class Workpane method handleOfferInvite.

/**
 * Handles incoming invitations or transfers.
 *
 * @param offer the <code>Offer</code>
 */
public void handleOfferInvite(final Offer offer) {
    Map metadata = offer.getMetaData();
    String sessionID = offer.getSessionID();
    metadata.put("sessionID", sessionID);
    RequestUtils utils = new RequestUtils(metadata);
    inviteMap.put(sessionID, metadata);
    UserInvitationPane invitationPane = null;
    if (offer.getContent() instanceof InvitationRequest) {
        InvitationRequest request = (InvitationRequest) offer.getContent();
        invitationPane = new UserInvitationPane(offer, utils, request.getRoom(), request.getInviter(), request.getReason());
    } else if (offer.getContent() instanceof TransferRequest) {
        TransferRequest request = (TransferRequest) offer.getContent();
        invitationPane = new UserInvitationPane(offer, utils, request.getRoom(), request.getInviter(), request.getReason());
    }
    invitationPane.setAcceptListener(new UserInvitationPane.AcceptListener() {

        public void yesOption() {
            // Remove
            invitations.remove(offer.getSessionID());
        }

        public void noOption() {
            invitations.remove(offer.getSessionID());
        }
    });
    invitations.put(offer.getSessionID(), invitationPane);
}
Also used : RequestUtils(org.jivesoftware.fastpath.workspace.util.RequestUtils)

Example 3 with RequestUtils

use of org.jivesoftware.fastpath.workspace.util.RequestUtils in project Spark by igniterealtime.

the class CoBrowser method getStartLocation.

private String getStartLocation() {
    Map metadata = FastpathPlugin.getLitWorkspace().getMetadata(sessionID);
    RequestUtils utils = new RequestUtils(metadata);
    String location = utils.getRequestLocation();
    if (location == null) {
        location = "";
    }
    return location;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) RequestUtils(org.jivesoftware.fastpath.workspace.util.RequestUtils)

Example 4 with RequestUtils

use of org.jivesoftware.fastpath.workspace.util.RequestUtils in project Spark by igniterealtime.

the class RoomInformation method showAllInformation.

public void showAllInformation(Map map) {
    if (map == null) {
        map = new HashMap();
    }
    LiveTitlePane titlePanel = new LiveTitlePane(FpRes.getString("title.request.information"), FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_24x24));
    final RequestUtils utils = new RequestUtils(map);
    setLayout(new GridBagLayout());
    setBackground(Color.white);
    // add(titlePanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    Iterator<String> iter = map.keySet().iterator();
    int row = 1;
    while (iter.hasNext()) {
        String key = iter.next();
        String value = utils.getValue(key);
        JLabel nameLabel = new JLabel(key);
        nameLabel.setFont(new Font("Dialog", Font.BOLD, 12));
        WrappedLabel valueLabel = new WrappedLabel();
        valueLabel.setBackground(Color.white);
        valueLabel.setText(value);
        add(nameLabel, new GridBagConstraints(0, row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
        add(valueLabel, new GridBagConstraints(1, row, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
        row++;
    }
    add(new JLabel(""), new GridBagConstraints(1, row, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) HashMap(java.util.HashMap) JLabel(javax.swing.JLabel) WrappedLabel(org.jivesoftware.spark.component.WrappedLabel) LiveTitlePane(org.jivesoftware.fastpath.internal.LiveTitlePane) RequestUtils(org.jivesoftware.fastpath.workspace.util.RequestUtils) Font(java.awt.Font)

Example 5 with RequestUtils

use of org.jivesoftware.fastpath.workspace.util.RequestUtils in project Spark by igniterealtime.

the class ChatQueue method offerRecieved.

public void offerRecieved(Offer offer) {
    this.offer = offer;
    // Retrieve workgroup form
    Form form;
    try {
        form = FastpathPlugin.getWorkgroup().getWorkgroupForm();
    } catch (XMPPException | SmackException e) {
        Log.error("Unable to retrieve Workgroup form.", e);
        return;
    }
    final RequestUtils utils = new RequestUtils(offer.getMetaData());
    nameLabel.setText(FpRes.getString("message.incoming.chat.request", utils.getUsername()));
    nameLabel.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_16x16));
    Color linkColor = new Color(69, 92, 137);
    int count = 1;
    for (final FormField field : form.getFields()) {
        String variable = field.getVariable();
        String label = field.getLabel();
        if (label != null) {
            final JLabel nameLabel = new JLabel(label);
            nameLabel.setFont(new Font("Dialog", Font.BOLD, 11));
            String value = utils.getValue(variable);
            if (value == null) {
                value = "";
            }
            final WrappedLabel valueLabel = new WrappedLabel();
            valueLabel.setBackground(Color.white);
            valueLabel.setText(value);
            add(nameLabel, new GridBagConstraints(0, count, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
            add(valueLabel, new GridBagConstraints(1, count, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
            count++;
        }
    }
    add(progressBar, new GridBagConstraints(0, count, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 5, 5), 0, 0));
    count++;
    viewLabel = new LinkLabel(FpRes.getString("message.view.more.information"), null, linkColor, Color.red);
    add(viewLabel, new GridBagConstraints(0, count, 1, 1, 0.0, 1.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.setOpaque(false);
    buttonPanel.add(acceptButton);
    buttonPanel.add(declineButton);
    add(buttonPanel, new GridBagConstraints(1, count, 2, 1, 1.0, 1.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    viewLabel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            showInformation();
        }
    });
    final Date endTime = offer.getExpiresDate();
    Date now = new Date();
    long mill = endTime.getTime() - now.getTime();
    int seconds = (int) (mill / 1000);
    progressBar.setMaximum(seconds);
    progressBar.setValue(seconds);
    SwingWorker worker = new SwingWorker() {

        public Object construct() {
            while (true) {
                Date now = new Date();
                if (now.getTime() >= endTime.getTime()) {
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    Log.error(e);
                }
                progressBar.setValue(progressBar.getValue() - 1);
                progressBar.setStringPainted(true);
                int seconds = (int) (endTime.getTime() - now.getTime()) / 1000;
                if (seconds <= 60) {
                    String timeString = seconds + " " + FpRes.getString("seconds");
                    progressBar.setString(timeString);
                } else {
                    long difference = endTime.getTime() - now.getTime();
                    String timeString = ModelUtil.getTimeFromLong(difference);
                    progressBar.setString(timeString);
                }
            }
            return progressBar;
        }
    };
    worker.start();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) Form(org.jivesoftware.smackx.xdata.Form) SmackException(org.jivesoftware.smack.SmackException) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) RequestUtils(org.jivesoftware.fastpath.workspace.util.RequestUtils) Font(java.awt.Font) Date(java.util.Date) LinkLabel(org.jivesoftware.spark.component.LinkLabel) SwingWorker(org.jivesoftware.spark.util.SwingWorker) WrappedLabel(org.jivesoftware.spark.component.WrappedLabel) XMPPException(org.jivesoftware.smack.XMPPException) FormField(org.jivesoftware.smackx.xdata.FormField)

Aggregations

RequestUtils (org.jivesoftware.fastpath.workspace.util.RequestUtils)5 Font (java.awt.Font)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 HashMap (java.util.HashMap)2 JLabel (javax.swing.JLabel)2 WrappedLabel (org.jivesoftware.spark.component.WrappedLabel)2 Color (java.awt.Color)1 FlowLayout (java.awt.FlowLayout)1 GridBagLayout (java.awt.GridBagLayout)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 Date (java.util.Date)1 Map (java.util.Map)1 JPanel (javax.swing.JPanel)1 LiveTitlePane (org.jivesoftware.fastpath.internal.LiveTitlePane)1 SmackException (org.jivesoftware.smack.SmackException)1 XMPPException (org.jivesoftware.smack.XMPPException)1 Message (org.jivesoftware.smack.packet.Message)1 Form (org.jivesoftware.smackx.xdata.Form)1