/// <summary>
        /// Selects one model to be shown in dialog.
        /// </summary>
        /// <param name="modelID">ID of model to be selected.</param>
        public void SelectModel(string modelID)
        {
            if (modelID == null)
            {
                outputExchangeItemSelector.TreePopulate(_treeOptionsSources);
                inputExchangeItemSelector.TreePopulate(_treeOptionsTargets);
                _loadedModelID = null;
            }
            else
            {
                // find model by ID
                int modelIndex = -1;
                for (int i = 0; i < comboBoxModel.Items.Count; i++)
                {
                    if ((string)comboBoxModel.Items[i] == modelID)
                    {
                        modelIndex = i;
                        break;
                    }
                }

                if (modelIndex < 0 || modelIndex >= _uiModels.Count)
                {
                    // model with modelID wasn't found
                    Debug.Assert(false);
                    SelectModel(null);
                    return;
                }

                UIModel selectedModel = (UIModel)_uiModels[modelIndex];

                Debug.Assert(selectedModel.InstanceCaption == modelID);

                // load exchange items (if they aren't already loaded)
                if (modelID != _loadedModelID)
                {
                    outputExchangeItemSelector.TreePopulate(selectedModel.LinkableComponent, _treeOptionsSources);
                    inputExchangeItemSelector.TreePopulate(selectedModel.LinkableComponent, _treeOptionsTargets);

                    _loadedModelID = selectedModel.InstanceCaption;
                }

                // select model also in comboBox
                // this can cause this method is reentered
                comboBoxModel.SelectedIndex = modelIndex;

                //labelInfo.Text = "Model " + selectedModel.ModelID;

                // show properties of this model
                PropertyGridSelectObject(selectedModel.LinkableComponent);
            }
        }
        /// <summary>
        /// Populates this <see cref="ConnectionDialog">ConnectionDialog</see> with specific connection.
        /// </summary>
        /// <param name="uilink"></param>
        public void PopulateDialog(UIConnection uilink)
        {
            _uilink = uilink;
            _propertyManagerCache = new Hashtable();

            _shouldBeSaved = false;

            _treeSource.TreePopulate(
                uilink, _treeOptionsSources);
            _treeTarget.TreePopulate(
                uilink, _treeOptionsTargets);

            ElementTypeFilterCheckBox.Checked = false;
            DimensionFilterCheckBox.Checked   = false;

            UpdateListLinks();

            Text = "Connection: " + uilink.SourceModel.InstanceCaption + " => " + uilink.TargetModel.InstanceCaption;
        }