mirror of https://github.com/sipwise/jitsi.git
parent
cbb4b73105
commit
dffc6255e3
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.menus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.main.*;
|
||||
import net.java.sip.communicator.impl.gui.main.account.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
/**
|
||||
* The <tt>FileMenu</tt> is a menu in the main application menu bar that
|
||||
* contains "New account".
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class FileMenu
|
||||
extends JMenu
|
||||
implements ActionListener
|
||||
{
|
||||
|
||||
private Logger logger = Logger.getLogger(FileMenu.class.getName());
|
||||
|
||||
private JMenuItem newAccountMenuItem
|
||||
= new JMenuItem(Messages.getString("newAccount"));
|
||||
|
||||
private JMenuItem closeMenuItem
|
||||
= new JMenuItem(Messages.getString("close"));
|
||||
|
||||
private MainFrame parentWindow;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>FileMenu</tt>.
|
||||
* @param parentWindow The parent <tt>ChatWindow</tt>.
|
||||
*/
|
||||
public FileMenu(MainFrame parentWindow) {
|
||||
|
||||
super(Messages.getString("file"));
|
||||
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
this.add(newAccountMenuItem);
|
||||
this.addSeparator();
|
||||
this.add(closeMenuItem);
|
||||
|
||||
this.newAccountMenuItem.setName("newAccount");
|
||||
this.closeMenuItem.setName("close");
|
||||
|
||||
this.newAccountMenuItem.addActionListener(this);
|
||||
this.closeMenuItem.addActionListener(this);
|
||||
|
||||
this.setMnemonic(Messages.getString("file").charAt(0));
|
||||
this.closeMenuItem.setMnemonic(
|
||||
Messages.getString("mnemonic.close").charAt(0));
|
||||
this.newAccountMenuItem.setMnemonic(
|
||||
Messages.getString("mnemonic.newAccount").charAt(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
JMenuItem menuItem = (JMenuItem) e.getSource();
|
||||
String itemText = menuItem.getName();
|
||||
|
||||
if (itemText.equalsIgnoreCase("newAccount")) {
|
||||
AccountRegWizardContainerImpl wizard
|
||||
= (AccountRegWizardContainerImpl)GuiActivator.getUIService()
|
||||
.getAccountRegWizardContainer();
|
||||
|
||||
wizard.setTitle(
|
||||
Messages.getString("accountRegistrationWizard"));
|
||||
|
||||
wizard.setLocation(
|
||||
Toolkit.getDefaultToolkit().getScreenSize().width/2
|
||||
- 250,
|
||||
Toolkit.getDefaultToolkit().getScreenSize().height/2
|
||||
- 100
|
||||
);
|
||||
|
||||
wizard.newAccount();
|
||||
|
||||
wizard.showModalDialog();
|
||||
}
|
||||
else if (itemText.equalsIgnoreCase("close")) {
|
||||
try {
|
||||
GuiActivator.bundleContext.getBundle(0).stop();
|
||||
} catch (BundleException ex) {
|
||||
logger.error("Failed to gently shutdown Oscar", ex);
|
||||
}
|
||||
parentWindow.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.menus;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.main.*;
|
||||
|
||||
/**
|
||||
* The main menu.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class MainMenu
|
||||
extends JMenuBar
|
||||
{
|
||||
private FileMenu fileMenu;
|
||||
|
||||
private ToolsMenu toolsMenu;
|
||||
|
||||
private JMenu viewMenu = new JMenu();
|
||||
|
||||
private JMenu helpMenu = new JMenu();
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>Menu</tt>.
|
||||
*/
|
||||
public MainMenu(MainFrame mainFrame)
|
||||
{
|
||||
this.fileMenu = new FileMenu(mainFrame);
|
||||
this.toolsMenu = new ToolsMenu(mainFrame);
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the menu.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
fileMenu.setText(Messages.getString("file"));
|
||||
fileMenu.setMnemonic(Messages.getString("mnemonic.file").charAt(0));
|
||||
fileMenu.setToolTipText(Messages.getString("file"));
|
||||
|
||||
toolsMenu.setText(Messages.getString("tools"));
|
||||
toolsMenu.setMnemonic(Messages.getString("mnemonic.tools").charAt(0));
|
||||
toolsMenu.setToolTipText(Messages.getString("tools"));
|
||||
|
||||
viewMenu.setText(Messages.getString("settings"));
|
||||
viewMenu.setMnemonic(Messages.getString("mnemonic.settings").charAt(0));
|
||||
viewMenu.setToolTipText(Messages.getString("settings"));
|
||||
|
||||
helpMenu.setText(Messages.getString("help"));
|
||||
helpMenu.setMnemonic(Messages.getString("mnemonic.help").charAt(0));
|
||||
helpMenu.setToolTipText(Messages.getString("help"));
|
||||
|
||||
this.add(fileMenu);
|
||||
this.add(toolsMenu);
|
||||
this.add(viewMenu);
|
||||
this.add(helpMenu);
|
||||
|
||||
// Disable all menus that are not yet implemented.
|
||||
this.viewMenu.setEnabled(false);
|
||||
this.helpMenu.setEnabled(false);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,283 @@
|
||||
/*
|
||||
* 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.menus;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.customcontrols.*;
|
||||
import net.java.sip.communicator.impl.gui.customcontrols.wizard.*;
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.main.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.gui.event.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>QuickMenu</tt> is the toolbar on the top of the main
|
||||
* application window. It provides quick access to the "User info" window, the
|
||||
* "Configuration" window, the "Add contact" window and the "Hide/Open offline
|
||||
* contacts" window.
|
||||
* <p>
|
||||
* Note that this class implements the <tt>PluginComponentListener</tt>. This
|
||||
* means that this toolbar is a plugable container and could contain plugin
|
||||
* components.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class QuickMenu extends SIPCommToolBar implements ActionListener,
|
||||
PluginComponentListener {
|
||||
|
||||
private Logger logger = Logger.getLogger(QuickMenu.class.getName());
|
||||
|
||||
private JButton infoButton = new JButton(new ImageIcon(ImageLoader
|
||||
.getImage(ImageLoader.QUICK_MENU_INFO_ICON)));
|
||||
|
||||
private JButton configureButton = new JButton(new ImageIcon(ImageLoader
|
||||
.getImage(ImageLoader.QUICK_MENU_CONFIGURE_ICON)));
|
||||
|
||||
private JButton searchButton = new JButton(new ImageIcon(ImageLoader
|
||||
.getImage(ImageLoader.QUICK_MENU_SEARCH_ICON)));
|
||||
|
||||
private JButton addButton = new JButton(new ImageIcon(ImageLoader
|
||||
.getImage(ImageLoader.QUICK_MENU_ADD_ICON)));
|
||||
|
||||
private ConfigurationManager configDialog;
|
||||
|
||||
private MainFrame mainFrame;
|
||||
|
||||
/**
|
||||
* Create an instance of the <tt>QuickMenu</tt>.
|
||||
* @param mainFrame The parent <tt>MainFrame</tt> window.
|
||||
*/
|
||||
public QuickMenu(MainFrame mainFrame) {
|
||||
this.mainFrame = mainFrame;
|
||||
|
||||
this.setRollover(true);
|
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
|
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
|
||||
this.setFloatable(false);
|
||||
|
||||
this.infoButton.setPreferredSize(new Dimension(28, 28));
|
||||
this.configureButton.setPreferredSize(new Dimension(28, 28));
|
||||
this.searchButton.setPreferredSize(new Dimension(28, 28));
|
||||
this.addButton.setPreferredSize(new Dimension(28, 28));
|
||||
|
||||
this.infoButton.setToolTipText(Messages.getString("userInfo"));
|
||||
this.configureButton.setToolTipText(Messages.getString("configure"));
|
||||
this.searchButton
|
||||
.setToolTipText(Messages.getString("showOfflineUsers"));
|
||||
this.addButton.setToolTipText(Messages.getString("addContact"));
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the <tt>QuickMenu</tt> by adding the buttons.
|
||||
*/
|
||||
private void init() {
|
||||
this.add(addButton);
|
||||
this.add(configureButton);
|
||||
this.add(infoButton);
|
||||
this.add(searchButton);
|
||||
|
||||
this.addButton.setName("add");
|
||||
this.configureButton.setName("config");
|
||||
this.searchButton.setName("search");
|
||||
this.infoButton.setName("info");
|
||||
|
||||
this.addButton.addActionListener(this);
|
||||
this.configureButton.addActionListener(this);
|
||||
this.searchButton.addActionListener(this);
|
||||
this.infoButton.addActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>ActionEvent</tt> triggered when user clicks on one of
|
||||
* the buttons in this toolbar.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JButton button = (JButton) e.getSource();
|
||||
String buttonName = button.getName();
|
||||
|
||||
if (buttonName.equals("add")) {
|
||||
|
||||
Wizard wizard = new Wizard();
|
||||
wizard.getDialog().setTitle(Messages.getString("addContactWizard"));
|
||||
|
||||
NewContact newContact = new NewContact();
|
||||
|
||||
AddContactWizardPage1 page1
|
||||
= new AddContactWizardPage1(wizard, newContact,
|
||||
mainFrame.getProtocolProviders());
|
||||
|
||||
wizard.registerWizardPage(AddContactWizardPage1.IDENTIFIER, page1);
|
||||
|
||||
AddContactWizardPage2 page2
|
||||
= new AddContactWizardPage2(wizard, newContact,
|
||||
mainFrame.getAllGroups());
|
||||
|
||||
wizard.registerWizardPage(AddContactWizardPage2.IDENTIFIER, page2);
|
||||
|
||||
AddContactWizardPage3 page3
|
||||
= new AddContactWizardPage3(newContact);
|
||||
|
||||
wizard.registerWizardPage(AddContactWizardPage3.IDENTIFIER, page3);
|
||||
|
||||
wizard.setCurrentPage(AddContactWizardPage1.IDENTIFIER);
|
||||
|
||||
wizard.getDialog().setLocation(
|
||||
Toolkit.getDefaultToolkit().getScreenSize().width/2
|
||||
- 250,
|
||||
Toolkit.getDefaultToolkit().getScreenSize().height/2
|
||||
- 100
|
||||
);
|
||||
|
||||
int returnCode = wizard.showModalDialog();
|
||||
|
||||
if(returnCode == 0) {
|
||||
ArrayList ppList = newContact.getProtocolProviders();
|
||||
ArrayList groupList = newContact.getGroups();
|
||||
|
||||
for(int i = 0; i < ppList.size(); i ++) {
|
||||
ProtocolProviderService pps
|
||||
= (ProtocolProviderService)ppList.get(i);
|
||||
|
||||
for(int j = 0; j < groupList.size(); j++) {
|
||||
MetaContactGroup group
|
||||
= (MetaContactGroup)groupList.get(j);
|
||||
|
||||
|
||||
class CreateContact extends Thread {
|
||||
ProtocolProviderService pps;
|
||||
MetaContactGroup group;
|
||||
NewContact newContact;
|
||||
CreateContact(ProtocolProviderService pps,
|
||||
MetaContactGroup group,
|
||||
NewContact newContact) {
|
||||
this.pps = pps;
|
||||
this.group = group;
|
||||
this.newContact = newContact;
|
||||
}
|
||||
public void run() {
|
||||
try {
|
||||
mainFrame.getContactList()
|
||||
.createMetaContact(
|
||||
pps, group, newContact.getUin());
|
||||
}
|
||||
catch (MetaContactListException ex) {
|
||||
logger.error(ex);
|
||||
|
||||
JOptionPane.showMessageDialog(mainFrame,
|
||||
Messages.getString(
|
||||
"addContactError",
|
||||
newContact.getUin()),
|
||||
Messages.getString(
|
||||
"addContactErrorTitle"),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
new CreateContact(pps, group, newContact).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(returnCode == 1) {
|
||||
wizard.getDialog().dispose();
|
||||
}
|
||||
}
|
||||
else if (buttonName.equals("config")) {
|
||||
|
||||
configDialog = GuiActivator.getUIService().getConfigurationManager();
|
||||
|
||||
configDialog.showDialog();
|
||||
}
|
||||
else if (buttonName.equals("search")) {
|
||||
|
||||
ContactList contactList = mainFrame.getContactListPanel()
|
||||
.getContactList();
|
||||
|
||||
ContactListModel listModel
|
||||
= (ContactListModel) contactList.getModel();
|
||||
|
||||
if (listModel.showOffline()) {
|
||||
listModel.setShowOffline(false);
|
||||
listModel.removeOfflineContacts();
|
||||
}
|
||||
else {
|
||||
Object selectedObject = null;
|
||||
int currentlySelectedIndex = contactList.getSelectedIndex();
|
||||
if(currentlySelectedIndex != -1) {
|
||||
selectedObject
|
||||
= listModel.getElementAt(currentlySelectedIndex);
|
||||
}
|
||||
|
||||
listModel.setShowOffline(true);
|
||||
listModel.addOfflineContacts();
|
||||
|
||||
if (selectedObject != null) {
|
||||
if (selectedObject instanceof MetaContact) {
|
||||
contactList.setSelectedIndex(
|
||||
listModel.indexOf((MetaContact) selectedObject));
|
||||
}
|
||||
else {
|
||||
contactList.setSelectedIndex(
|
||||
listModel.indexOf(
|
||||
(MetaContactGroup) selectedObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buttonName.equals("info")) {
|
||||
MetaContact selectedMetaContact =
|
||||
(MetaContact) mainFrame.getContactListPanel()
|
||||
.getContactList().getSelectedValue();
|
||||
|
||||
if(selectedMetaContact != null) {
|
||||
Contact defaultContact = selectedMetaContact
|
||||
.getDefaultContact();
|
||||
|
||||
ProtocolProviderService defaultProvider
|
||||
= defaultContact.getProtocolProvider();
|
||||
|
||||
OperationSetWebContactInfo wContactInfo
|
||||
= mainFrame.getWebContactInfo(defaultProvider);
|
||||
|
||||
CrossPlatformBrowserLauncher.openURL(
|
||||
wContactInfo.getWebContactInfo(defaultContact)
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>PluginComponentListener.pluginComponentAdded</code>
|
||||
* method.
|
||||
*/
|
||||
public void pluginComponentAdded(PluginComponentEvent event) {
|
||||
//TODO Implement pluginComponentAdded.
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>PluginComponentListener.pluginComponentRemoved</code>
|
||||
* method.
|
||||
*/
|
||||
public void pluginComponentRemoved(PluginComponentEvent event) {
|
||||
//TODO Implement pluginComponentRemoved.
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.menus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.main.*;
|
||||
import net.java.sip.communicator.impl.gui.main.account.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
/**
|
||||
* The <tt>FileMenu</tt> is a menu in the main application menu bar that
|
||||
* contains "New account".
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ToolsMenu
|
||||
extends JMenu
|
||||
implements ActionListener
|
||||
{
|
||||
|
||||
private Logger logger = Logger.getLogger(ToolsMenu.class.getName());
|
||||
|
||||
private JMenuItem configMenuItem
|
||||
= new JMenuItem(Messages.getString("configurations"));
|
||||
|
||||
private MainFrame parentWindow;
|
||||
|
||||
private ConfigurationManager configDialog;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>FileMenu</tt>.
|
||||
* @param parentWindow The parent <tt>ChatWindow</tt>.
|
||||
*/
|
||||
public ToolsMenu(MainFrame parentWindow) {
|
||||
|
||||
super(Messages.getString("tools"));
|
||||
|
||||
this.parentWindow = parentWindow;
|
||||
|
||||
this.add(configMenuItem);
|
||||
|
||||
this.configMenuItem.setName("config");
|
||||
|
||||
this.configMenuItem.addActionListener(this);
|
||||
|
||||
this.setMnemonic(Messages.getString("mnemonic.tools").charAt(0));
|
||||
this.configMenuItem.setMnemonic(
|
||||
Messages.getString("mnemonic.toolsMenuConfig").charAt(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
JMenuItem menuItem = (JMenuItem) e.getSource();
|
||||
String itemText = menuItem.getName();
|
||||
|
||||
if (itemText.equalsIgnoreCase("config")) {
|
||||
configDialog = GuiActivator.getUIService().getConfigurationManager();
|
||||
|
||||
configDialog.showDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue