<commit_before>/*
 *                  BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 * 
 * Created on Jan 25, 2006
 *
 */
package org.biojava.spice.gui;

import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

import org.biojava.spice.SpiceApplication;

public class MenuCreator {

    public MenuCreator() {
        super();

    }
    
    public static JMenu createAlignmentMenu(SpiceMenuListener ml){
        JMenu amenu = new JMenu("Alignment");
        JMenuItem region = new JMenuItem("Toggle full structure");
        region.addActionListener(ml);
        region.setMnemonic(KeyEvent.VK_T);
        amenu.add(region);
        return amenu;
    }

    public static ImageIcon createImageIcon(String name){
        return SpiceApplication.createImageIcon(name);
    }
    
    public static JMenu createHelpMenu(SpiceMenuListener ml){
        JMenu help = new JMenu("Help");
        help.setMnemonic(KeyEvent.VK_H);
        help.getAccessibleContext().setAccessibleDescription("get help");
      
        
        ImageIcon helpIcon = createImageIcon("help.png");
        
        JMenuItem aboutspice;
        if ( helpIcon == null )
            aboutspice = new JMenuItem("About SPICE");
        else
            aboutspice = new JMenuItem("About SPICE",helpIcon);
        aboutspice.addActionListener  ( ml );
        aboutspice.setMnemonic(KeyEvent.VK_A);
        help.add(aboutspice);
        
        JMenuItem techinfo;
        if ( helpIcon == null )
            techinfo = new JMenuItem("Tech Info");
        else
            techinfo = new JMenuItem("Tech Info", helpIcon);
        techinfo.addActionListener(ml);
        techinfo.setMnemonic(KeyEvent.VK_T);
        help.add(techinfo);
        
        
        JMenuItem spicemanual;
        ImageIcon manualIcon =  createImageIcon("toggle_log.png");
        if ( manualIcon == null)
            spicemanual = new JMenuItem("Manual");
        else
            spicemanual = new JMenuItem("Manual",manualIcon);
        spicemanual.addActionListener(ml);
        spicemanual.setMnemonic(KeyEvent.VK_M);
        help.add(spicemanual);
       
        
        return help;   
    }
    
