Example #1
0
 public void Dispose()
 {
     ReleaseAllVisibleEnabledNotifications();
     _registeredSettingTypes.Clear();
     _workflowConfigurationController = null;
     _currentConfigController         = null;
 }
Example #2
0
        /// <summary>
        /// Returns the configuration controller class which is responsible for the specified
        /// <paramref name="setting"/>.
        /// </summary>
        /// <param name="setting">The setting to check.</param>
        /// <returns>Configuration controller class which is responsible for the specified
        /// <paramref name="setting"/>, or <c>null</c>, if the setting is not supported.</returns>
        protected ConfigurationController FindConfigurationController(ConfigSetting setting)
        {
            if (setting == null)
            {
                return(null);
            }
            ConfigurationController result = null;
            // Check if a custom configuration controller is requested
            ConfigSettingMetadata metadata = (ConfigSettingMetadata)setting.Metadata;

            if (metadata.AdditionalTypes != null && metadata.AdditionalTypes.ContainsKey("CustomConfigController"))
            {
                Type controllerType = metadata.AdditionalTypes["CustomConfigController"];
                if (controllerType == null)
                {
                    ServiceRegistration.Get <ILogger>().Warn(
                        "ConfigurationModel: Custom configuration controller could not be loaded (config setting at location '{0}')",
                        metadata.Location);
                    return(null);
                }
                // Check if we already have the required controller available
                foreach (KeyValuePair <Type, ConfigurationController> registration in _registeredSettingTypes)
                {
                    if (registration.Value.GetType() == controllerType)
                    {
                        result = registration.Value;
                        break;
                    }
                }
                if (result == null)
                {
                    // FIXME Albert: Make configuration controllers to models; load them via the workflow manager.
                    // This will make configuration controllers be managed correctly
                    result = Activator.CreateInstance(controllerType) as ConfigurationController;
                    if (result != null)
                    {
                        // Lazily add the new controller type to our registered controllers
                        Register(result);
                    }
                }
                if (result != null)
                {
                    return(result);
                }
            }
            // Check if the workflow configuration controller can handle the setting
            if (_workflowConfigurationController.IsSettingSupported(setting))
            {
                return(_workflowConfigurationController);
            }
            // Else try a default configuration controller
            return(FindConfigurationController(setting.GetType()));
        }
Example #3
0
        /// <summary>
        /// Initializes the model state variables for the GUI to be used in the screen for the configuration
        /// item of the specified <paramref name="configLocation"/> and shows the screen.
        /// </summary>
        /// <param name="configLocation">The configuration location to be shown.</param>
        public void ShowConfigItem(string configLocation)
        {
            _currentLocation = configLocation;
            IConfigurationManager configurationManager = ServiceRegistration.Get <IConfigurationManager>();
            IConfigurationNode    currentNode          = configurationManager.GetNode(configLocation);
            ConfigSetting         configSetting        = currentNode == null ? null : currentNode.ConfigObj as ConfigSetting;

            _currentConfigController = FindConfigurationController(configSetting);
            if (_currentConfigController == null)
            { // Error case: We don't have a configuration controller for the setting to be shown
                ServiceRegistration.Get <ILogger>().Warn(
                    "ConfigurationModel: Cannot show configuration for setting '{0}', no configuration controller available",
                    configSetting);
                return;
            }
            _currentConfigController.Initialize(configSetting);
            _currentConfigController.ExecuteConfiguration();
        }
Example #4
0
        /// <summary>
        /// Sets up the internal and external states to conform to the specified <paramref name="newContext"/>.
        /// </summary>
        /// <param name="oldContext">Old workflow navigation context which is left.</param>
        /// <param name="newContext">New workflow navigation context which is entered.</param>
        protected void PrepareConfigLocation(NavigationContext oldContext, NavigationContext newContext)
        {
            _currentConfigController = null;
            ReleaseAllVisibleEnabledNotifications();
            string configLocation = GetConfigLocation(newContext);
            IConfigurationManager configurationManager = ServiceRegistration.Get <IConfigurationManager>();
            bool enteringConfiguration = !IsInitialized(oldContext);

            if (enteringConfiguration)
            {
                configurationManager.Initialize();
            }

            _currentLocation = configLocation;
            // We need to create new instances because the old GUI screen is still attached to the old instances and we don't
            // want to update them
            _headerTextProperty = new WProperty(typeof(string), null);
            _configSettingsList = new ItemsList();
            UpdateConfigSettingsAndHeader();
        }
Example #5
0
        /// <summary>
        /// Returns the information if the specified <paramref name="setting"/> is supported by this
        /// configuration plugin.
        /// </summary>
        /// <param name="setting">The setting to check.</param>
        /// <returns><c>true</c>, if the setting is supported, i.e. it can be displayed in the GUI, else
        /// <c>false</c>.</returns>
        protected bool IsSettingSupported(ConfigSetting setting)
        {
            ConfigurationController controller = FindConfigurationController(setting);

            return(controller != null && controller.IsSettingSupported(setting));
        }
Example #6
0
 /// <summary>
 /// Registers the specified configuration <paramref name="controller"/> for the configuration
 /// type, the controller specifies in its <see cref="ConfigurationController.ConfigSettingType"/> property.
 /// </summary>
 void Register(ConfigurationController controller)
 {
     _registeredSettingTypes[controller.ConfigSettingType] = controller;
 }
    /// <summary>
    /// Sets up the internal and external states to conform to the specified <paramref name="newContext"/>.
    /// </summary>
    /// <param name="oldContext">Old workflow navigation context which is left.</param>
    /// <param name="newContext">New workflow navigation context which is entered.</param>
    protected void PrepareConfigLocation(NavigationContext oldContext, NavigationContext newContext)
    {
      _currentConfigController = null;
      ReleaseAllVisibleEnabledNotifications();
      string configLocation = GetConfigLocation(newContext);
      IConfigurationManager configurationManager = ServiceRegistration.Get<IConfigurationManager>();
      bool enteringConfiguration = !IsInitialized(oldContext);
      if (enteringConfiguration)
        configurationManager.Initialize();

      _currentLocation = configLocation;
      // We need to create new instances because the old GUI screen is still attached to the old instances and we don't
      // want to update them
      _headerTextProperty = new WProperty(typeof(string), null);
      _configSettingsList = new ItemsList();
      UpdateConfigSettingsAndHeader();
    }
 /// <summary>
 /// Initializes the model state variables for the GUI to be used in the screen for the configuration
 /// item of the specified <paramref name="configLocation"/> and shows the screen.
 /// </summary>
 /// <param name="configLocation">The configuration location to be shown.</param>
 public void ShowConfigItem(string configLocation)
 {
   _currentLocation = configLocation;
   IConfigurationManager configurationManager = ServiceRegistration.Get<IConfigurationManager>();
   IConfigurationNode currentNode = configurationManager.GetNode(configLocation);
   ConfigSetting configSetting = currentNode == null ? null : currentNode.ConfigObj as ConfigSetting;
   _currentConfigController = FindConfigurationController(configSetting);
   if (_currentConfigController == null)
   { // Error case: We don't have a configuration controller for the setting to be shown
     ServiceRegistration.Get<ILogger>().Warn(
         "ConfigurationModel: Cannot show configuration for setting '{0}', no configuration controller available",
         configSetting);
     return;
   }
   _currentConfigController.Initialize(configSetting);
   _currentConfigController.ExecuteConfiguration();
 }
 public void Dispose()
 {
   ReleaseAllVisibleEnabledNotifications();
   _registeredSettingTypes.Clear();
   _workflowConfigurationController = null;
   _currentConfigController = null;
 }
 /// <summary>
 /// Registers the specified configuration <paramref name="controller"/> for the configuration
 /// type, the controller specifies in its <see cref="ConfigurationController.ConfigSettingType"/> property.
 /// </summary>
 void Register(ConfigurationController controller)
 {
   _registeredSettingTypes[controller.ConfigSettingType] = controller;
 }