Search in sources :

Example 1 with SparkToaster

use of org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster in project Spark by igniterealtime.

the class CallManager method showIncomingCall.

private void showIncomingCall(final InterlocutorUI ic) {
    try {
        EventQueue.invokeAndWait(new Runnable() {

            public void run() {
                final SparkToaster toasterManager = new SparkToaster();
                toasters.put(ic, toasterManager);
                final IncomingCallUI incomingCall = new IncomingCallUI(ic);
                toasterManager.setToasterHeight(230);
                toasterManager.setToasterWidth(300);
                toasterManager.setDisplayTime(500000000);
                toasterManager.showToaster(PhoneRes.getIString("phone.incomingcall"), incomingCall);
                toasterManager.hideTitle();
                toasterManager.setHidable(false);
                incomingCall.getAcceptButton().addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        SparkManager.getMainWindow().toFront();
                        closeToaster(ic);
                        SoftPhoneManager.getInstance().getDefaultGuiManager().answer();
                    }
                });
                incomingCall.getRejectButton().addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        closeToaster(ic);
                        SoftPhoneManager.getInstance().getDefaultGuiManager().hangup(ic);
                    }
                });
            }
        });
    } catch (Exception e) {
        Log.error(e);
    }
}
Also used : SparkToaster(org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 2 with SparkToaster

use of org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster in project Spark by igniterealtime.

the class CallManager method closeToaster.

private void closeToaster(InterlocutorUI ic) {
    SparkToaster toaster = toasters.get(ic);
    if (toaster != null) {
        toaster.close();
        toasters.remove(ic);
    }
}
Also used : SparkToaster(org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster)

Example 3 with SparkToaster

use of org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster in project Spark by igniterealtime.

the class ConferenceServices method showToaster.

private void showToaster(String message, String title, GroupChatRoom groupChatRoom) {
    if (_localPreferences.getShowToasterPopup()) {
        SparkToaster toaster = new SparkToaster();
        toaster.setCustomAction(new AbstractAction() {

            private static final long serialVersionUID = -4546475740161533555L;

            @Override
            public void actionPerformed(ActionEvent e) {
                ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
                chatFrame.setState(Frame.NORMAL);
                chatFrame.setVisible(true);
            }
        });
        toaster.setDisplayTime(5000);
        toaster.setBorder(BorderFactory.createBevelBorder(0));
        toaster.setToasterHeight(150);
        toaster.setToasterWidth(200);
        toaster.setTitle(title);
        toaster.showToaster(groupChatRoom.getTabIcon(), message);
    }
}
Also used : SparkToaster(org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster) ActionEvent(java.awt.event.ActionEvent)

Example 4 with SparkToaster

use of org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster in project Spark by igniterealtime.

the class PhonePlugin method displayRingUI.

private void displayRingUI(RingEvent event) {
    IncomingCall incomingCall = new IncomingCall();
    boolean idExists = false;
    if (ModelUtil.hasLength(event.getCallerIDName())) {
        incomingCall.setCallerName(event.getCallerIDName());
        idExists = true;
    }
    if (ModelUtil.hasLength(event.getCallerID())) {
        incomingCall.setCallerNumber(event.getCallerID());
        idExists = true;
    }
    if (!idExists) {
        incomingCall.setCallerName(Res.getString("message.no.caller.id"));
    }
    if (!SettingsManager.getLocalPreferences().getDisableAsteriskToasterPopup()) {
        SparkToaster toasterManager = new SparkToaster();
        toasterManager.setTitle("Incoming Phone Call");
        toasterManager.setDisplayTime(15000);
        toasterManager.showToaster(SparkRes.getImageIcon(SparkRes.ON_PHONE_IMAGE));
        toasterManager.setComponent(incomingCall);
    }
}
Also used : SparkToaster(org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster)

Example 5 with SparkToaster

use of org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster in project Spark by igniterealtime.

the class NotificationPlugin method notifyUserOnline.

/**
 * Notify client that a user has come online.
 *
 * @param jid the jid of the user that has come online.
 * @param presence Presence of the online user.
 */
private void notifyUserOnline(final String jid, final Presence presence) {
    try {
        EventQueue.invokeAndWait(() -> {
            SparkToaster toaster = new SparkToaster();
            toaster.setDisplayTime(preferences.getNotificationsDisplayTime());
            toaster.setBorder(BorderFactory.createBevelBorder(0));
            toaster.setCustomAction(new ChatAction(jid));
            NotificationAlertUI alertUI = new NotificationAlertUI(jid, true, presence);
            toaster.setToasterHeight((int) alertUI.getPreferredSize().getHeight() + 40);
            int width = (int) alertUI.getPreferredSize().getWidth() + 40;
            if (width < 300) {
                width = 300;
            }
            toaster.setToasterWidth(width);
            toaster.showToaster(alertUI.topLabel.getText(), alertUI);
            toaster.setTitleAlert(new Font("Dialog", Font.BOLD, 13), presence);
        });
    } catch (Exception ex) {
        Log.error(ex);
    }
}
Also used : SparkToaster(org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster) Font(java.awt.Font)

Aggregations

SparkToaster (org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster)12 ActionEvent (java.awt.event.ActionEvent)4 Date (java.util.Date)3 Font (java.awt.Font)2 ActionListener (java.awt.event.ActionListener)2 TimerTask (java.util.TimerTask)2 MouseEvent (java.awt.event.MouseEvent)1 ArrayList (java.util.ArrayList)1 AbstractAction (javax.swing.AbstractAction)1 Action (javax.swing.Action)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JPopupMenu (javax.swing.JPopupMenu)1 JScrollPane (javax.swing.JScrollPane)1 StanzaTypeFilter (org.jivesoftware.smack.filter.StanzaTypeFilter)1 Message (org.jivesoftware.smack.packet.Message)1 Presence (org.jivesoftware.smack.packet.Presence)1 VCard (org.jivesoftware.smackx.vcardtemp.packet.VCard)1 VerticalFlowLayout (org.jivesoftware.spark.component.VerticalFlowLayout)1 ContextMenuListener (org.jivesoftware.spark.plugin.ContextMenuListener)1