001package jmri.jmrit.beantable; 002 003import java.util.List; 004 005import javax.annotation.Nonnull; 006import javax.swing.event.ChangeEvent; 007import javax.swing.JTabbedPane; 008import jmri.*; 009 010public class IdTagTableTabAction extends AbstractTableTabAction<IdTag> { 011 012 public IdTagTableTabAction(String s) { 013 super(s); 014 } 015 016 public IdTagTableTabAction() { 017 this("Multiple Tabbed"); 018 } 019 020 /** {@inheritDoc} */ 021 @Override 022 @Nonnull 023 protected Manager<IdTag> getManager() { 024 return InstanceManager.getDefault(IdTagManager.class); 025 } 026 027 /** {@inheritDoc} */ 028 @Override 029 protected String getClassName() { 030 return IdTagTableAction.class.getName(); 031 } 032 033 /** {@inheritDoc} */ 034 @Override 035 protected IdTagTableAction getNewTableAction(String choice) { 036 return new IdTagTableAction(choice); 037 } 038 039 /** {@inheritDoc} */ 040 @Override 041 protected String helpTarget() { 042 return "package.jmri.jmrit.beantable.IdTagTable"; 043 } 044 045 @Override 046 protected void createModel() { 047 dataTabs = new JTabbedPane(); 048 if (getManager() instanceof jmri.managers.AbstractProxyManager) { 049 // build the list, with default at start and internal at end (if present) 050 jmri.managers.AbstractProxyManager<IdTag> proxy = (jmri.managers.AbstractProxyManager<IdTag>) getManager(); 051 052 tabbedTableArray.add(new TabbedTableItem<>(Bundle.getMessage("All"), true, getManager(), getNewTableAction("All"))); // NOI18N 053 054 List<jmri.Manager<IdTag>> managerList = proxy.getDisplayOrderManagerList(); 055 for (Manager<IdTag> manager : managerList) { 056 String manuName = manager.getMemo().getUserName(); 057 if (manuName == null && (manager instanceof jmri.managers.DefaultRailComManager)) { 058 manuName = "RailCom"; // NOI18N (proper name). 059 } 060 TabbedTableItem<IdTag> itemModel = new TabbedTableItem<>(manuName, true, manager, getNewTableAction(manuName)); // connection name to display in Tab 061 tabbedTableArray.add(itemModel); 062 } 063 064 } else { 065 String manuName = getManager().getMemo().getUserName(); 066 tabbedTableArray.add(new TabbedTableItem<>(manuName, true, getManager(), getNewTableAction(manuName))); 067 } 068 for (int x = 0; x < tabbedTableArray.size(); x++) { 069 AbstractTableAction<IdTag> table = tabbedTableArray.get(x).getAAClass(); 070 table.addToPanel(this); 071 dataTabs.addTab(tabbedTableArray.get(x).getItemString(), null, tabbedTableArray.get(x).getPanel(), null); 072 } 073 dataTabs.addChangeListener((ChangeEvent evt) -> setMenuBar(f)); 074 init = true; 075 } 076 077}