001package jmri.jmrit.picker;
002
003import java.util.ArrayList;
004import java.util.HashMap;
005import java.util.Iterator;
006import java.util.List;
007import java.util.ResourceBundle;
008import java.util.TreeSet;
009import javax.annotation.CheckForNull;
010import javax.annotation.Nonnull;
011import javax.swing.JTable;
012import javax.swing.ListSelectionModel;
013import javax.swing.SortOrder;
014import javax.swing.table.TableColumn;
015import javax.swing.table.TableColumnModel;
016import javax.swing.table.TableRowSorter;
017import jmri.*;
018import jmri.jmrit.beantable.BeanTableDataModel;
019import jmri.jmrit.entryexit.*;
020import jmri.jmrit.logix.*;
021import jmri.swing.RowSorterUtil;
022import jmri.util.*;
023import jmri.util.swing.XTableColumnModel;
024import org.slf4j.Logger;
025import org.slf4j.LoggerFactory;
026
027/**
028 * Abstract class to make pick lists for NamedBeans; Table model for pick lists
029 * in IconAdder
030 * <p>
031 * Concrete pick list class for many beans are include at the end of this file.
032 * This class also has instantiation methods serve as a factory for those
033 * classes.
034 * <p>
035 * Note: Extensions of this class must call init() after instantiation.
036 *
037 * <hr>
038 * This file is part of JMRI.
039 * <p>
040 * JMRI is free software; you can redistribute it and/or modify it under the
041 * terms of version 2 of the GNU General Public License as published by the Free
042 * Software Foundation. See the "COPYING" file for a copy of this license.
043 * <p>
044 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
045 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
046 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
047 *
048 * @param <E> the supported type of NamedBean
049 * @author Pete Cressman Copyright (C) 2009, 2010
050 */
051public abstract class PickListModel<E extends NamedBean> extends BeanTableDataModel<E> {
052
053    protected ArrayList<E> _pickList;
054    protected String _name;
055    private JTable _table;       // table using this model
056    protected TableRowSorter<PickListModel<E>> _sorter;
057
058    public static final int SNAME_COLUMN = 0;
059    public static final int UNAME_COLUMN = 1;
060    public static final int POSITION_COL = 2;
061    public static final ResourceBundle rb = ResourceBundle.getBundle("jmri.jmrit.beantable.BeanTableBundle");
062
063    static HashMap<String, Integer> _listMap = new HashMap<String, Integer>();
064
065    static public int getNumInstances(@Nonnull String type) {
066        Integer num = _listMap.get(type.toLowerCase());
067        log.debug("getNumInstances of {} num={}", type, num);
068        if (num != null) {
069            return num;
070        }
071        return 0;
072    }
073
074    /**
075     * Default constructor makes a table sorted by System Name.
076     */
077    public PickListModel() {
078        super();
079    }
080
081    /**
082     * If table has been sorted table row no longer is the same as array index.
083     *
084     * @param index row of table
085     * @return bean at index or null if index is out of range
086     */
087    @CheckForNull
088    public E getBeanAt(int index) {
089        if (index >= _pickList.size()) {
090            return null;
091        }
092        return _pickList.get(index);
093    }
094
095    public int getIndexOf(@Nonnull E bean) {
096        for (int i = 0; i < _pickList.size(); i++) {
097            if (_pickList.get(i).equals(bean)) {
098                return i;
099            }
100        }
101        return -1;
102    }
103
104    @Nonnull
105    public List<E> getBeanList() {
106        return _pickList;
107    }
108
109    /**
110     * override BeanTableDataModel only lists SystemName
111     */
112    @Override
113    protected synchronized void updateNameList() {
114        makePickList();
115    }
116
117    private void makePickList() {
118        // Don't know who is added or deleted so remove all name change listeners
119        if (_pickList != null) {
120            for (int i = 0; i < _pickList.size(); i++) {
121                _pickList.get(i).removePropertyChangeListener(this);
122            }
123        }
124        TreeSet<E> ts = new TreeSet<>(new NamedBeanComparator<>());
125        ts.addAll(getManager().getNamedBeanSet());
126
127        _pickList = new ArrayList<>(getManager().getNamedBeanSet().size());
128
129        Iterator<E> it = ts.iterator();
130        while (it.hasNext()) {
131            E elt = it.next();
132            _pickList.add(elt);
133        }
134        // add name change listeners
135        for (int i = 0; i < _pickList.size(); i++) {
136            _pickList.get(i).addPropertyChangeListener(this);
137        }
138        log.debug("_pickList has {} beans", _pickList.size());
139    }
140
141    /** {@inheritDoc} */
142    @Override
143    @CheckForNull
144    public E getBySystemName(@Nonnull String name) {
145        return getManager().getBySystemName(name);
146    }
147
148    /** {@inheritDoc} */
149    @Override
150    @CheckForNull
151    protected E getByUserName(@Nonnull String name) {
152        return getManager().getByUserName(name);
153    }
154
155    /** {@inheritDoc} */
156    @Override
157    @Nonnull
158    abstract public Manager<E> getManager();
159
160    /**
161     * Return bean with name given in parameter. Create if needed and possible.
162     *
163     * @param name the name for the bean
164     * @return the bean or null if not made
165     */
166    @CheckForNull
167    abstract public E addBean(@Nonnull String name);
168
169    @CheckForNull
170    abstract public E addBean(@Nonnull String sysName, String userName);
171
172    /**
173     * Check if beans can be added by this model.
174     *
175     * @return true if model can create beans; false otherwise
176     */
177    abstract public boolean canAddBean();
178
179    // these BeanTableDataModel abstract methods not needed
180    /** {@inheritDoc} */
181    @Override
182    protected String getMasterClassName() {
183        return "PickListModel";
184    }
185
186    /** {@inheritDoc} */
187    @Override
188    public void clickOn(E t) {
189    }
190
191    /** {@inheritDoc} */
192    @Override
193    public Class<?> getColumnClass(int c) {
194        return String.class;
195    }
196
197    /** {@inheritDoc} */
198    @Override
199    public int getColumnCount() {
200        return 2;
201    }
202
203    /** {@inheritDoc} */
204    @Override
205    public String getColumnName(int c) {
206        if (c == SNAME_COLUMN) {
207            return Bundle.getMessage("ColumnSystemName");
208        } else if (c == UNAME_COLUMN) {
209            return Bundle.getMessage("ColumnUserName");
210        }
211        return "";
212    }
213
214    /** {@inheritDoc} */
215    @Override
216    public boolean isCellEditable(int r, int c) {
217        return false;
218    }
219
220    /** {@inheritDoc} */
221    @Override
222    public int getRowCount() {
223        return _pickList.size();
224    }
225
226    /** {@inheritDoc} */
227    @Override
228    public Object getValueAt(int r, int c) {
229        // some error checking
230        if (r >= _pickList.size()) {
231            log.debug("row is greater than picklist size");
232            return null;
233        }
234        if (c == SNAME_COLUMN) {
235            return _pickList.get(r).getSystemName();
236        } else if (c == UNAME_COLUMN) {
237            return _pickList.get(r).getUserName();
238        }
239        return null;
240    }
241
242    /** {@inheritDoc} */
243    @Override
244    public void setValueAt(Object type, int r, int c) {
245    }
246
247    // these BeanTableDataModel abstract methods not needed
248    /** {@inheritDoc} */
249    @Override
250    public String getValue(String systemName) {
251        return systemName;
252    }
253
254    public String getName() {
255        return _name;
256    }
257
258    /** {@inheritDoc} */
259    @Override
260    protected String getBeanType() {
261        return _name;
262    }
263
264    /**
265     * Handle additions and deletions in the table and changes to beans within
266     * the table.
267     *
268     * @param e the change
269     */
270    @Override
271    public void propertyChange(java.beans.PropertyChangeEvent e) {
272        if (e.getPropertyName().equals("length")) {
273            // a NamedBean added or deleted
274            makePickList();
275            fireTableDataChanged();
276        }
277        if (e.getSource() instanceof NamedBean) {
278            NamedBean bean = (NamedBean) e.getSource();
279            for (int i = 0; i < _pickList.size(); i++) {
280                if (bean.equals(_pickList.get(i))) {
281                    fireTableRowsUpdated(i, i);
282                    break;
283                }
284            }
285        }
286        if (log.isDebugEnabled()) {
287            log.debug("propertyChange of \"{}\" for {}", e.getPropertyName(), e.getSource().toString());
288        }
289    }
290
291    /**
292     * Make pick table, DND enabled.
293     * @return the table
294     */
295    public JTable makePickTable() {
296        _sorter = new TableRowSorter<>(this);
297        _table = new JTable(this) {
298            /**
299             * Overridden to prevent empty cells from being selected
300             */
301            @Override
302            public void changeSelection(int row, int col, boolean toggle, boolean extend) {
303                if (super.getValueAt(row, col) != null) {
304                    super.changeSelection(row, col, toggle, extend);
305                }
306            }
307        };
308        _sorter.setComparator(SNAME_COLUMN, new jmri.util.AlphanumComparator());
309        _sorter.setComparator(UNAME_COLUMN, new jmri.util.AlphanumComparator());
310        RowSorterUtil.setSortOrder(_sorter, SNAME_COLUMN, SortOrder.ASCENDING);
311        _table.setRowSorter(_sorter);
312
313        _table.setRowSelectionAllowed(true);
314        _table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
315        _table.setPreferredScrollableViewportSize(new java.awt.Dimension(250, _table.getRowHeight() * 7));
316        _table.setDragEnabled(true);
317        _table.setTransferHandler(new DnDTableExportHandler());
318
319        _table.getTableHeader().setReorderingAllowed(true);
320        _table.setColumnModel(new XTableColumnModel());
321        _table.createDefaultColumnsFromModel();
322        TableColumnModel columnModel = _table.getColumnModel();
323
324        TableColumn sNameColumnT = columnModel.getColumn(SNAME_COLUMN);
325        sNameColumnT.setResizable(true);
326        sNameColumnT.setMinWidth(50);
327        //sNameColumnT.setMaxWidth(200);
328
329        TableColumn uNameColumnT = columnModel.getColumn(UNAME_COLUMN);
330        uNameColumnT.setResizable(true);
331        uNameColumnT.setMinWidth(100);
332        //uNameColumnT.setMaxWidth(300);
333
334        addMouseListenerToHeader(_table);
335        _table.setAutoCreateColumnsFromModel(false);
336
337        return _table;
338    }
339
340    public void makeSorter(@Nonnull JTable table) {
341        _sorter = new TableRowSorter<>(this);
342        _sorter.setComparator(SNAME_COLUMN, new jmri.util.AlphanumComparator());
343        _sorter.setComparator(UNAME_COLUMN, new jmri.util.AlphanumComparator());
344        RowSorterUtil.setSortOrder(_sorter, SNAME_COLUMN, SortOrder.ASCENDING);
345        table.setRowSorter(_sorter);
346    }
347
348    @Nonnull
349    public JTable getTable() {
350        return _table;
351    }
352
353    /** {@inheritDoc} */
354    @Override
355    public void dispose() {
356        getManager().removePropertyChangeListener(this);
357    }
358
359    @Nonnull
360    public static PickListModel<Turnout> turnoutPickModelInstance() {
361        Integer num = _listMap.get("turnout");
362        if (num != null) {
363            _listMap.put("turnout", num + 1);
364        } else {
365            _listMap.put("turnout", 1);
366        }
367        return new TurnoutPickModel();
368    }
369
370    @Nonnull
371    public static PickListModel<Sensor> sensorPickModelInstance() {
372        Integer num = _listMap.get("sensor");
373        if (num != null) {
374            _listMap.put("sensor", num + 1);
375        } else {
376            _listMap.put("sensor", 1);
377        }
378        return new SensorPickModel();
379    }
380
381    @Nonnull
382    public static PickListModel<Sensor> multiSensorPickModelInstance() {
383        Integer num = _listMap.get("multisensor");
384        if (num != null) {
385            _listMap.put("multisensor", num + 1);
386        } else {
387            _listMap.put("multisensor", 1);
388        }
389        return new MultiSensorPickModel();
390    }
391
392    @Nonnull
393    public static PickListModel<SignalHead> signalHeadPickModelInstance() {
394        Integer num = _listMap.get("signalhead");
395        if (num != null) {
396            _listMap.put("signalhead", num + 1);
397        } else {
398            _listMap.put("signalhead", 1);
399        }
400        return new SignalHeadPickModel();
401    }
402
403    @Nonnull
404    public static PickListModel<SignalMast> signalMastPickModelInstance() {
405        Integer num = _listMap.get("signalmast");
406        if (num != null) {
407            _listMap.put("signalmast", num + 1);
408        } else {
409            _listMap.put("signalmast", 1);
410        }
411        return new SignalMastPickModel();
412    }
413
414    @Nonnull
415    public static PickListModel<Memory> memoryPickModelInstance() {
416        Integer num = _listMap.get("memory");
417        if (num != null) {
418            _listMap.put("memory", num + 1);
419        } else {
420            _listMap.put("memory", 1);
421        }
422        return new MemoryPickModel();
423    }
424
425    @Nonnull
426    public static PickListModel<Block> blockPickModelInstance() {
427        Integer num = _listMap.get("block");
428        if (num != null) {
429            _listMap.put("block", num + 1);
430        } else {
431            _listMap.put("block", 1);
432        }
433        return new BlockPickModel();
434    }
435
436    @Nonnull
437    public static PickListModel<Reporter> reporterPickModelInstance() {
438        Integer num = _listMap.get("reporter");
439        if (num != null) {
440            _listMap.put("reporter", num + 1);
441        } else {
442            _listMap.put("reporter", 1);
443        }
444        return new ReporterPickModel();
445    }
446
447    @Nonnull
448    public static PickListModel<Light> lightPickModelInstance() {
449        Integer num = _listMap.get("light");
450        if (num != null) {
451            _listMap.put("light", num + 1);
452        } else {
453            _listMap.put("light", 1);
454        }
455        return new LightPickModel();
456    }
457
458    @Nonnull
459    public static PickListModel<OBlock> oBlockPickModelInstance() {
460        Integer num = _listMap.get("oBlock");
461        if (num != null) {
462            _listMap.put("oBlock", num + 1);
463        } else {
464            _listMap.put("oBlock", 1);
465        }
466        return new OBlockPickModel();
467    }
468
469    @Nonnull
470    public static PickListModel<Warrant> warrantPickModelInstance() {
471        Integer num = _listMap.get("warrant");
472        if (num != null) {
473            _listMap.put("warrant", num + 1);
474        } else {
475            _listMap.put("warrant", 1);
476        }
477        return new WarrantPickModel();
478    }
479
480    @Nonnull
481    public static PickListModel<DestinationPoints> entryExitPickModelInstance() {
482        Integer num = _listMap.get("entryExit");
483        if (num != null) {
484            _listMap.put("entryExit", num + 1);
485        } else {
486            _listMap.put("entryExit", 1);
487        }
488        return new EntryExitPickModel();
489    }
490
491    public static PickListModel<Logix> logixPickModelInstance() {
492        Integer num = _listMap.get("logix");
493        if (num != null) {
494            _listMap.put("logix", num + 1);
495        } else {
496            _listMap.put("logix", 1);
497        }
498        return new LogixPickModel();
499    }
500
501    private final static Logger log = LoggerFactory.getLogger(PickListModel.class);
502
503    static class TurnoutPickModel extends PickListModel<Turnout> {
504
505        TurnoutManager manager = InstanceManager.turnoutManagerInstance();
506
507        TurnoutPickModel() {
508            _name = rb.getString("TitleTurnoutTable");
509        }
510
511        /** {@inheritDoc} */
512        @Override
513        public Manager<Turnout> getManager() {
514            manager = InstanceManager.turnoutManagerInstance();
515            return manager;
516        }
517
518        /** {@inheritDoc} */
519        @Override
520        public Turnout addBean(String name) throws IllegalArgumentException {
521            return manager.provideTurnout(name);
522        }
523
524        /** {@inheritDoc} */
525        @Override
526        public Turnout addBean(String sysName, String userName) {
527            return manager.newTurnout(sysName, userName);
528        }
529
530        /** {@inheritDoc} */
531        @Override
532        public boolean canAddBean() {
533            return true;
534        }
535    }
536
537    static class SensorPickModel extends PickListModel<Sensor> {
538
539        SensorManager manager = InstanceManager.sensorManagerInstance();
540
541        SensorPickModel() {
542            _name = rb.getString("TitleSensorTable");
543        }
544
545        /** {@inheritDoc} */
546        @Override
547        public Manager<Sensor> getManager() {
548            manager = InstanceManager.sensorManagerInstance();
549            return manager;
550        }
551
552        /** {@inheritDoc} */
553        @Override
554        public Sensor addBean(String name) throws IllegalArgumentException {
555            return manager.provideSensor(name);
556        }
557
558        /** {@inheritDoc} */
559        @Override
560        public Sensor addBean(String sysName, String userName) {
561            return manager.newSensor(sysName, userName);
562        }
563
564        /** {@inheritDoc} */
565        @Override
566        public boolean canAddBean() {
567            return true;
568        }
569    }
570
571    static class MultiSensorPickModel extends SensorPickModel {
572
573        private final HashMap<Integer, String> _position = new HashMap<>();
574
575        MultiSensorPickModel() {
576            super();
577        }
578
579        /** {@inheritDoc} */
580        @Override
581        public Object getValueAt(int r, int c) {
582            if (c == POSITION_COL) {
583                return _position.get(r);
584            }
585            return super.getValueAt(r, c);
586        }
587
588        /** {@inheritDoc} */
589        @Override
590        public void setValueAt(Object type, int r, int c) {
591            if (c == POSITION_COL) {
592                _position.put(r, (String) type);
593            }
594        }
595    }
596
597    static class SignalHeadPickModel extends PickListModel<SignalHead> {
598
599        SignalHeadManager manager = InstanceManager.getDefault(SignalHeadManager.class);
600
601        SignalHeadPickModel() {
602            _name = rb.getString("TitleSignalTable");
603        }
604
605        /** {@inheritDoc} */
606        @Override
607        public Manager<SignalHead> getManager() {
608            manager = InstanceManager.getDefault(SignalHeadManager.class);
609            return manager;
610        }
611
612        /** {@inheritDoc} */
613        @Override
614        public SignalHead addBean(String name) {
615            return manager.getSignalHead(name);
616        }
617
618        /** {@inheritDoc} */
619        @Override
620        public SignalHead addBean(String sysName, String userName) {
621            SignalHead sh = manager.getSignalHead(userName);
622            if (sh == null) {
623                sh = manager.getSignalHead(sysName);
624            }
625            return sh;
626        }
627
628        /** {@inheritDoc} */
629        @Override
630        public boolean canAddBean() {
631            return false;
632        }
633    }
634
635    static class SignalMastPickModel extends PickListModel<SignalMast> {
636
637        SignalMastManager manager = InstanceManager.getDefault(SignalMastManager.class);
638
639        SignalMastPickModel() {
640            _name = rb.getString("TitleSignalMastTable");
641        }
642
643        /** {@inheritDoc} */
644        @Override
645        public Manager<SignalMast> getManager() {
646            manager = InstanceManager.getDefault(SignalMastManager.class);
647            return manager;
648        }
649
650        /** {@inheritDoc} */
651        @Override
652        public SignalMast addBean(String name) throws IllegalArgumentException {
653            return manager.provideSignalMast(name);
654        }
655
656        /** {@inheritDoc} */
657        @Override
658        public SignalMast addBean(String sysName, String userName) throws IllegalArgumentException {
659            SignalMast sm = manager.getSignalMast(userName);
660            if (sm == null) {
661                sm = manager.provideSignalMast(sysName);
662            }
663            return sm;
664        }
665
666        /** {@inheritDoc} */
667        @Override
668        public boolean canAddBean() {
669            return false;
670        }
671    }
672
673    static class MemoryPickModel extends PickListModel<Memory> {
674
675        MemoryManager manager = InstanceManager.memoryManagerInstance();
676
677        MemoryPickModel() {
678            _name = rb.getString("TitleMemoryTable");
679        }
680
681        /** {@inheritDoc} */
682        @Override
683        public Manager<Memory> getManager() {
684            manager = InstanceManager.memoryManagerInstance();
685            return manager;
686        }
687
688        /** {@inheritDoc} */
689        @Override
690        public Memory addBean(String name) throws IllegalArgumentException {
691            return manager.provideMemory(name);
692        }
693
694        /** {@inheritDoc} */
695        @Override
696        public Memory addBean(String sysName, String userName) {
697            return manager.newMemory(sysName, userName);
698        }
699
700        /** {@inheritDoc} */
701        @Override
702        public boolean canAddBean() {
703            return true;
704        }
705    }
706
707    static class BlockPickModel extends PickListModel<Block> {
708
709        BlockManager manager = InstanceManager.getDefault(BlockManager.class);
710
711        BlockPickModel() {
712            _name = rb.getString("TitleBlockTable");
713        }
714
715        /** {@inheritDoc} */
716        @Override
717        public Manager<Block> getManager() {
718            manager = InstanceManager.getDefault(BlockManager.class);
719            return manager;
720        }
721
722        /** {@inheritDoc} */
723        @Override
724        public Block addBean(String name) throws IllegalArgumentException {
725            return manager.provideBlock(name);
726        }
727
728        /** {@inheritDoc} */
729        @Override
730        public Block addBean(String sysName, String userName) {
731            return manager.createNewBlock(sysName, userName);
732        }
733
734        /** {@inheritDoc} */
735        @Override
736        public boolean canAddBean() {
737            return true;
738        }
739    }
740
741    static class ReporterPickModel extends PickListModel<Reporter> {
742
743        ReporterManager manager = InstanceManager.getDefault(ReporterManager.class);
744
745        ReporterPickModel() {
746            _name = rb.getString("TitleReporterTable");
747        }
748
749        /** {@inheritDoc} */
750        @Override
751        public Manager<Reporter> getManager() {
752            manager = InstanceManager.getDefault(ReporterManager.class);
753            return manager;
754        }
755
756        /** {@inheritDoc} */
757        @Override
758        public Reporter addBean(String name) throws IllegalArgumentException {
759            return manager.provideReporter(name);
760        }
761
762        /** {@inheritDoc} */
763        @Override
764        public Reporter addBean(String sysName, String userName) {
765            return manager.newReporter(sysName, userName);
766        }
767
768        /** {@inheritDoc} */
769        @Override
770        public boolean canAddBean() {
771            return true;
772        }
773    }
774
775    static class LightPickModel extends PickListModel<Light> {
776
777        LightManager manager = InstanceManager.lightManagerInstance();
778
779        LightPickModel() {
780            _name = rb.getString("TitleLightTable");
781        }
782
783        /** {@inheritDoc} */
784        @Override
785        public Manager<Light> getManager() {
786            manager = InstanceManager.lightManagerInstance();
787            return manager;
788        }
789
790        /** {@inheritDoc} */
791        @Override
792        public Light addBean(String name) throws IllegalArgumentException {
793            return manager.provideLight(name);
794        }
795
796        /** {@inheritDoc} */
797        @Override
798        public Light addBean(String sysName, String userName) {
799            return manager.newLight(sysName, userName);
800        }
801
802        /** {@inheritDoc} */
803        @Override
804        public boolean canAddBean() {
805            return true;
806        }
807    }
808
809    static class OBlockPickModel extends PickListModel<OBlock> {
810
811        OBlockManager manager = InstanceManager.getDefault(OBlockManager.class);
812
813        OBlockPickModel() {
814            _name = rb.getString("TitleBlockTable");
815        }
816
817        /** {@inheritDoc} */
818        @Override
819        public Manager<OBlock> getManager() {
820            manager = InstanceManager.getDefault(OBlockManager.class);
821            return manager;
822        }
823
824        /** {@inheritDoc} */
825        @Override
826        public OBlock addBean(String name) throws IllegalArgumentException {
827            return manager.provideOBlock(name);
828        }
829
830        /** {@inheritDoc} */
831        @Override
832        public OBlock addBean(String sysName, String userName) {
833            return manager.createNewOBlock(sysName, userName);
834        }
835
836        /** {@inheritDoc} */
837        @Override
838        public boolean canAddBean() {
839            return true;
840        }
841    }
842
843    static class WarrantPickModel extends PickListModel<Warrant> {
844
845        WarrantManager manager = InstanceManager.getDefault(WarrantManager.class);
846
847        WarrantPickModel() {
848            _name = rb.getString("TitleWarrantTable");
849        }
850
851        /** {@inheritDoc} */
852        @Override
853        public Manager<Warrant> getManager() {
854            manager = InstanceManager.getDefault(WarrantManager.class);
855            return manager;
856        }
857
858        /** {@inheritDoc} */
859        @Override
860        public Warrant addBean(String name) throws IllegalArgumentException {
861            return manager.provideWarrant(name);
862        }
863
864        /** {@inheritDoc} */
865        @Override
866        public Warrant addBean(String sysName, String userName) {
867            return manager.createNewWarrant(sysName, userName, false, 0);
868        }
869
870        /** {@inheritDoc} */
871        @Override
872        public boolean canAddBean() {
873            return false;
874        }
875    }
876
877    static class EntryExitPickModel extends PickListModel<DestinationPoints> {
878
879        EntryExitPairs manager = InstanceManager.getDefault(EntryExitPairs.class);
880
881        EntryExitPickModel() {
882            _name = rb.getString("TitleEntryExitTable");
883        }
884
885        /** {@inheritDoc} */
886        @Override
887        public Manager<DestinationPoints> getManager() {
888            manager = InstanceManager.getDefault(EntryExitPairs.class);
889            return manager;
890        }
891
892        /** {@inheritDoc} */
893        @Override
894        public DestinationPoints addBean(String name) {
895            return null;
896        }
897
898        /** {@inheritDoc} */
899        @Override
900        public DestinationPoints addBean(String sysName, String userName) {
901            return null;
902        }
903
904        /** {@inheritDoc} */
905        @Override
906        public boolean canAddBean() {
907            return false;
908        }
909
910        /** {@inheritDoc} */
911        @Override
912        public String getColumnName(int c) {
913            if (c == SNAME_COLUMN) {
914                return "Unique Id";
915            } else if (c == UNAME_COLUMN) {
916                return Bundle.getMessage("ColumnUserName");
917            }
918            return "";
919        }
920    }
921
922    static class LogixPickModel extends PickListModel<Logix> {
923
924        LogixManager manager;
925
926        LogixPickModel() {
927           _name = rb.getString("TitleLogixTable");
928        }
929
930        /** {@inheritDoc} */
931        @Override
932        public Manager<Logix> getManager() {
933            manager = InstanceManager.getDefault(LogixManager.class);
934            return manager;
935        }
936
937        /** {@inheritDoc} */
938        @Override
939        public Logix addBean(String name) {
940            return null;
941        }
942
943        /** {@inheritDoc} */
944        @Override
945        public Logix addBean(String sysName, String userName) {
946            return null;
947        }
948
949        /** {@inheritDoc} */
950        @Override
951        public boolean canAddBean() {
952            return false;
953        }
954    }
955}