001package jmri.jmrit.beantable.beanedit; 002 003import java.awt.event.ActionEvent; 004import javax.swing.JCheckBox; 005import jmri.InstanceManager; 006import jmri.Sensor; 007 008/** 009 * Provides an edit panel for a Sensor object. 010 * 011 * @author Kevin Dickerson Copyright (C) 2011 012 */ 013public class SensorEditAction extends BeanEditAction<Sensor> { 014 015 @Override 016 public String helpTarget() { 017 return "package.jmri.jmrit.beantable.SensorAddEdit"; 018 } // NOI18N 019 020 SensorDebounceEditAction debounce; 021 SensorPullUpEditAction pullup; 022 023 @Override 024 protected void initPanels() { 025 super.initPanels(); 026 debounce = new SensorDebounceEditAction(); 027 debounce.setBean(bean); 028 bei.add(debounce.sensorDebounce(null)); 029 pullup = new SensorPullUpEditAction(); 030 pullup.setBean(bean); 031 bei.add(pullup.sensorPullUp(null)); 032 } 033 034 @Override 035 public Sensor getByUserName(String name) { 036 return InstanceManager.sensorManagerInstance().getByUserName(name); 037 } 038 039 JCheckBox inverted = new JCheckBox(); 040 041 @Override 042 BeanItemPanel basicDetails() { 043 BeanItemPanel basic = super.basicDetails(); 044 045 basic.addItem(new BeanEditItem(inverted, Bundle.getMessage("Inverted"), Bundle.getMessage("SensorInvertedToolTip"))); 046 047 return basic; 048 } 049 050 @Override 051 protected void saveBasicItems(ActionEvent e) { 052 super.saveBasicItems(e); 053 bean.setInverted(inverted.isSelected()); 054 } 055 056 @Override 057 protected void resetBasicItems(ActionEvent e) { 058 super.resetBasicItems(e); 059 inverted.setSelected(bean.getInverted()); 060 } 061 062}