Search in sources :

Example 1 with SoftPhoneManager

use of net.java.sipmack.softphone.SoftPhoneManager 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 SoftPhoneManager

use of net.java.sipmack.softphone.SoftPhoneManager 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 SoftPhoneManager

use of net.java.sipmack.softphone.SoftPhoneManager in project Spark by igniterealtime.

the class ContactDialControl method placeCall.

private void placeCall() {
    if (incomingCall) {
        SoftPhoneManager.getInstance().getDefaultGuiManager().answer();
        enableIt(false);
    } else {
        final SoftPhoneManager phoneManager = SoftPhoneManager.getInstance();
        if (phoneManager.getInterlocutors().size() > 0) {
            phoneManager.getDefaultGuiManager().hangupAll();
        } else {
            phoneManager.getDefaultGuiManager().dial(callField.getText());
        }
    }
}
Also used : SoftPhoneManager(net.java.sipmack.softphone.SoftPhoneManager)

Example 4 with SoftPhoneManager

use of net.java.sipmack.softphone.SoftPhoneManager in project Spark by igniterealtime.

the class PhonebookUI method init.

private void init() {
    this.removeAll();
    model = new DefaultTableModel() {

        private static final long serialVersionUID = -1231025049889503785L;

        public boolean isCellEditable(int i, int j) {
            return false;
        }
    };
    sorter = new TableRowSorter<TableModel>(model);
    table = new JTable(model);
    JPanel pbtn = new JPanel();
    JPanel psearch = new JPanel();
    tfsearch = new JTextField();
    JScrollPane scroll = new JScrollPane(table);
    table.setRowSorter(sorter);
    table.getTableHeader().setReorderingAllowed(false);
    btnAdd = new RolloverButton(PhoneRes.getIString("btn.add"));
    btnDel = new RolloverButton(PhoneRes.getIString("btn.del"));
    btnEdit = new RolloverButton(PhoneRes.getIString("btn.edit"));
    btnDial = new RolloverButton(PhoneRes.getIString("btn.dial"));
    // add icons
    btnAdd.setIcon(new ImageIcon(PhoneRes.getImage("ADDICON").getScaledInstance(iconwidth, iconheight, Image.SCALE_SMOOTH)));
    btnDel.setIcon(new ImageIcon(PhoneRes.getImage("DELICON").getScaledInstance(iconwidth, iconheight, Image.SCALE_SMOOTH)));
    btnEdit.setIcon(new ImageIcon(PhoneRes.getImage("EDITICON").getScaledInstance(iconwidth, iconheight, Image.SCALE_SMOOTH)));
    btnDial.setIcon(new ImageIcon(PhoneRes.getImage("DIALICON").getScaledInstance(iconwidth, iconheight, Image.SCALE_SMOOTH)));
    // add actionlisteners
    btnAdd.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            btnAddPerformed();
        }
    });
    btnDel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int[] selected = table.getSelectedRows();
            if (selected.length == 0) {
                JOptionPane.showMessageDialog(PhonebookUI.this, PhoneRes.getIString("book.noEntry"), PhoneRes.getIString("book.warning"), JOptionPane.WARNING_MESSAGE);
            }
            for (int select : selected) {
                if (select > -1) {
                    manager.deleteEntry(table.getValueAt(select, 0).toString(), table.getValueAt(select, 1).toString());
                    model.removeRow(sorter.convertRowIndexToModel(select));
                }
            }
            loadEntries();
        }
    });
    btnEdit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selected = table.getSelectedRow();
            if (selected > -1) {
                btnEditPerformed(table.getValueAt(selected, 0).toString(), table.getValueAt(selected, 1).toString());
            } else {
                JOptionPane.showMessageDialog(PhonebookUI.this, PhoneRes.getIString("book.noEntry"), PhoneRes.getIString("book.warning"), JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    btnDial.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selected = table.getSelectedRow();
            if (selected > -1) {
                final SoftPhoneManager phoneManager = SoftPhoneManager.getInstance();
                if (phoneManager.getInterlocutors().size() > 0) {
                    phoneManager.getDefaultGuiManager().hangupAll();
                } else {
                    phoneManager.getDefaultGuiManager().dial(table.getValueAt(selected, 1).toString());
                }
            } else {
                JOptionPane.showMessageDialog(PhonebookUI.this, PhoneRes.getIString("book.noEntry"), PhoneRes.getIString("book.warning"), JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    sorter.addRowSorterListener(new RowSorterListener() {

        public void sorterChanged(RowSorterEvent arg0) {
            TableRowSorter<?> rs = (TableRowSorter<?>) arg0.getSource();
            String temp = tfsearch.getText();
            if (model.getRowCount() > 0 && rs.getViewRowCount() < 1) {
                // nur wenn auch was drin steht, erkennen
                if (temp.length() > 0) {
                    tfsearch.setText(temp.substring(0, temp.length() - 1));
                }
                filterTable(tfsearch.getText());
            } else if (table.getRowCount() > 0) {
                table.setRowSelectionInterval(0, 0);
            }
        }
    });
    tfsearch.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent evt) {
            keyReleasedSuchFeld(evt);
            if (table.getRowCount() > 0) {
                table.setRowSelectionInterval(0, 0);
            }
        }
    });
    loadEntries();
    // add components to layout
    pbtn.setLayout(new BoxLayout(pbtn, BoxLayout.X_AXIS));
    pbtn.setBorder(new EmptyBorder(5, 5, 5, 5));
    pbtn.add(Box.createHorizontalGlue());
    pbtn.add(btnDial);
    pbtn.add(Box.createHorizontalStrut(5));
    pbtn.add(btnAdd);
    pbtn.add(Box.createHorizontalStrut(5));
    pbtn.add(btnEdit);
    pbtn.add(Box.createHorizontalStrut(5));
    pbtn.add(btnDel);
    pbtn.add(Box.createHorizontalGlue());
    psearch.setLayout(new BoxLayout(psearch, BoxLayout.X_AXIS));
    psearch.setBorder(new EmptyBorder(5, 5, 5, 5));
    psearch.add(new JLabel(PhoneRes.getIString("book.search") + ":"));
    psearch.add(tfsearch);
    this.setLayout(new BorderLayout());
    this.add(psearch, BorderLayout.NORTH);
    this.add(pbtn, BorderLayout.SOUTH);
    this.add(scroll, BorderLayout.CENTER);
    tfsearch.requestFocusInWindow();
    frame.setLayout(new BorderLayout());
    frame.add(this, BorderLayout.CENTER);
    frame.setTitle(PhoneRes.getIString("frame.title"));
    frame.setSize(new Dimension(400, 300));
    frame.setIconImage(SparkRes.getImageIcon(SparkRes.ADDRESS_BOOK_16x16).getImage());
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) ActionEvent(java.awt.event.ActionEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) KeyAdapter(java.awt.event.KeyAdapter) BoxLayout(javax.swing.BoxLayout) JTextField(javax.swing.JTextField) RolloverButton(org.jivesoftware.spark.component.RolloverButton) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) RowSorterListener(javax.swing.event.RowSorterListener) EmptyBorder(javax.swing.border.EmptyBorder) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) SoftPhoneManager(net.java.sipmack.softphone.SoftPhoneManager) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) RowSorterEvent(javax.swing.event.RowSorterEvent) TableModel(javax.swing.table.TableModel) DefaultTableModel(javax.swing.table.DefaultTableModel)

Aggregations

SoftPhoneManager (net.java.sipmack.softphone.SoftPhoneManager)4 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 SwingWorker (org.jivesoftware.spark.util.SwingWorker)2 TransferManager (org.jivesoftware.sparkplugin.ui.transfer.TransferManager)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 BoxLayout (javax.swing.BoxLayout)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextField (javax.swing.JTextField)1 EmptyBorder (javax.swing.border.EmptyBorder)1 RowSorterEvent (javax.swing.event.RowSorterEvent)1