package com.digi.config.util; import java.util.Hashtable; import java.util.Properties; import java.awt.*; /** * This class defines default for all the config settings options * */ public final class DefaultConfigSettings implements DefaultValueFinder { //================================================================================== // CONSTANTS for Key Values //================================================================================== //========================== CFG Section =========================================== /** * The Resource Bundle containing all translatable text for messages */ public final static String RESOURCE_BUNDLE_NAME="ResourceBundleName"; private Hashtable MasterTable; //============================================================================== //= Constructors //============================================================================== /** * Constructor. */ public DefaultConfigSettings() { // Determine if this is a development run. If so, this changes // some of the default values. boolean developerFlag=(System.getProperty("ConfigDeveloper")!=null); try { MasterTable=new Hashtable(); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // System Properties //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! MasterTable.put("System", System.getProperties()); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // General Config Options //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties cfgSettings=new Properties(); cfgSettings.setProperty("AppletMode", "false"); MasterTable.put("General", cfgSettings); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Service Server Options //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties ServiceServerOptions=new Properties(); ServiceServerOptions.setProperty("ServicePort", "4449"); MasterTable.put("ServiceServerOptions", ServiceServerOptions); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Colors //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties Colors=new Properties(); Colors.setProperty("NormalText", "0,0,0"); Colors.setProperty("Background", "255,255,255"); Colors.setProperty("FontFamily", "Monospaced"); Colors.setProperty("FontSize", "12"); MasterTable.put("Colors", Colors); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // WindowSettings //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties WindowSettings=new Properties(); WindowSettings.setProperty("ToolBars","true"); WindowSettings.setProperty("FrameLocX", "20"); WindowSettings.setProperty("FrameLocY", "20"); WindowSettings.setProperty("FrameWidth", "1000"); WindowSettings.setProperty("FrameHeight", "700"); WindowSettings.setProperty("BorderAreaWidth", "250"); WindowSettings.setProperty("BorderAreaHeight", "250"); WindowSettings.setProperty("ContentAreaWidth", "800"); WindowSettings.setProperty("ContentAreaHeight", "600"); WindowSettings.setProperty("NavigationAreaWidth", "200"); WindowSettings.setProperty("NavigationAreaHeight", "600"); WindowSettings.setProperty("MessageAreaWidth", "1000"); WindowSettings.setProperty("MessageAreaHeight", "80"); WindowSettings.setProperty("MessageAreaPriorMessageFilter","true"); WindowSettings.setProperty("MessageAreaMinimumSeverityFilter", "0"); //WindowSettings.setProperty("AppPanelBackgroundImage", "AppBackgroundImage"); //WindowSettings.setProperty("AppPanelTileBackground", "true"); //WindowSettings.setProperty("AppPanelStretchBackground", "false"); WindowSettings.setProperty("AppPanelBackgroundColor", "255,255,255,255"); //WindowSettings.setProperty("NavigationPanelBackgroundImage", "NavigationBackgroundImage"); //WindowSettings.setProperty("NavigationPanelBackgroundImagePos", "8"); //WindowSettings.setProperty("NavigationPanelTileBackground", "false"); //WindowSettings.setProperty("NavigationPanelStretchBackground", "false"); //WindowSettings.setProperty("NavigationPanelBackgroundColor", "255,255,255,0"); //WindowSettings.setProperty("NavigationPanelHeight", "600"); //WindowSettings.setProperty("NavigationPanelWidth", "200"); //WindowSettings.setProperty("ContentPanelBackgroundImage", "ContentBackgroundImage"); //WindowSettings.setProperty("ContentPanelTileBackground", "true"); //WindowSettings.setProperty("ContentPanelStretchBackground", "false"); //WindowSettings.setProperty("ContentPanelBackgroundColor", "255,255,255,0"); //WindowSettings.setProperty("MessagePanelBackgroundImage", "MessageBackgroundImage"); //WindowSettings.setProperty("MessagePanelTileBackground", "true"); //WindowSettings.setProperty("MessagePanelStretchBackground", "false"); //WindowSettings.setProperty("MessagePanelBackgroundColor", "255,255,255,0"); WindowSettings.setProperty("DefaultPanelOpaque", "true"); WindowSettings.setProperty("DefaultPanelBackgroundColor", "255,255,255,0"); WindowSettings.setProperty("HeadingBarBackgroundColor", "197,214,252,255"); MasterTable.put("WindowSettings", WindowSettings); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // LogSettings //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties LogSettings=new Properties(); LogSettings.setProperty("LogToFile", "true"); LogSettings.setProperty("ConfigLogFileName", "configlog.txt"); LogSettings.setProperty("LogDebugMsg", (developerFlag?"true" :"false")); MasterTable.put("LogSettings", LogSettings); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // PropertiesSettings //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties PropertiesSettings=new Properties(); PropertiesSettings.setProperty("UseMenus", "false"); MasterTable.put("PropertiesSettings", PropertiesSettings); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // DebugSettings //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Properties DebugSettings=new Properties(); DebugSettings.setProperty("GeneralDebug", (developerFlag?"true" :"false")); // there could be additional settings to turn on debug for specific components MasterTable.put("DebugSettings", DebugSettings); } catch (Throwable t) { // Don't use logging here as the system log will not be initialized yet System.out.println("Failed loading the default ConfigSetting values. Throwable: " +t); } } /** * Gets the default values for a specific category and key * * @param category is the String name of the category from which the property value * should be retrieved. This is a Mandatory parameter. * @param key is the String name of the key to the specific property value whose default * should be retrieved. This is a Mandatory parameter. * @return the default value for the specified category/key provided. Null will * be returned if the category does not exist or if a value does not exist for * the specified key within the category. * @throws IllegalArgumentException when either the category or key parameter are null. */ public String getDefaultValue(String category, String key) { if ((category==null)||(key==null)) { throw new IllegalArgumentException("Category and Key are MANDATORY parameters"); } // Try looking the default value up in the static default table String retValue=null; Properties prop=(Properties)MasterTable.get(category); if (prop!=null) { retValue=(String)prop.getProperty(key); } if (retValue==null) { // static default value not defined. If there is any dynamic assignment to be // done then this is the place. // ... add any dynamic assignments here ... } return retValue; } //end getDefaultValue /** * Gets the default values for a specific category and key * * @param category is the String name of the category from which the property value * should be retrieved. This is a Mandatory parameter. * @return the Properties object containing the defaults for the specified category. * Null will be returned if the category does not exist * @throws IllegalArgumentException when the category parameter is null. */ public Properties getDefaultCategory(String category) { if (category==null) { throw new IllegalArgumentException("Category is a MANDATORY parameter"); } return (Properties)MasterTable.get(category); } //end getDefaultCategory } //end DefaultConfigSettings