001package jmri.jmrit.beantable.beanedit; 002 003import java.util.ArrayList; 004import java.util.Collections; 005import java.util.List; 006import javax.swing.AbstractAction; 007import javax.swing.JPanel; 008 009/** 010 * Hold the information for each bean panel in a structured manner. 011 * The Panel enabled status and Tool-tip are used in the Tab Selection Menu Titles. 012 */ 013public class BeanItemPanel extends JPanel { 014 015 public BeanItemPanel() { 016 super(); 017 } 018 019 public void saveItem() { 020 if (save != null) { 021 save.actionPerformed(null); 022 } 023 } 024 025 public void resetField() { 026 if (reset != null) { 027 reset.actionPerformed(null); 028 } 029 } 030 031 /** 032 * Set the action to be performed when the Save button is pressed. 033 * 034 * @param save the new save action 035 */ 036 public void setSaveItem(AbstractAction save) { 037 this.save = save; 038 } 039 040 /** 041 * Set the action to be performed when the Cancel button is pressed. 042 * 043 * @param reset the new reset action 044 */ 045 public void setResetItem(AbstractAction reset) { 046 this.reset = reset; 047 } 048 049 private AbstractAction save; 050 private AbstractAction reset; 051 052 private final ArrayList<BeanEditItem> items = new ArrayList<>(); 053 054 public void addItem(BeanEditItem bei) { 055 items.add(bei); 056 } 057 058 /** 059 * Get List of Bean Edit Items 060 * @return unmodifiable List. 061 */ 062 public List<BeanEditItem> getListOfItems() { 063 return Collections.unmodifiableList(items); 064 } 065 066 private String name; 067 068 @Override 069 public void setName(String name) { 070 this.name = name; 071 } 072 073 @Override 074 public String getName() { 075 return name; 076 } 077 078}