001 002package jmri.jmrix.mqtt; 003 004import javax.swing.*; 005 006 007/** 008 * 009 * @author Lionel Jeanson 010 */ 011public class MqttConnectionConfig extends jmri.jmrix.AbstractNetworkConnectionConfig { 012 013 public MqttConnectionConfig(jmri.jmrix.NetworkPortAdapter p) { 014 super(p); 015 } 016 017 public MqttConnectionConfig() { 018 super(); 019 } 020 021 @Override 022 public String name() { 023 return("MQTT Connection"); 024 } 025 026 /** 027 * {@inheritDoc} 028 */ 029 @Override 030 protected void setInstance() { 031 if (adapter == null) { 032 adapter = new MqttAdapter(); 033 adapter.setPort(1883); 034 } 035 } 036 037 @Override 038 public String getInfo() { 039 return(adapter.getCurrentPortName()); 040 } 041 042 @Override 043 public String getManufacturer() { 044 return(MqttConnectionTypeList.GENMAN); 045 } 046 047 /** 048 * {@inheritDoc} 049 */ 050 @Override 051 public void loadDetails(final JPanel details) { 052 super.loadDetails(details); 053 054 // the following is a very brittle work-around until we 055 // move to a SystemConnectionMemo architecture. It sets the 056 // combobox for the topic preference to editable, so that it 057 // can be changed to an arbitrary string before being stored. 058 if ( options.get(adapter.getOptions()[0]).getComponent() instanceof JComboBox) { 059 ((JComboBox<?>) options.get(adapter.getOptions()[0]).getComponent()).setEditable(true); 060 } 061 } 062 063 @Override 064 protected void checkOptionValueValidity(String i, JComboBox<String> opt) { 065 // it's OK, even it it doesn't match a pre-load 066 } 067 068 // private final static Logger log = LoggerFactory.getLogger(MqttConnectionConfig.class); 069 070}