/*
 * 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();
        }
    }
}

@@ -506,24 +506,219 @@
 .account.*;%0A
+import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;%0Aimport net.java.sip.communicator.impl.gui.main.contactlist.addgroup.*;%0Aimport net.java.sip.communicator.impl.gui.utils.*;%0A
 import net.j
@@ -1132,32 +1132,232 @@
 ccount%22));%0A    %0A
+    private JMenuItem addContactItem%0A        = new JMenuItem(Messages.getString(%22addContact%22));%0A    %0A    private JMenuItem createGroupItem%0A        = new JMenuItem(Messages.getString(%22createGroup%22));%0A%0A
     private JMen
@@ -1764,32 +1764,41 @@
 countMenuItem);%0A
+        %0A
         this.add
@@ -1822,138 +1822,507 @@
     
-this.add(closeMenuItem);%0A        %0A        this.newAccountMenuItem.setName(%22newAccount%22);%0A        this.closeMenuItem.setName(%22close
+%0A        this.add(addContactItem);%0A        this.add(createGroupItem);%0A        %0A        this.addSeparator();%0A        %0A        this.add(closeMenuItem);%0A        %0A        //this.addContactItem.setIcon(new ImageIcon(ImageLoader%0A        //        .getImage(ImageLoader.ADD_CONTACT_16x16_ICON)));%0A        %0A        this.newAccountMenuItem.setName(%22newAccount%22);%0A        this.closeMenuItem.setName(%22close%22);%0A        this.addContactItem.setName(%22addContact%22);%0A        this.createGroupItem.setName(%22createGroup
 %22);%0A
@@ -2431,32 +2431,139 @@
 Listener(this);%0A
+        this.addContactItem.addActionListener(this);%0A        this.createGroupItem.addActionListener(this);%0A
         %0A       
@@ -2835,24 +2835,248 @@
 charAt(0));%0A
+        this.addContactItem.setMnemonic(%0A                Messages.getString(%22mnemonic.addContact%22).charAt(0));%0A        this.createGroupItem.setMnemonic(%0A                Messages.getString(%22mnemonic.createGroup%22).charAt(0));%0A
     %7D%0A%0A    /
@@ -3291,20 +3291,20 @@
 ing item
-Text
+Name
  = menuI
@@ -3335,37 +3335,27 @@
 if (item
-Text
+Name
 .equals
-IgnoreCase
 (%22newAcc
@@ -4009,29 +4009,391 @@
 item
-Text.equalsIgnoreCase
+Name.equals(%22addContact%22)) %7B%0A            AddContactWizard wizard = new AddContactWizard(parentWindow);%0A            %0A            wizard.showModalDialog();%0A        %7D%0A        else if (itemName.equals(%22createGroup%22)) %7B%0A            CreateGroupDialog dialog = new CreateGroupDialog(parentWindow);%0A            %0A            dialog.setVisible(true);%0A        %7D%0A        else if (itemName.equals
 (%22cl

add contact and create group in the file menu