Search in sources :

Example 1 with SwingWorker

use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.

the class NonRosterPanel method setupDefaults.

public void setupDefaults() {
    holdButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            toggleHold();
        }
    });
    muteButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            toggleMute();
        }
    });
    transferButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            TransferManager ui = new TransferManager();
            final String number = ui.getNumber(SparkManager.getChatManager().getChatContainer().getChatFrame());
            if (ModelUtil.hasLength(number)) {
                setStatus(PhoneRes.getIString("phone.transferring") + "...", blueColor);
                historyPanel.transferring();
                SwingWorker transferringThread = new SwingWorker() {

                    public Object construct() {
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return true;
                    }

                    public void finished() {
                        setStatus(PhoneRes.getIString("phone.transfered"), blueColor);
                        historyPanel.transfer(number);
                        callWasTransferred = true;
                        softPhone.handleTransfer(getActiveCall().getID(), number);
                        callEnded();
                    }
                };
                transferringThread.start();
            }
        }
    });
    final SoftPhoneManager manager = SoftPhoneManager.getInstance();
    hangUpButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            manager.getDefaultGuiManager().hangup(activeCall);
            hangUpButton.setEnabled(false);
            muteButton.setButtonSelected(false);
            holdButton.setButtonSelected(false);
        }
    });
    redialButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            manager.getDefaultGuiManager().dial(activeCall.getCall().getNumber());
            redialButton.setVisible(false);
            hangUpButton.setVisible(true);
        }
    });
}
Also used : TransferManager(org.jivesoftware.sparkplugin.ui.transfer.TransferManager) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) SoftPhoneManager(net.java.sipmack.softphone.SoftPhoneManager) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Example 2 with SwingWorker

use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.

the class RosterMemberPanel method setupDefaults.

public void setupDefaults() {
    holdButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            toggleHold();
        }
    });
    muteButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            toggleMute();
        }
    });
    transferButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent mouseEvent) {
            TransferManager ui = new TransferManager();
            final String number = ui.getNumber(SparkManager.getChatManager().getChatContainer().getChatFrame());
            if (ModelUtil.hasLength(number)) {
                setStatus("Transferring...", blueColor);
                historyPanel.transferring();
                SwingWorker transferringThread = new SwingWorker() {

                    public Object construct() {
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return true;
                    }

                    public void finished() {
                        setStatus("Transferred", blueColor);
                        historyPanel.transfer(number);
                        callWasTransferred = true;
                        softPhone.handleTransfer(getActiveCall().getID(), number);
                        callEnded();
                    }
                };
                transferringThread.start();
            }
        }
    });
    final SoftPhoneManager manager = SoftPhoneManager.getInstance();
    hangUpButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            manager.getDefaultGuiManager().hangup(activeCall);
            hangUpButton.setEnabled(false);
        }
    });
}
Also used : TransferManager(org.jivesoftware.sparkplugin.ui.transfer.TransferManager) MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) SoftPhoneManager(net.java.sipmack.softphone.SoftPhoneManager) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Example 3 with SwingWorker

use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.

the class CallManager method interlocutorRemoved.

public void interlocutorRemoved(final InterlocutorUI interlocutorUI) {
    if (softPhone.getInterlocutors().size() == 0) {
        if (offPhonePresence == null) {
            // Set user to available when all phone calls are hung up.
            Presence availablePresence = new Presence(Presence.Type.available, "Online", 1, Presence.Mode.available);
            SparkManager.getSessionManager().changePresence(availablePresence);
        } else {
            // Set user presence to last one choosed
            SparkManager.getSessionManager().changePresence(offPhonePresence);
        }
        offPhonePresence = null;
    }
    final SwingWorker delay = new SwingWorker() {

        public Object construct() {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return true;
        }

        public void finished() {
            String phoneNumber = interlocutorUI.getCall().getNumber();
            phoneNumber = SoftPhoneManager.getNumbersFromPhone(phoneNumber);
            final PhonePanel phonePanel = calls.get(phoneNumber);
            if (phonePanel == null) {
                return;
            }
            for (ChatRoom room : SparkManager.getChatManager().getChatContainer().getChatRooms()) {
                Component comp = room.getSplitPane().getRightComponent();
                if (comp != null && comp instanceof PhonePanel) {
                    final PhonePanel cp = (PhonePanel) comp;
                    if (cp == phonePanel) {
                        room.getSplitPane().setRightComponent(null);
                        removePhonePanel(cp);
                        // Remove state mapping
                        softPhone.removeCallSession(room);
                        SparkManager.getChatManager().notifySparkTabHandlers(room);
                    }
                    return;
                }
            }
        }
    };
    delay.start();
}
Also used : ChatRoom(org.jivesoftware.spark.ui.ChatRoom) Presence(org.jivesoftware.smack.packet.Presence) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Example 4 with SwingWorker

use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.

the class SoftPhonePlugin method initialize.

/**
 * Called after Spark is loaded to initialize the new plugin. Load
 * Configuration from VCard and Instantiate a SoftPhoneManager
 */
public void initialize() {
    final SwingWorker initializeThread = new SwingWorker() {

        public Object construct() {
            PhoneManager.getInstance();
            softPhone = SoftPhoneManager.getInstance();
            return true;
        }

        public void finished() {
            if (softPhone.isPhoneEnabled()) {
                // Add TabHandler
                SparkManager.getChatManager().addSparkTabHandler(new SoftPhoneTabHandler());
                initializeUI();
            }
            SipCodecsPreference preference = new SipCodecsPreference();
            SparkManager.getPreferenceManager().addPreference(preference);
            preference.load();
        }
    };
    initializeThread.start();
}
Also used : SipCodecsPreference(org.jivesoftware.sparkplugin.preferences.SipCodecsPreference) SoftPhoneTabHandler(org.jivesoftware.sparkplugin.ui.call.SoftPhoneTabHandler) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Example 5 with SwingWorker

use of org.jivesoftware.spark.util.SwingWorker in project Spark by igniterealtime.

the class JoinConferenceRoomDialog method joinRoom.

public void joinRoom(final String roomJID, final String roomName) {
    final LocalPreferences pref = SettingsManager.getLocalPreferences();
    // Set default nickname
    nicknameField.setText(pref.getNickname());
    // Enable password field if a password is required
    passwordField.setVisible(false);
    passwordLabel.setVisible(false);
    roomNameDescription.setText(roomName);
    final JOptionPane pane;
    TitlePanel titlePanel;
    // Create the title panel for this dialog
    titlePanel = new TitlePanel(Res.getString("title.join.conference.room"), Res.getString("message.specify.information.for.conference"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), true);
    // Construct main panel w/ layout.
    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);
    // The user should only be able to close this dialog.
    Object[] options = { Res.getString("join"), Res.getString("cancel") };
    pane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
    mainPanel.add(pane, BorderLayout.CENTER);
    final JOptionPane p = new JOptionPane();
    final JDialog dlg = p.createDialog(SparkManager.getMainWindow(), Res.getString("title.conference.rooms"));
    dlg.setModal(false);
    dlg.pack();
    dlg.setSize(350, 250);
    dlg.setResizable(true);
    dlg.setContentPane(mainPanel);
    dlg.setLocationRelativeTo(SparkManager.getMainWindow());
    PropertyChangeListener changeListener = e -> {
        String value = (String) pane.getValue();
        if (Res.getString("cancel").equals(value)) {
            pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
            dlg.dispose();
        } else if (Res.getString("join").equals(value)) {
            pane.setValue(JOptionPane.UNINITIALIZED_VALUE);
            dlg.dispose();
            ConferenceUtils.joinConferenceOnSeperateThread(roomName, roomJID, null);
        }
    };
    pane.addPropertyChangeListener(changeListener);
    dlg.setVisible(true);
    dlg.toFront();
    dlg.requestFocus();
    SwingWorker worker = new SwingWorker() {

        boolean requiresPassword;

        public Object construct() {
            requiresPassword = ConferenceUtils.isPasswordRequired(roomJID);
            return requiresPassword;
        }

        public void finished() {
            passwordField.setVisible(requiresPassword);
            passwordLabel.setVisible(requiresPassword);
        }
    };
    worker.start();
}
Also used : Insets(java.awt.Insets) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) JDialog(javax.swing.JDialog) JTextField(javax.swing.JTextField) SparkRes(org.jivesoftware.resource.SparkRes) SettingsManager(org.jivesoftware.sparkimpl.settings.local.SettingsManager) Res(org.jivesoftware.resource.Res) SwingWorker(org.jivesoftware.spark.util.SwingWorker) GridBagConstraints(java.awt.GridBagConstraints) JOptionPane(javax.swing.JOptionPane) TitlePanel(org.jivesoftware.spark.component.TitlePanel) ResourceUtils(org.jivesoftware.spark.util.ResourceUtils) JPasswordField(javax.swing.JPasswordField) PropertyChangeListener(java.beans.PropertyChangeListener) SparkManager(org.jivesoftware.spark.SparkManager) JLabel(javax.swing.JLabel) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) PropertyChangeListener(java.beans.PropertyChangeListener) SwingWorker(org.jivesoftware.spark.util.SwingWorker) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) JOptionPane(javax.swing.JOptionPane) TitlePanel(org.jivesoftware.spark.component.TitlePanel) JDialog(javax.swing.JDialog)

Aggregations

SwingWorker (org.jivesoftware.spark.util.SwingWorker)65 SmackException (org.jivesoftware.smack.SmackException)22 XMPPException (org.jivesoftware.smack.XMPPException)15 Presence (org.jivesoftware.smack.packet.Presence)11 MouseAdapter (java.awt.event.MouseAdapter)8 MouseEvent (java.awt.event.MouseEvent)8 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)8 ActionEvent (java.awt.event.ActionEvent)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 GridBagConstraints (java.awt.GridBagConstraints)6 Insets (java.awt.Insets)6 Collection (java.util.Collection)6 JLabel (javax.swing.JLabel)6 JPanel (javax.swing.JPanel)5 ContactItem (org.jivesoftware.spark.ui.ContactItem)5 Action (javax.swing.Action)4 Cursor (java.awt.Cursor)3 ActionListener (java.awt.event.ActionListener)3 File (java.io.File)3