    public static JMenu createFileMenu(SpiceMenuListener ml){
        JMenu file = new JMenu("File");
        file.setMnemonic(KeyEvent.VK_F);
        file.getAccessibleContext().setAccessibleDescription("the file menu");
        
        
        JMenuItem newWindow;
        ImageIcon nwIcon = createImageIcon("window_new.png");
        if ( nwIcon == null)
            newWindow = new JMenuItem("New Window");
        else 
            newWindow = new JMenuItem("New Window", nwIcon);
        
        newWindow.setMnemonic(KeyEvent.VK_N);
        
        
        JMenuItem newTab;
        ImageIcon tabIcon = createImageIcon("view-right.png");
        if ( tabIcon == null)
            newTab = new JMenuItem("New Tab");
        else
            newTab = new JMenuItem("New Tab", tabIcon);
        
        JMenuItem openpdb;
        ImageIcon openIcon = createImageIcon("network.png");
        if ( openIcon == null)
            openpdb = new JMenuItem("Open");
        else
            openpdb = new JMenuItem("Open", openIcon);
        
        openpdb.setMnemonic(KeyEvent.VK_O);
        
        // currently disabled
        /*JMenuItem align;
        ImageIcon alignIcon = createImageIcon("align.png");
        if ( alignIcon == null) {
            align = new JMenuItem("Align");
        } else
            align = new JMenuItem("Align", alignIcon);
        align.setMnemonic(KeyEvent.VK_A);
        */
        
        /*
        JMenuItem save ;
        ImageIcon saveIcon = createImageIcon("3floppy_unmount.png");
        if ( saveIcon == null)
            save = new JMenuItem("Save");
        else
            save = new JMenuItem("Save",saveIcon);
        save.setMnemonic(KeyEvent.VK_S);
        
        JMenuItem revert;
        ImageIcon revertIcon = createImageIcon("revert.png");
        if (revertIcon == null)
            revert = new JMenuItem("Load");
        else
            revert = new JMenuItem("Load",revertIcon);
        revert.setMnemonic(KeyEvent.VK_L);
        */
        
        ImageIcon exitIcon = createImageIcon("exit.png");
        JMenuItem exit;
        if ( exitIcon != null)
            exit    = new JMenuItem("Exit",exitIcon);
        else
            exit    = new JMenuItem("Exit");
        exit.setMnemonic(KeyEvent.VK_X);
        
        ImageIcon propIcon = createImageIcon("configure.png");
        JMenuItem props ;
        if ( propIcon != null )
            props   = new JMenuItem("Properties",propIcon);
        else
            props   = new JMenuItem("Properties");
        props.setMnemonic(KeyEvent.VK_P);
      
        newWindow.addActionListener(ml );
        newTab.addActionListener (  ml );
        openpdb.addActionListener(  ml );
        //align.addActionListener  (  ml );
        //save.addActionListener   (  ml );
        //revert.addActionListener (  ml );
        exit.addActionListener   (  ml );
        props.addActionListener  (  ml );<commit_msg>added new .properties for Menu<commit_after>/*
 *                  BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 * 
 * Created on Jan 25, 2006
 *
 */
package org.biojava.spice.gui;

import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ResourceBundle;

import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

import org.biojava.spice.SpiceApplication;

public class MenuCreator {

    static String baseName = "spice";
    static ResourceBundle bundle = ResourceBundle.getBundle(baseName);
    
    public MenuCreator() {
        super();

    }
    
    public static JMenu createAlignmentMenu(SpiceMenuListener ml){
        String menuText = bundle.getString("org.biojava.spice.gui.menu.AlignmentMenu");
        JMenu amenu = new JMenu(menuText);
        String toggleText = bundle.getString("org.biojava.spice.gui.menu.AlignmentToggleStructure");
        JMenuItem region = new JMenuItem(toggleText);
        region.addActionListener(ml);
        region.setMnemonic(KeyEvent.VK_T);
        amenu.add(region);
        return amenu;
    }

    public static ImageIcon createImageIcon(String name){
        return SpiceApplication.createImageIcon(name);
    }
    
    public static JMenu createHelpMenu(SpiceMenuListener ml){
        String menuText = bundle.getString("org.biojava.spice.gui.menu.HelpMenu");
        JMenu help = new JMenu(menuText);
        help.setMnemonic(KeyEvent.VK_H);
        String helpDesc = bundle.getString("org.biojava.spice.gui.menu.HelpMenuDesc");
        help.getAccessibleContext().setAccessibleDescription(helpDesc);
      
        
        ImageIcon helpIcon = createImageIcon("help.png");
        
        String aboutSpice = bundle.getString("org.biojava.spice.gui.menu.AboutSpice");
        JMenuItem aboutspice;
        if ( helpIcon == null )
            aboutspice = new JMenuItem(aboutSpice);
        else
            aboutspice = new JMenuItem(aboutSpice,helpIcon);
        aboutspice.addActionListener  ( ml );
        aboutspice.setMnemonic(KeyEvent.VK_A);
        help.add(aboutspice);
        
        String techInfo = bundle.getString("org.biojava.spice.gui.menu.TechInfo");
        JMenuItem techinfo;
        if ( helpIcon == null )
            techinfo = new JMenuItem(techInfo);
        else
            techinfo = new JMenuItem(techInfo, helpIcon);
        techinfo.addActionListener(ml);
        techinfo.setMnemonic(KeyEvent.VK_T);
        help.add(techinfo);
        
        String manual = bundle.getString("org.biojava.spice.gui.menu.Manual");
        JMenuItem spicemanual;
        ImageIcon manualIcon =  createImageIcon("toggle_log.png");
        if ( manualIcon == null)
            spicemanual = new JMenuItem(manual);
        else
            spicemanual = new JMenuItem(manual,manualIcon);
        spicemanual.addActionListener(ml);
        spicemanual.setMnemonic(KeyEvent.VK_M);
        help.add(spicemanual);
       
        
        return help;   
    }
    
    public static JMenu createFileMenu(SpiceMenuListener ml){
        String fileMenu = bundle.getString("org.biojava.spice.gui.menu.FileMenu");
        JMenu file = new JMenu(fileMenu);
        file.setMnemonic(KeyEvent.VK_F);
        String fileMenuDesc =bundle.getString("org.biojava.spice.gui.menu.FileMenuDesc");
        file.getAccessibleContext().setAccessibleDescription(fileMenuDesc);
        
        String newWindowTxt =bundle.getString("org.biojava.spice.gui.menu.NewWindow");
        JMenuItem newWindow;
        ImageIcon nwIcon = createImageIcon("window_new.png");
        if ( nwIcon == null)
            newWindow = new JMenuItem(newWindowTxt);
        else 
            newWindow = new JMenuItem(newWindowTxt, nwIcon);
        
        newWindow.setMnemonic(KeyEvent.VK_N);
        
        String newTabTxt =bundle.getString("org.biojava.spice.gui.menu.NewTab");
        JMenuItem newTab;
        ImageIcon tabIcon = createImageIcon("view-right.png");
        if ( tabIcon == null)
            newTab = new JMenuItem(newTabTxt);
        else
            newTab = new JMenuItem(newTabTxt, tabIcon);
        
        String openTxt =bundle.getString("org.biojava.spice.gui.menu.Open");
        JMenuItem openpdb;
        ImageIcon openIcon = createImageIcon("network.png");
        if ( openIcon == null)
            openpdb = new JMenuItem(openTxt);
        else
            openpdb = new JMenuItem(openTxt, openIcon);
        
        openpdb.setMnemonic(KeyEvent.VK_O);
        
        // currently disabled
        /*JMenuItem align;
        ImageIcon alignIcon = createImageIcon("align.png");
        if ( alignIcon == null) {
            align = new JMenuItem("Align");
        } else
            align = new JMenuItem("Align", alignIcon);
        align.setMnemonic(KeyEvent.VK_A);
        */
        
        /*
        JMenuItem save ;
        ImageIcon saveIcon = createImageIcon("3floppy_unmount.png");
        if ( saveIcon == null)
            save = new JMenuItem("Save");
        else
            save = new JMenuItem("Save",saveIcon);
        save.setMnemonic(KeyEvent.VK_S);
        
        JMenuItem revert;
        ImageIcon revertIcon = createImageIcon("revert.png");
        if (revertIcon == null)
            revert = new JMenuItem("Load");
        else
            revert = new JMenuItem("Load",revertIcon);
        revert.setMnemonic(KeyEvent.VK_L);
        */
        
        String exitTxt =bundle.getString("org.biojava.spice.gui.menu.Exit");
        ImageIcon exitIcon = createImageIcon("exit.png");
        JMenuItem exit;
        if ( exitIcon != null)
            exit    = new JMenuItem(exitTxt,exitIcon);
        else
            exit    = new JMenuItem(exitTxt);
        exit.setMnemonic(KeyEvent.VK_X);
        
        String propertiesTxt =bundle.getString("org.biojava.spice.gui.menu.Properties");
        ImageIcon propIcon = createImageIcon("configure.png");
        JMenuItem props ;
        if ( propIcon != null )
            props   = new JMenuItem(propertiesTxt,propIcon);
        else
            props   = new JMenuItem(propertiesTxt);
        props.setMnemonic(KeyEvent.VK_P);
      
        newWindow.addActionListener(ml );
        newTab.addActionListener (  ml );
        openpdb.addActionListener(  ml );
        //align.addActionListener  (  ml );
        //save.addActionListener   (  ml );
        //revert.addActionListener (  ml );
        exit.addActionListener   (  ml );
        props.addActionListener  (  ml );
{'fraction_non_alphanumeric': 0.09959125923596919, 'fraction_numerical': 0.0011004559031598806, 'mean_word_length': 2.212878787878788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3389246', 'n_tokens_mistral': 3706, 'n_tokens_neox': 3636, 'n_words': 779}