001package jmri.jmrit.beantable; 002 003import java.awt.event.ActionEvent; 004import jmri.InstanceManager; 005import jmri.Route; 006import jmri.jmrit.beantable.routetable.RouteAddFrame; 007import jmri.util.JmriJFrame; 008 009/** 010 * Swing action to create and register a Route Table. 011 * 012 * Based in part on {@link SignalHeadTableAction} by Bob Jacobsen 013 * 014 * @author Dave Duchamp Copyright (C) 2004 015 * @author Bob Jacobsen Copyright (C) 2007 016 * @author Simon Reader Copyright (C) 2008 017 * @author Pete Cressman Copyright (C) 2009 018 * @author Egbert Broerse Copyright (C) 2016 019 * @author Paul Bender Colyright (C) 2020 020 */ 021public class RouteTableAction extends AbstractTableAction<Route> { 022 023 /** 024 * Create an action with a specific title. 025 * <p> 026 * Note that the argument is the Action title, not the title of the 027 * resulting frame. Perhaps this should be changed? 028 * 029 * @param s title of the action 030 */ 031 public RouteTableAction(String s) { 032 super(s); 033 // disable ourself if there is no primary Route manager available 034 if (InstanceManager.getNullableDefault(jmri.RouteManager.class) == null) { 035 super.setEnabled(false); 036 } 037 } 038 039 public RouteTableAction() { 040 this(Bundle.getMessage("TitleRouteTable")); 041 } 042 043 /** 044 * Create the JTable DataModel, along with the changes for the specific case 045 * of Routes. 046 */ 047 @Override 048 protected void createModel() { 049 m = new RouteTableDataModel(); 050 } 051 052 @Override 053 protected void setTitle() { 054 f.setTitle(Bundle.getMessage("TitleRouteTable")); 055 } 056 057 @Override 058 protected String helpTarget() { 059 return "package.jmri.jmrit.beantable.RouteTable"; 060 } 061 062 063 @Override 064 protected void addPressed(ActionEvent e) { 065 066 final JmriJFrame addFrame = new RouteAddFrame(); 067 // display the window 068 addFrame.setVisible(true); 069 addFrame.setEscapeKeyClosesWindow(true); 070 } 071 072 @Override 073 public void setMessagePreferencesDetails() { 074 InstanceManager.getDefault(jmri.UserPreferencesManager.class) 075 .setPreferenceItemDetails(getClassName(), "remindSaveRoute", Bundle.getMessage("HideSaveReminder")); 076 super.setMessagePreferencesDetails(); 077 } 078 079 @Override 080 protected String getClassName() { 081 return RouteTableAction.class.getName(); 082 } 083 084 @Override 085 public String getClassDescription() { 086 return Bundle.getMessage("TitleRouteTable"); 087 } 088 089}