mirror of https://github.com/sipwise/jitsi.git
parent
51dd74637c
commit
8d138f1f6a
@ -1,66 +1,145 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.customcontrols.SIPCommButton;
|
||||
import net.java.sip.communicator.impl.gui.main.utils.Constants;
|
||||
|
||||
/**
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
|
||||
public class CallPanel extends JPanel implements ActionListener{
|
||||
|
||||
public class CallPanel extends JPanel{
|
||||
private JComboBox phoneNumberCombo = new JComboBox ();
|
||||
|
||||
private Image callButtonPressedIcon = LookAndFeelConstants.CALL_PRESSED_BUTTON_BG;
|
||||
private Image hangupButtonPressedIcon = LookAndFeelConstants.HANGUP_PRESSED_BUTTON_BG;
|
||||
private Image callButtonBG = LookAndFeelConstants.CALL_BUTTON_BG;
|
||||
private Image callButtonRolloverBG = LookAndFeelConstants.CALL_ROLLOVER_BUTTON_BG;
|
||||
private Image hangupButtonBG = LookAndFeelConstants.HANGUP_BUTTON_BG;
|
||||
private Image hangupButtonRolloverBG = LookAndFeelConstants.HANGUP_ROLLOVER_BUTTON_BG;
|
||||
|
||||
private JComboBox phoneNumberCombo = new JComboBox();
|
||||
private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 5));
|
||||
private SIPCommButton callButton;
|
||||
private SIPCommButton hangupButton;
|
||||
|
||||
public CallPanel(){
|
||||
private JPanel comboPanel = new JPanel (new BorderLayout());
|
||||
|
||||
private JPanel buttonsPanel = new JPanel (
|
||||
new FlowLayout(FlowLayout.CENTER, 15, 0));
|
||||
|
||||
private SIPCommButton callButton = new SIPCommButton
|
||||
(Constants.CALL_BUTTON_BG,
|
||||
Constants.CALL_ROLLOVER_BUTTON_BG,
|
||||
Constants.CALL_PRESSED_BUTTON_BG,
|
||||
null);
|
||||
|
||||
private SIPCommButton hangupButton = new SIPCommButton
|
||||
(Constants.HANGUP_BUTTON_BG,
|
||||
Constants.HANGUP_ROLLOVER_BUTTON_BG,
|
||||
Constants.HANGUP_PRESSED_BUTTON_BG,
|
||||
null);
|
||||
|
||||
private SIPCommButton minimizeButton
|
||||
= new SIPCommButton(Constants.CALL_PANEL_MINIMIZE_BUTTON,
|
||||
Constants.CALL_PANEL_MINIMIZE_ROLLOVER_BUTTON);
|
||||
|
||||
private SIPCommButton restoreButton
|
||||
= new SIPCommButton(Constants.CALL_PANEL_RESTORE_BUTTON,
|
||||
Constants.CALL_PANEL_RESTORE_ROLLOVER_BUTTON);
|
||||
|
||||
private JPanel minimizeButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
private MainFrame parentWindow;
|
||||
|
||||
public CallPanel(MainFrame parentWindow) {
|
||||
|
||||
super(new BorderLayout());
|
||||
/*
|
||||
callButton = new SIPCommButton(callButtonBG,
|
||||
callButtonRolloverBG,
|
||||
callButtonIcon);
|
||||
hangupButton = new SIPCommButton(hangupButtonBG,
|
||||
hangupButtonRolloverBG,
|
||||
hangupButtonIcon);
|
||||
*/
|
||||
|
||||
callButton = new SIPCommButton(callButtonBG,
|
||||
callButtonRolloverBG,
|
||||
callButtonPressedIcon,
|
||||
null);
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
hangupButton = new SIPCommButton(hangupButtonBG,
|
||||
hangupButtonRolloverBG,
|
||||
hangupButtonPressedIcon,
|
||||
null);
|
||||
|
||||
|
||||
this.buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
|
||||
|
||||
this.comboPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5));
|
||||
|
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
this.phoneNumberCombo.setEditable(true);
|
||||
|
||||
this.add(phoneNumberCombo, BorderLayout.NORTH);
|
||||
this.comboPanel.add(phoneNumberCombo, BorderLayout.CENTER);
|
||||
this.add(comboPanel, BorderLayout.NORTH);
|
||||
|
||||
this.callButton.setName("call");
|
||||
this.hangupButton.setName("hangup");
|
||||
this.minimizeButton.setName("minimize");
|
||||
this.restoreButton.setName("restore");
|
||||
|
||||
this.callButton.addActionListener(this);
|
||||
this.hangupButton.addActionListener(this);
|
||||
this.minimizeButton.addActionListener(this);
|
||||
this.restoreButton.addActionListener(this);
|
||||
|
||||
this.buttonsPanel.add(callButton);
|
||||
this.buttonsPanel.add(hangupButton);
|
||||
|
||||
|
||||
this.add(buttonsPanel, BorderLayout.CENTER);
|
||||
|
||||
this.minimizeButtonPanel.add(minimizeButton);
|
||||
|
||||
this.add(minimizeButtonPanel,BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public JComboBox getPhoneNumberCombo() {
|
||||
return phoneNumberCombo;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JButton button = (JButton) e.getSource();
|
||||
String buttonName = button.getName();
|
||||
|
||||
if (buttonName.equalsIgnoreCase("call")){
|
||||
CallReceivePanel cr = new CallReceivePanel(this.parentWindow);
|
||||
|
||||
cr.setVisible(true);
|
||||
}
|
||||
else if (buttonName.equalsIgnoreCase("hangup")){
|
||||
|
||||
}
|
||||
else if (buttonName.equalsIgnoreCase("minimize")){
|
||||
|
||||
this.remove(comboPanel);
|
||||
this.remove(buttonsPanel);
|
||||
|
||||
this.minimizeButtonPanel.removeAll();
|
||||
this.minimizeButtonPanel.add(restoreButton);
|
||||
|
||||
this.parentWindow.validate();
|
||||
}
|
||||
else if (buttonName.equalsIgnoreCase("restore")){
|
||||
|
||||
this.add(comboPanel, BorderLayout.NORTH);
|
||||
this.add(buttonsPanel, BorderLayout.CENTER);
|
||||
|
||||
this.minimizeButtonPanel.removeAll();
|
||||
this.minimizeButtonPanel.add(minimizeButton);
|
||||
|
||||
this.parentWindow.validate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,93 @@
|
||||
package net.java.sip.communicator.impl.gui.main;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.customcontrols.SIPCommButton;
|
||||
import net.java.sip.communicator.impl.gui.main.utils.Constants;
|
||||
|
||||
public class CallReceivePanel extends JDialog{
|
||||
|
||||
private Image callButtonPressedIcon = Constants.CALL_PRESSED_BUTTON_BG;
|
||||
|
||||
private Image hangupButtonPressedIcon = Constants.HANGUP_PRESSED_BUTTON_BG;
|
||||
|
||||
private Image callButtonBG = Constants.CALL_BUTTON_BG;
|
||||
|
||||
private Image callButtonRolloverBG = Constants.CALL_ROLLOVER_BUTTON_BG;
|
||||
|
||||
private Image hangupButtonBG = Constants.HANGUP_BUTTON_BG;
|
||||
|
||||
private Image hangupButtonRolloverBG = Constants.HANGUP_ROLLOVER_BUTTON_BG;
|
||||
|
||||
private JLabel personPhoto = new JLabel(new ImageIcon (Constants.DEFAULT_USER_PHOTO));
|
||||
|
||||
private JLabel personName = new JLabel ("John Smith");
|
||||
|
||||
private JLabel birthDate = new JLabel ("11/11/1900");
|
||||
|
||||
private JLabel emptyLabel = new JLabel (" ");
|
||||
|
||||
private JLabel personInfo = new JLabel ("additional info");
|
||||
|
||||
private SIPCommButton callButton;
|
||||
|
||||
private SIPCommButton hangupButton;
|
||||
|
||||
private JPanel userInfoPanel = new JPanel();
|
||||
|
||||
private JPanel buttonsPanel = new JPanel(
|
||||
new FlowLayout(FlowLayout.CENTER, 15, 5));
|
||||
|
||||
|
||||
|
||||
public CallReceivePanel (MainFrame parent){
|
||||
|
||||
super(parent);
|
||||
|
||||
this.setSize(300, 200);
|
||||
|
||||
this.getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
callButton = new SIPCommButton(callButtonBG, callButtonRolloverBG,
|
||||
callButtonPressedIcon, null);
|
||||
|
||||
hangupButton = new SIPCommButton(hangupButtonBG,
|
||||
hangupButtonRolloverBG, hangupButtonPressedIcon, null);
|
||||
|
||||
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void init () {
|
||||
|
||||
this.personName.setFont(new Font("Sans Serif", Font.BOLD, 12));
|
||||
|
||||
//this.buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY));
|
||||
this.buttonsPanel.add(callButton);
|
||||
this.buttonsPanel.add(hangupButton);
|
||||
|
||||
this.userInfoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
|
||||
this.userInfoPanel.setLayout(new BoxLayout(userInfoPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
this.userInfoPanel.add(personName);
|
||||
this.userInfoPanel.add(birthDate);
|
||||
this.userInfoPanel.add(emptyLabel);
|
||||
this.userInfoPanel.add(personInfo);
|
||||
|
||||
this.getContentPane().add(personPhoto, BorderLayout.WEST);
|
||||
this.getContentPane().add(userInfoPanel, BorderLayout.CENTER);
|
||||
this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,190 @@
|
||||
package net.java.sip.communicator.impl.gui.main;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.customcontrols.AntialiasedMenu;
|
||||
import net.java.sip.communicator.impl.gui.main.customcontrols.AntialiasedMenuItem;
|
||||
import net.java.sip.communicator.impl.gui.main.customcontrols.MessageDialog;
|
||||
import net.java.sip.communicator.impl.gui.main.history.HistoryWindow;
|
||||
import net.java.sip.communicator.impl.gui.main.i18n.Messages;
|
||||
import net.java.sip.communicator.impl.gui.main.message.MessageWindow;
|
||||
import net.java.sip.communicator.impl.gui.main.utils.Constants;
|
||||
|
||||
public class ContactRightButtonMenu extends JPopupMenu implements
|
||||
ActionListener {
|
||||
|
||||
private AntialiasedMenu moveToMenu = new AntialiasedMenu(
|
||||
Messages.getString("moveToGroup"),
|
||||
new ImageIcon(Constants.GROUPS_16x16_ICON));
|
||||
|
||||
private AntialiasedMenu addSubcontactMenu = new AntialiasedMenu(
|
||||
Messages.getString("addSubcontact"),
|
||||
new ImageIcon(Constants.ADD_CONTACT_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem sendMessageItem = new AntialiasedMenuItem(
|
||||
Messages.getString("sendMessage"),
|
||||
new ImageIcon(Constants.SEND_MESSAGE_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem sendFileItem = new AntialiasedMenuItem(
|
||||
Messages.getString("sendFile"),
|
||||
new ImageIcon(Constants.SEND_FILE_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem removeContactItem = new AntialiasedMenuItem(
|
||||
Messages.getString("removeContact"),
|
||||
new ImageIcon(Constants.DELETE_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem renameContactItem = new AntialiasedMenuItem(
|
||||
Messages.getString("renameContact"),
|
||||
new ImageIcon(Constants.RENAME_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem userInfoItem = new AntialiasedMenuItem(
|
||||
Messages.getString("userInfo"),
|
||||
new ImageIcon(Constants.INFO_16x16_ICON));
|
||||
|
||||
private AntialiasedMenuItem viewHistoryItem = new AntialiasedMenuItem(
|
||||
Messages.getString("viewHistory"),
|
||||
new ImageIcon(Constants.HISTORY_16x16_ICON));
|
||||
|
||||
private ContactItem contactItem;
|
||||
|
||||
private MainFrame mainFrame;
|
||||
|
||||
public ContactRightButtonMenu(MainFrame mainFrame, ContactItem contactItem) {
|
||||
super();
|
||||
|
||||
this.mainFrame = mainFrame;
|
||||
|
||||
this.contactItem = contactItem;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
// This feature is disabled until it's implemented
|
||||
this.sendFileItem.setEnabled(false);
|
||||
|
||||
String[] userProtocols = mainFrame.getUser().getProtocols();
|
||||
|
||||
for (int i = 0; i < userProtocols.length; i++) {
|
||||
|
||||
AntialiasedMenuItem protocolMenuItem = new AntialiasedMenuItem(
|
||||
userProtocols[i],
|
||||
new ImageIcon(Constants.getProtocolIcon(userProtocols[i])));
|
||||
|
||||
this.addSubcontactMenu.add(protocolMenuItem);
|
||||
}
|
||||
|
||||
this.add(sendMessageItem);
|
||||
this.add(sendFileItem);
|
||||
|
||||
this.addSeparator();
|
||||
|
||||
this.add(moveToMenu);
|
||||
|
||||
this.addSeparator();
|
||||
|
||||
this.add(addSubcontactMenu);
|
||||
|
||||
this.addSeparator();
|
||||
|
||||
this.add(removeContactItem);
|
||||
this.add(renameContactItem);
|
||||
|
||||
this.addSeparator();
|
||||
|
||||
this.add(viewHistoryItem);
|
||||
this.add(userInfoItem);
|
||||
|
||||
this.sendMessageItem.setName("sendMessage");
|
||||
this.sendFileItem.setName("sendFile");
|
||||
this.moveToMenu.setName("moveToGroup");
|
||||
this.addSubcontactMenu.setName("addSubcontact");
|
||||
this.removeContactItem.setName("removeContact");
|
||||
this.renameContactItem.setName("renameContact");
|
||||
this.viewHistoryItem.setName("viewHistory");
|
||||
this.userInfoItem.setName("userInfo");
|
||||
|
||||
this.sendMessageItem.addActionListener(this);
|
||||
this.sendFileItem.addActionListener(this);
|
||||
this.moveToMenu.addActionListener(this);
|
||||
this.addSubcontactMenu.addActionListener(this);
|
||||
this.removeContactItem.addActionListener(this);
|
||||
this.renameContactItem.addActionListener(this);
|
||||
this.viewHistoryItem.addActionListener(this);
|
||||
this.userInfoItem.addActionListener(this);
|
||||
}
|
||||
|
||||
public Point calculatePopupLocation() {
|
||||
|
||||
Component component = this.getInvoker();
|
||||
Point point = new Point();
|
||||
int x = component.getX();
|
||||
int y = component.getY();
|
||||
|
||||
while (component.getParent() != null) {
|
||||
|
||||
component = component.getParent();
|
||||
|
||||
x += component.getX();
|
||||
y += component.getY();
|
||||
}
|
||||
System.out.println(component.getHeight());
|
||||
point.x = x;
|
||||
point.y = y + this.getInvoker().getHeight();
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
JMenuItem menuItem = (JMenuItem) e.getSource();
|
||||
String itemName = menuItem.getName();
|
||||
|
||||
if (itemName.equalsIgnoreCase("sendMessage")) {
|
||||
|
||||
MessageWindow msgWindow = new MessageWindow(this.mainFrame);
|
||||
|
||||
msgWindow.addContactToChat(this.contactItem);
|
||||
|
||||
msgWindow.setVisible(true);
|
||||
}
|
||||
else if (itemName.equalsIgnoreCase("sendFile")) {
|
||||
|
||||
// disabled
|
||||
}
|
||||
else if (itemName.equalsIgnoreCase("removeContact")) {
|
||||
|
||||
MessageDialog warning = new MessageDialog(this.mainFrame);
|
||||
|
||||
String message = "<HTML>Are you sure you want to remove <B>"
|
||||
+ this.contactItem.getNickName()
|
||||
+"</B><BR>from your contact list?</html>";
|
||||
|
||||
warning.setMessage(message);
|
||||
|
||||
warning.setVisible(true);
|
||||
}
|
||||
else if (itemName.equalsIgnoreCase("renameContact")) {
|
||||
|
||||
}
|
||||
else if (itemName.equalsIgnoreCase("viewHistory")) {
|
||||
|
||||
HistoryWindow history = new HistoryWindow();
|
||||
|
||||
history.setContact(this.contactItem);
|
||||
history.setVisible(true);
|
||||
}
|
||||
else if (itemName.equalsIgnoreCase("userInfo")) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue