001package jmri.jmrix; 002 003import javax.annotation.Nonnull; 004import javax.swing.JPanel; 005 006/** 007 * Interface for objects that handle configuring a layout connection. 008 * <p> 009 * General design documentation is available on the 010 * <a href="http://jmri.org/help/en/html/doc/Technical/SystemStructure.shtml">Structure of External System Connections page</a>. 011 * 012 * @author Bob Jacobsen Copyright (C) 2001, 2003 013 * @see JmrixConfigPane 014 * @see PortAdapter 015 */ 016public interface ConnectionConfig { 017 018 String name(); 019 020 String getInfo(); 021 022 PortAdapter getAdapter(); 023 024 String getConnectionName(); 025 026 String getManufacturer(); 027 028 void setManufacturer(String Manufacturer); 029 030 /** 031 * Load the Swing widgets needed to configure 032 * this connection into a specified JPanel. 033 * Used during the configuration process to 034 * fill out the preferences window with 035 * content specific to this Connection type. 036 * The JPanel contents need to handle their own 037 * gets/sets to the underlying Connection content. 038 * 039 * @param details the specific Swing object to be configured and filled 040 */ 041 void loadDetails(JPanel details); 042 043 /** 044 * Register the ConnectionConfig with the running JMRI process. 045 * <p> 046 * At a minimum, is responsible for: 047 * <ul> 048 * <li>Registering this object with the ConfigurationManager for persistance, typically at the "Preferences" level 049 * <li>Adding this object to the default (@link ConnectionConfigManager} 050 * </ul> 051 */ 052 void register(); 053 054 /** 055 * Done with this ConnectionConfig object. 056 * Invoked in {@link JmrixConfigPane} when switching 057 * away from this particular mode. 058 */ 059 void dispose(); 060 061 boolean getDisabled(); 062 063 void setDisabled(boolean disabled); 064 065 /** 066 * Determine if configuration needs to be written to disk. 067 * 068 * @return true if configuration needs to be saved, false otherwise 069 */ 070 boolean isDirty(); 071 072 /** 073 * Determine if application needs to be restarted for configuration changes 074 * to be applied. 075 * 076 * @return true if application needs to restart, false otherwise 077 */ 078 boolean isRestartRequired(); 079 080 /** 081 * Get the configuration for the ConnectionConfig. 082 * 083 * @return the configuration or null if not supported 084 */ 085 default Config getConfig() { 086 return null; 087 } 088 089 /** 090 * Set the configuration for the ConnectionConfig. 091 * The method MUST check if the configuration is of a supported type 092 * and if not, ignore it. An unsupported connection type is not an error. 093 * 094 * @param config the configuration 095 */ 096 default void setConfig(@Nonnull Config config) { 097 // Do nothing 098 } 099 100 /** 101 * Configuration for a ConnectionConfig. 102 */ 103 interface Config { 104 } 105 106}