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

📄 callhistoryui.java.svn-base

📁 开源项目openfire的完整源程序
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
                }            }        });        for (HistoryCall call : callList) {            if (call.getGroupName().equals(CallLog.Type.received.toString())) {                final CallEntry callEntry = new CallEntry(call);                model.addElement(callEntry);            }        }        tabs.addTab(PhoneRes.getIString("phone.received"), null, new JScrollPane(list), PhoneRes.getIString("phone.receivedcalls"));    }    private void addCallsMissed(List<HistoryCall> callList) {        final DefaultListModel model = new DefaultListModel();        final JList list = new JList(model);        list.addListSelectionListener(this);        list.setCellRenderer(renderer);        list.addMouseListener(new MouseAdapter() {            public void mouseClicked(MouseEvent mouseEvent) {                if (mouseEvent.getClickCount() == 2) {                    CallEntry entry = (CallEntry)list.getSelectedValue();                    callHistoryFrame.dispose();                    SoftPhoneManager.getInstance().getDefaultGuiManager().dial(entry.getNumber());                }            }        });        for (HistoryCall call : callList) {            if (call.getGroupName().equals(CallLog.Type.missed.toString())) {                final CallEntry callEntry = new CallEntry(call);                model.addElement(callEntry);            }        }        tabs.addTab(PhoneRes.getIString("phone.missed"), null, new JScrollPane(list), PhoneRes.getIString("phone.missedcalls"));    }    public void invoke() {        GraphicUtils.centerWindowOnComponent(callHistoryFrame, SparkManager.getMainWindow());        callHistoryFrame.setVisible(true);    }    /**     * Represents a single entry into the phone history list.     */    public class CallEntry extends JPanel {        private String number;        private HistoryCall call;        public CallEntry(HistoryCall call) {            setLayout(new GridBagLayout());            this.number = call.getNumber();            this.call = call;            long time = call.getTime();            long duration = call.getCallLength();            String title = call.getCallerName();            if (title == null) {                title = PhoneRes.getIString("phone.unknown");            }            number = call.getNumber();            StringBuilder sb = new StringBuilder();            if (call.getGroupName().equals(CallLog.Type.dialed.toString())) {                setBackground(new Color(40, 147, 40).brighter().brighter());                sb.append(PhoneRes.getIString("phone.placecallto")+" ");            }            else if (call.getGroupName().equals(CallLog.Type.received.toString())) {                setBackground(Color.blue);                sb.append(PhoneRes.getIString("phone.placecallto")+" ");            }            else if (call.getGroupName().equals(CallLog.Type.missed.toString())) {                setBackground(Color.red);                sb.append(PhoneRes.getIString("phone.missedcallfrom")+" ");            }            sb.append(title);            final JLabel titleLabel = new JLabel(sb.toString());            titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));            final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");            StringBuilder builder = new StringBuilder();            builder.append(formatter.format(time));            builder.append(" ");            if (duration > 0) {                builder.append(PhoneRes.getIString("phone.duration")+": ");                builder.append(ModelUtil.getTimeFromLong(duration*1000));            }            final JLabel descriptionLabel = new JLabel(builder.toString());            descriptionLabel.setForeground(Color.gray);            descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, 11));            // Add Title Label            add(titleLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 2), 0, 0));            // Add Phone Number Label            final JLabel numberLabel = new JLabel();            numberLabel.setFont(new Font("Dialog", Font.PLAIN, 11));            numberLabel.setText(number);            add(numberLabel, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 2), 0, 0));            // Add description of call            add(descriptionLabel, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 2, 2), 0, 0));        }        public String getNumber() {            return number;        }        public HistoryCall getCall() {            return call;        }    }    public void actionPerformed(ActionEvent actionEvent) {        if (actionEvent.getSource() == callButton) {            // Get Selected Call Entry            CallEntry entry = (CallEntry)activeList.getSelectedValue();            SoftPhoneManager.getInstance().getDefaultGuiManager().dial(entry.getNumber());        }        else if (actionEvent.getSource() == deleteButton) {        }    }    final Comparator itemComparator = new Comparator() {        public int compare(Object contactItemOne, Object contactItemTwo) {            final HistoryCall time1 = (HistoryCall)contactItemOne;            final HistoryCall time2 = (HistoryCall)contactItemTwo;            if (time1.getTime() < time2.getTime()) {                return 1;            }            else if (time1.getTime() > time2.getTime()) {                return -1;            }            return 0;        }    };    public void valueChanged(ListSelectionEvent listSelectionEvent) {        if (listSelectionEvent.getValueIsAdjusting()) {            return;        }        final JList list = (JList)listSelectionEvent.getSource();        activeList = list;        CallEntry callEntry = (CallEntry)list.getSelectedValue();        callButton.setEnabled(callEntry != null);        deleteButton.setEnabled(callEntry != null);    }    /**     * Internal ListRenderer for CallEntry panel.     */    private static class CallHistoryRenderer extends JPanel implements ListCellRenderer {        public Component getListCellRendererComponent(JList list,                                                      Object value,                                                      int index,                                                      boolean isSelected,                                                      boolean cellHasFocus) {            CallEntry panel = (CallEntry)value;            panel.setFocusable(false);            if (isSelected) {                panel.setForeground((Color)UIManager.get("List.selectionForeground"));                panel.setBackground((Color)UIManager.get("List.selectionBackground"));                panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.selectionBorder")));            }            else {                if (panel.getCall().getGroupName().equals(CallLog.Type.dialed.toString())) {                    panel.setBackground(new Color(231, 248, 228));                }                else if (panel.getCall().getGroupName().equals(CallLog.Type.received.toString())) {                    panel.setBackground(new Color(211, 237, 240));                }                else if (panel.getCall().getGroupName().equals(CallLog.Type.missed.toString())) {                    panel.setBackground(new Color(255, 224, 224));                }                panel.setForeground(list.getForeground());                panel.setBorder(BorderFactory.createLineBorder((Color)UIManager.get("List.background")));            }            list.setBackground((Color)UIManager.get("List.background"));            return panel;        }    }}

⌨️ 快捷键说明

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