⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nonrosterpanel.java.svn-base

📁 开源项目openfire的完整源程序
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
            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);
            }
        });

        redialButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                manager.getDefaultGuiManager().dial(activeCall.getCall().getNumber());
                redialButton.setVisible(false);
                hangUpButton.setVisible(true);
            }
        });
    }


    /**
     * Called when a new call is established.
     */
    private void callStarted() {
        redialButton.setVisible(false);
        hangUpButton.setVisible(true);
        hangUpButton.setEnabled(true);
        muteButton.setEnabled(true);
        holdButton.setEnabled(true);
        transferButton.setEnabled(true);
        setStatus(CONNECTED, false);

        // Show History
        historyPanel.removeAll();
        historyPanel.addPreviousConversations(phoneNumber);

        // Add notification to ChatRoom if one exists.
        final ChatRoom chatRoom = callManager.getAssociatedChatRoom(this);
        if (chatRoom != null) {
            final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
            String time = formatter.format(new Date());

            chatRoom.getTranscriptWindow().insertNotificationMessage(PhoneRes.getIString("phone.callstartedat")+ " " + time, ChatManager.NOTIFICATION_COLOR);
        }
    }

    /**
     * Called when the call is ended. This does basic container cleanup.
     */
    public void callEnded() {
        if (!callWasTransferred) {
            historyPanel.callEnded();
            setStatus(PhoneRes.getIString("phone.callended"), new Color(211, 0, 0));
        }

        hangUpButton.setVisible(false);
        redialButton.setVisible(true);
        muteButton.setEnabled(false);
        holdButton.setEnabled(false);
        transferButton.setEnabled(false);

        // Add notification to ChatRoom if one exists.
        final ChatRoom chatRoom = callManager.getAssociatedChatRoom(this);
        if (chatRoom != null) {
            final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
            String time = formatter.format(new Date());

            chatRoom.getTranscriptWindow().insertNotificationMessage(PhoneRes.getIString("phone.callendedat")+" " + time, ChatManager.NOTIFICATION_COLOR);
        }


        changeState(CallRoomState.callWasEnded);
    }

    private void setStatus(String status, boolean alert) {
        if (alert) {
            connectedLabel.setForeground(orangeColor);
        }
        else {
            connectedLabel.setForeground(greenColor);
        }
        connectedLabel.setText(status);
    }

    private void setStatus(String status, Color color) {
        connectedLabel.setForeground(color);
        connectedLabel.setText(status);
    }


    private void toggleMute() {
        if (onHold) {
            toggleHold();
        }

        if (muted) {
            muted = false;
            muteButton.setToolTipText(PhoneRes.getIString("phone.mute"));
            muteButton.setButtonSelected(false);
            setStatus(CONNECTED, false);

            // Change the state.
            changeState(CallRoomState.inCall);
        }
        else {
            muted = true;
            muteButton.setToolTipText(PhoneRes.getIString("phone.unmute"));
            muteButton.setButtonSelected(true);
            setStatus("Muted", true);

            // Change the state.
            changeState(CallRoomState.muted);
        }

        muteButton.invalidate();
        muteButton.validate();
        muteButton.repaint();
        softPhone.getDefaultGuiManager().mute(activeCall, !muted);
    }


    private void toggleHold() {
        if (muted) {
            toggleMute();
        }

        if (onHold) {
            onHold = false;
            holdButton.setToolTipText(PhoneRes.getIString("phone.hold"));
            holdButton.setButtonSelected(false);
            setStatus(CONNECTED, false);

            // Change the state.
            changeState(CallRoomState.inCall);
        }
        else {
            onHold = true;
            holdButton.setButtonSelected(true);
            holdButton.setToolTipText("Unhold");
            setStatus(PhoneRes.getIString("phone.onhold"), true);

            // Change the state.
            changeState(CallRoomState.onHold);
        }

        softPhone.getDefaultGuiManager().hold(activeCall);
    }

    public void actionPerformed(ActionEvent e) {

    }

    public String getTabTitle() {
        return TelephoneUtils.formatPattern(phoneNumber,PhoneRes.getIString("phone.numpattern"));
    }

    public String getFrameTitle() {
        if (activeCall.getCallState() == Call.CONNECTED) {
            return PhoneRes.getIString("phone.onphonewith")+" " + TelephoneUtils.formatPattern(phoneNumber,PhoneRes.getIString("phone.numpattern"));
        }
        else {
            return PhoneRes.getIString("phone.callendedwith")+" " + TelephoneUtils.formatPattern(phoneNumber,PhoneRes.getIString("phone.numpattern"));
        }

    }

    public ImageIcon getTabIcon() {
        return PhoneRes.getImageIcon("RECEIVER2_IMAGE");
    }

    public JComponent getGUI() {
        return this;
    }

    public String getToolTipDescription() {
        return phoneNumber;
    }

    public boolean closing() {
        return true;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void paintComponent(Graphics g) {
        BufferedImage cache = new BufferedImage(2, getHeight(), BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = cache.createGraphics();

        GradientPaint paint = new GradientPaint(0, 0, new Color(241, 245, 250), 0, getHeight(), new Color(244, 250, 255), true);

        g2d.setPaint(paint);
        g2d.fillRect(0, 0, getWidth(), getHeight());
        g2d.dispose();

        g.drawImage(cache, 0, 0, getWidth(), getHeight(), null);
    }


    public Dimension getPreferredSize() {
        Dimension dim = super.getPreferredSize();
        dim.width = 0;
        return dim;
    }

    public InterlocutorUI getActiveCall() {
        return activeCall;
    }

    private void changeState(CallRoomState state) {
        softPhone.addCallSession(this, state);
        SparkManager.getChatManager().notifySparkTabHandlers(this);
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -