001package jmri.jmrit.operations.rollingstock.engines; 002 003import javax.swing.AbstractAction; 004import javax.swing.JMenu; 005 006import org.slf4j.Logger; 007import org.slf4j.LoggerFactory; 008 009import jmri.jmrit.operations.rollingstock.engines.tools.*; 010 011/** 012 * Provides a context-specific menu for handling the Roster. 013 * 014 * @author Bob Jacobsen Copyright (C) 2001, 2002 015 * @author Dennis Miller Copyright (C) 2005 016 * @author Daniel Boudreau Copyright (C) 2007, 2012 017 */ 018public class EngineRosterMenu extends JMenu { 019 020 /** 021 * Ctor argument defining that the menu object will be used as part of the 022 * main menu of the program, away from any GUI that can select or use a 023 * RosterEntry. 024 */ 025 static public final int MAINMENU = 1; 026 027 /** 028 * Ctor argument defining that the menu object will be used as a menu on a 029 * GUI object that can select a RosterEntry. 030 */ 031 static public final int SELECTMENU = 2; 032 033 /** 034 * Ctor argument defining that the menu object will be used as a menu on a 035 * GUI object that is dealing with a single RosterEntry. 036 */ 037 static public final int ENTRYMENU = 3; 038 039 /** 040 * Creates a roster menu for locomotives. 041 * 042 * @param pMenuName Name for the menu 043 * @param pMenuType Select where the menu will be used, hence the right set 044 * of items to be enabled. 045 * @param pWho The Component using this menu, used to ensure that dialog 046 * boxes will pop in the right place. 047 */ 048 public EngineRosterMenu(String pMenuName, int pMenuType, EnginesTableFrame pWho) { 049 super(pMenuName); 050 051 // create the menu 052 AbstractAction importRosterAction = new ImportRosterEngineAction(); 053 AbstractAction exportAction = new ExportEngineRosterAction(); 054 AbstractAction importAction = new ImportEngineAction(); 055 AbstractAction deleteAction = new DeleteEngineRosterAction(); 056 AbstractAction resetMovesAction = new ResetEngineMovesAction(); 057 AbstractAction printAction = new PrintEngineRosterAction(false, pWho); 058 AbstractAction previewAction = new PrintEngineRosterAction(true, pWho); 059 060 add(importRosterAction); 061 add(importAction); 062 add(exportAction); 063 add(deleteAction); 064 add(resetMovesAction); 065 addSeparator(); 066 add(printAction); 067 add(previewAction); 068 069 // activate the right items 070 switch (pMenuType) { 071 case MAINMENU: 072 case SELECTMENU: 073 case ENTRYMENU: 074 break; 075 default: 076 log.error("RosterMenu constructed without a valid menuType parameter: {}", pMenuType); 077 } 078 } 079 080 // initialize logging 081 private final static Logger log = LoggerFactory.getLogger(EngineRosterMenu.class.getName()); 082 083}