package gui;

import javax.swing.*;

import actions.*;

public class MenuBar extends JMenuBar
{
  private JMenu[] menuArray = new JMenu[5]; // hard-coded number of menus

  private String[] menus = new String[] {"File", "Edit", "View", "Window", "Help"};
  private char[] menuMnemonics = {'F', 'E', 'V', 'W', 'H'};

  private String[] fileItems = new String[] {"New Diagram", "Open", "Save", "Import Diagram", "Export Diagram", "Close/Remove Diagram"};
  private String[] editItems = new String[] {"Undo", "Redo", "Cut", "Copy", "Paste", "Rotate Left", "Rotate Right", "Rename Diagram", "Delete Element"};
  private String[] viewItems = new String[] {"Zoom In", "Zoom Out"};
  private String[] windowItems = new String[] {"Cascade Windows", "Tile Windows Vertically", "Tile Windows Horizontally", "Previous Window", "Next Window"};
  private String[] helpItems = new String[] {"About"};

  private char[] fileMnemonics = {'N', 'O', 'S', 'I', 'E', 'C'};
  private char[] editMnemonics = {'U', 'R', 'C', 'Y', 'P', 'L', 'R', 'n', 'D'};
  private char[] viewMnemonics = {'I', 'O'};
  private char[] windowMnemonics = {'C', 'V', 'H', 'P', 'N'};
  private char[] helpMnemonics = {'A'};

  public MenuBar()
  {
    // Create all menus
    for (int i = 0; i < menus.length; i++)
    {
      JMenu menu = new JMenu(menus[i]);
      menu.setMnemonic(menuMnemonics[i]);
      menuArray[i] = menu;
    }

    // Populate the "File" menu
    for (int i = 0; i < fileItems.length; i++)
    {
      PlaceholderAction action = new PlaceholderAction(fileItems[i], new Integer(fileMnemonics[i]));
      JMenuItem item = new JMenuItem(action);
      menuArray[0].add(item);
    }

    // Populate the "Edit" menu
    for (int i = 0; i < editItems.length; i++)
    {
      PlaceholderAction action = new PlaceholderAction(editItems[i], new Integer(editMnemonics[i]));
      JMenuItem item = new JMenuItem(action);
      menuArray[1].add(item);
    }

    // Populate the "View" menu
    for (int i = 0; i < viewItems.length; i++)
    {
      PlaceholderAction action = new PlaceholderAction(viewItems[i], new Integer(viewMnemonics[i]));
      JMenuItem item = new JMenuItem(action);
      menuArray[2].add(item);
    }

    // Populate the "Window" menu
    for (int i = 0; i < windowItems.length; i++)
    {
      PlaceholderAction action = new PlaceholderAction(windowItems[i], new Integer(windowMnemonics[i]));
      JMenuItem item = new JMenuItem(action);
      menuArray[3].add(item);
    }

    // Populate the "Help" menu
    for (int i = 0; i < helpItems.length; i++)
    {
      PlaceholderAction action = new PlaceholderAction(helpItems[i], new Integer(helpMnemonics[i]));
      JMenuItem item = new JMenuItem(action);
      menuArray[4].add(item);
    }

    // Add all created menus to the menu bar
    for (int i = 0; i < menus.length; i++)
    {
      this.add(menuArray[i]);
    }
  }
}

@@ -1463,32 +1463,263 @@
 gth; i++)%0A    %7B%0A
+      ImageIcon icon;%0A      if (i == fileItems.length - 1) %7B icon = new ImageIcon(%22images/Top Panel/%22 + %22Close Remove Diagram%22 + %22.jpg%22); %7D // dirty%0A      else %7B icon = new ImageIcon(%22images/Top Panel/%22 + fileItems%5Bi%5D + %22.jpg%22); %7D%0A
       Placeholde
@@ -1762,32 +1762,38 @@
 on(fileItems%5Bi%5D,
+ icon,
  new Integer(fil
@@ -1969,32 +1969,115 @@
 gth; i++)%0A    %7B%0A
+      ImageIcon icon = new ImageIcon(%22images/Top Panel/%22 + editItems%5Bi%5D + %22.jpg%22);%0A
       Placeholde
@@ -2120,32 +2120,38 @@
 on(editItems%5Bi%5D,
+ icon,
  new Integer(edi
@@ -2327,32 +2327,115 @@
 gth; i++)%0A    %7B%0A
+      ImageIcon icon = new ImageIcon(%22images/Top Panel/%22 + viewItems%5Bi%5D + %22.jpg%22);%0A
       Placeholde
@@ -2478,32 +2478,38 @@
 on(viewItems%5Bi%5D,
+ icon,
  new Integer(vie
@@ -2689,32 +2689,117 @@
 gth; i++)%0A    %7B%0A
+      ImageIcon icon = new ImageIcon(%22images/Top Panel/%22 + windowItems%5Bi%5D + %22.jpg%22);%0A
       Placeholde
@@ -2844,32 +2844,38 @@
 (windowItems%5Bi%5D,
+ icon,
  new Integer(win
@@ -3057,24 +3057,107 @@
  i++)%0A    %7B%0A
+      ImageIcon icon = new ImageIcon(%22images/Top Panel/%22 + helpItems%5Bi%5D + %22.jpg%22);%0A
       Placeh
@@ -3212,16 +3212,22 @@
 tems%5Bi%5D,
+ icon,
  new Int

Add toolbar icons to all menu bar items.