rostermemberpanel.java.svn-base
来自「开源项目openfire的完整源程序」· SVN-BASE 代码 · 共 502 行 · 第 1/2 页
SVN-BASE
502 行
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); } }); } /** * Called when a new call is established. */ private void callStarted() { // Show History historyPanel.removeAll(); historyPanel.addPreviousConversations(phoneNumber); hangUpButton.setEnabled(true); muteButton.setEnabled(true); holdButton.setEnabled(true); transferButton.setEnabled(true); setStatus(CONNECTED, 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.callstartedat")+" " + time, ChatManager.NOTIFICATION_COLOR); } } /** * Called when the call is ended. This does basic container cleanup. */ public void callEnded() { if (!callWasTransferred) { historyPanel.callEnded(); setStatus("Call Ended", redColor); } hangUpButton.setEnabled(false); hangUpButton.setOpaque(false); muteButton.setEnabled(false); muteButton.setOpaque(false); holdButton.setEnabled(false); holdButton.setOpaque(false); transferButton.setEnabled(false); setStatus("Call Ended", redColor); // 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); } // If this is a standalone phone call with no associated ChatRoom // gray out title and show off-phone icon. final ChatRoom room = callManager.getAssociatedChatRoom(this); softPhone.addCallSession(room, SoftPhoneManager.CallRoomState.callWasEnded); // Notify SparkManager.getChatManager().notifySparkTabHandlers(room); } 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("Mute"); muteButton.setButtonSelected(false); setStatus(CONNECTED, false); // Change the current state. changeState(CallRoomState.inCall); } else { muted = true; muteButton.setToolTipText("Unmute"); muteButton.setButtonSelected(true); setStatus("Muted", true); // Change the current 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("Hold"); holdButton.setButtonSelected(false); setStatus(CONNECTED, false); // Change the current state changeState(CallRoomState.inCall); } else { onHold = true; holdButton.setToolTipText("Unhold"); holdButton.setButtonSelected(true); setStatus("On Hold", true); // Change the current 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() { return PhoneRes.getIString("phone.onphonewith")+" " + 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(SoftPhoneManager.CallRoomState state) { final ChatRoom room = callManager.getAssociatedChatRoom(this); softPhone.addCallSession(room, state); SparkManager.getChatManager().notifySparkTabHandlers(room); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?