📄 callhistoryui.java.svn-base
字号:
/** * $Revision: $ * $Date: $ * * Copyright (C) 2007 Jive Software. All rights reserved. * * This software is published under the terms of the GNU Lesser Public License (LGPL), * a copy of which is included in this distribution. */package org.jivesoftware.sparkplugin.ui.call;import org.jivesoftware.spark.plugin.phone.resource.PhoneRes;import org.jivesoftware.sparkplugin.callhistory.HistoryCall;import org.jivesoftware.sparkplugin.calllog.CallLog;import org.jivesoftware.sparkplugin.calllog.LogManager;import net.java.sipmack.softphone.SoftPhoneManager;import org.jivesoftware.resource.SparkRes;import org.jivesoftware.spark.SparkManager;import org.jivesoftware.spark.component.RolloverButton;import org.jivesoftware.spark.component.tabbedPane.SparkTab;import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane;import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPaneListener;import org.jivesoftware.spark.util.GraphicUtils;import org.jivesoftware.spark.util.ModelUtil;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List;import javax.swing.BorderFactory;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.ListCellRenderer;import javax.swing.UIManager;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;/** * */public class CallHistoryUI extends JPanel implements ActionListener, ListSelectionListener { private SparkTabbedPane tabs; private final LogManager logManager; private final JFrame callHistoryFrame; private RolloverButton callButton; private RolloverButton deleteButton; private JList activeList; private CallHistoryRenderer renderer; public CallHistoryUI() { setLayout(new BorderLayout()); setBackground(Color.white); renderer = new CallHistoryRenderer(); callHistoryFrame = new JFrame(PhoneRes.getIString("phone.callhistory")); callHistoryFrame.setIconImage(SparkRes.getImageIcon(SparkRes.HISTORY_16x16).getImage()); callHistoryFrame.add(this); callHistoryFrame.pack(); callHistoryFrame.setSize(300, 300); logManager = SoftPhoneManager.getInstance().getLogManager(); List<HistoryCall> calls = new ArrayList<HistoryCall>(logManager.getCallHistory()); Collections.sort(calls, itemComparator); tabs = new SparkTabbedPane(); add(tabs, BorderLayout.CENTER); addAllPanel(calls); addDialedCalls(calls); addCallsReceived(calls); addCallsMissed(calls); callButton = new RolloverButton(PhoneRes.getIString("phone.tocall"), PhoneRes.getImageIcon("PHONE_CALL_24x24_IMAGE")); deleteButton = new RolloverButton(PhoneRes.getIString("phone.delete"), PhoneRes.getImageIcon("DELETE_24x24_IMAGE")); callButton.setHorizontalAlignment(JLabel.CENTER); deleteButton.setHorizontalAlignment(JLabel.CENTER); final Font buttonFont = new Font("Dialog", Font.BOLD, 13); callButton.setFont(buttonFont); deleteButton.setFont(buttonFont); final JPanel flowPanel = new JPanel(new FlowLayout()); flowPanel.setOpaque(false); flowPanel.add(callButton); //flowPanel.add(deleteButton); add(flowPanel, BorderLayout.SOUTH); callButton.setEnabled(false); deleteButton.setEnabled(false); callButton.addActionListener(this); deleteButton.addActionListener(this); tabs.addSparkTabbedPaneListener(new SparkTabbedPaneListener() { public void tabRemoved(SparkTab tab, Component component, int index) { } public void tabAdded(SparkTab tab, Component component, int index) { } public void tabSelected(SparkTab tab, Component component, int index) { JScrollPane pane = (JScrollPane)component; JList list = (JList)pane.getViewport().getView(); activeList = list; boolean selections = list.getSelectedValue() != null; callButton.setEnabled(selections); deleteButton.setEnabled(selections); } public void allTabsRemoved() { } public boolean canTabClose(SparkTab tab, Component component) { return false; } }); } private void addAllPanel(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) { final CallEntry callEntry = new CallEntry(call); model.addElement(callEntry); } tabs.addTab(PhoneRes.getIString("phone.all"), null, new JScrollPane(list), PhoneRes.getIString("phone.allcalls")); } private void addDialedCalls(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.dialed.toString())) { final CallEntry callEntry = new CallEntry(call); model.addElement(callEntry); } } tabs.addTab(PhoneRes.getIString("phone.dialed"), null, new JScrollPane(list), PhoneRes.getIString("phone.dialedcalls")); } private void addCallsReceived(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());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -