Пример #1
0
        private void OnClickAddButton(Object sender, EventArgs e)
        {
            DeviceFilterTreeNode node = new DeviceFilterTreeNode(_webConfig);

            node.Text = _filterList.GetUniqueLabel(node.Text);
            _filterList.TvList.Nodes.Add(node);
            _filterList.TvList.SelectedNode = node;
            node.EnsureVisible();
            UpdateButtonsEnabling();
            node.BeginEdit();
        }
Пример #2
0
        private void DelegateMode()
        {
            DeviceFilterTreeNode node = (DeviceFilterTreeNode)_filterList.SelectedNode;

            node.DeviceFilter.Mode = DeviceFilterMode.Delegate;
            _pnlCompare.Visible    = false;
            _pnlDelegate.Visible   = true;
            _rbDelegate.Checked    = true;
            _txtType.Text          = node.DeviceFilter.Type;
            _txtMethod.Text        = node.DeviceFilter.Method;
        }
Пример #3
0
        private void OnFilterSelected(Object sender, TreeViewEventArgs e)
        {
            DeviceFilterTreeNode node = (DeviceFilterTreeNode)e.Node;

            UpdateButtonsEnabling();
            if (node.DeviceFilter.Mode == DeviceFilterMode.Compare)
            {
                CompareMode();
            }
            else
            {
                DelegateMode();
            }
        }
Пример #4
0
        private void CompareMode()
        {
            DeviceFilterTreeNode node = (DeviceFilterTreeNode)_filterList.SelectedNode;

            node.DeviceFilter.Mode = DeviceFilterMode.Compare;
            _pnlCompare.Visible    = true;
            _pnlDelegate.Visible   = false;
            _rbCompare.Checked     = true;
            // We set Text proprety twice to preserve casing.  (See AUI 3964 /
            // URT 99595)
            String compare = node.DeviceFilter.Compare;

            _cbCompare.Text   = compare;
            _cbCompare.Text   = compare;
            _txtArgument.Text = node.DeviceFilter.Argument;
        }
        // NOTE: A FileLoadException is thrown if an error occurs while reading
        //       web.config.
        internal DeviceFilterEditorDialog(ISite site, WebConfigManager webConfig) : base(site)
        {
            InitializeComponent();

            _lblArgument.Text = SR.GetString(SR.DeviceFilterEditorDialog_Argument);
            _glAttributes.Text = SR.GetString(SR.DeviceFilterEditorDialog_Attributes);
            _lblMethod.Text = SR.GetString(SR.DeviceFilterEditorDialog_Method);
            _glType.Text = SR.GetString(SR.DeviceFilterEditorDialog_TypeGl);
            _rbCompare.Text = SR.GetString(SR.DeviceFilterEditorDialog_Equality);
            _lblCompare.Text = SR.GetString(SR.DeviceFilterEditorDialog_Compare);
            _rbDelegate.Text = SR.GetString(SR.DeviceFilterEditorDialog_Evaluator);
            _lblType.Text = SR.GetString(SR.DeviceFilterEditorDialog_TypeTxt);
            _lblHeader.Text = SR.GetString(SR.DeviceFilterEditorDialog_Header);
            this.Text = SR.GetString(SR.DeviceFilterEditorDialog_Title);

            int tabOffset = 0;
            this._pnlMain.TabIndex = tabOffset++;
            this._filterList.TabIndex = tabOffset++;
            this._pnlRight.TabIndex = tabOffset++;
            this._glType.TabIndex = tabOffset++;
            this._rbCompare.TabIndex = tabOffset++;
            this._rbDelegate.TabIndex = tabOffset++;
            this._glAttributes.TabIndex = tabOffset++;
            this._pnlCompare.TabIndex = tabOffset++;
            this._pnlDelegate.TabIndex = tabOffset++;
            this._lblCompare.TabIndex = tabOffset++;
            this._cbCompare.TabIndex = tabOffset++;
            this._lblType.TabIndex = tabOffset++;
            this._txtType.TabIndex = tabOffset++;
            this._lblArgument.TabIndex = tabOffset++;
            this._txtArgument.TabIndex = tabOffset++;
            this._lblMethod.TabIndex = tabOffset++;
            this._txtMethod.TabIndex = tabOffset++;
            this._dialogButtons.TabIndex = tabOffset++;
            
            _webConfig = webConfig;
            this._site = site;
            GenericUI.InitDialog(this, site);

            _filterList.LblTitle.Text = SR.GetString(SR.DeviceFilterEditorDialog_DeviceFilters);
            _filterList.BtnAdd.Text = SR.GetString(SR.DeviceFilterEditorDialog_NewDeviceFilter);

            // Attempt to load Device Filters
            ArrayList filters = null;
            try 
            {
                filters = _webConfig.ReadDeviceFilters();
            }
            catch (FileNotFoundException e)
            {
                GenericUI.ShowWarningMessage(
                    SR.GetString(SR.DeviceFilterEditorDialog_Title),
                    SR.GetString(SR.DeviceFilterEditorDialog_WebConfigMissingOnOpen)
                );
                throw new FileLoadException(
                    SR.GetString(SR.WebConfig_FileLoadException, e)
                );
            }
            catch (Exception e)
            {
                if (e.Message.Equals(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)))
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)
                    );
                }
                else
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(
                            SR.DeviceFilterEditorDialog_WebConfigParsingError,
                            e.Message
                        )
                    );
                }
                throw new FileLoadException(
                    SR.GetString(SR.WebConfig_FileLoadException, e)
                );
            }

            // Make sure web.config is checked out before we make changes.
            _webConfig.EnsureWebConfigCheckedOut();

            // Insert the Device Filters into the List UI
            foreach(DeviceFilterNode filter in filters)
            {
                DeviceFilterTreeNode node = new DeviceFilterTreeNode(filter);
                _filterList.TvList.Nodes.Add(node);
            }

            // Make sure all filters have a name...
            // NOTE: Do not combine with the above loop or GetUniqueLabel()
            //       will not necessarily be unique.  It could be done if
            //       we wrote another implementation of GetUniqueLabel()
            //       that compared against filters [ArrayList returned
            //       from ReadDeviceFilters()].
            foreach(DeviceFilterTreeNode node in _filterList.TvList.Nodes)
            {
                if(String.IsNullOrEmpty(node.Text))
                {
                    node.Text = _filterList.GetUniqueLabel(
                        SR.GetString(SR.DeviceFilterNode_DefaultFilterName)
                    );
                }
            }
                
            // Initialize the UI
            _rbCompare.Click += new EventHandler(OnClickCompareRadioButton);
            _rbDelegate.Click += new EventHandler(OnClickDelegateRadioButton);
            _cbCompare.TextChanged += new EventHandler(OnTextChanged);
            _cbCompare.SelectedIndexChanged += new EventHandler(OnTextChanged);
            _txtArgument.TextChanged += new EventHandler(OnTextChanged);
            _txtType.TextChanged += new EventHandler(OnTextChanged);
            _txtMethod.TextChanged += new EventHandler(OnTextChanged);
            _filterList.TvList.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _filterList.TvList.AfterSelect += new TreeViewEventHandler(OnFilterSelected);
            _filterList.BtnAdd.Click += new EventHandler(OnClickAddButton);
            _filterList.BtnRemove.Click += new EventHandler(OnClickRemoveButton);
            _filterList.TvList.SelectedNode = null;

            LoadAvailableCapabilities();
            UpdateButtonsEnabling();

            _dialogButtons.CmdOK.Click += new EventHandler(OnClickOK);
            _dialogButtons.CmdCancel.Click += new EventHandler(OnClickCancel);
        }
 private void OnClickAddButton(Object sender, EventArgs e)
 {
     DeviceFilterTreeNode node = new DeviceFilterTreeNode(_webConfig);
     node.Text = _filterList.GetUniqueLabel(node.Text);
     _filterList.TvList.Nodes.Add(node);
     _filterList.TvList.SelectedNode = node;
     node.EnsureVisible();
     UpdateButtonsEnabling();
     node.BeginEdit();
 }
Пример #7
0
        // NOTE: A FileLoadException is thrown if an error occurs while reading
        //       web.config.
        internal DeviceFilterEditorDialog(ISite site, WebConfigManager webConfig) : base(site)
        {
            InitializeComponent();

            _lblArgument.Text  = SR.GetString(SR.DeviceFilterEditorDialog_Argument);
            _glAttributes.Text = SR.GetString(SR.DeviceFilterEditorDialog_Attributes);
            _lblMethod.Text    = SR.GetString(SR.DeviceFilterEditorDialog_Method);
            _glType.Text       = SR.GetString(SR.DeviceFilterEditorDialog_TypeGl);
            _rbCompare.Text    = SR.GetString(SR.DeviceFilterEditorDialog_Equality);
            _lblCompare.Text   = SR.GetString(SR.DeviceFilterEditorDialog_Compare);
            _rbDelegate.Text   = SR.GetString(SR.DeviceFilterEditorDialog_Evaluator);
            _lblType.Text      = SR.GetString(SR.DeviceFilterEditorDialog_TypeTxt);
            _lblHeader.Text    = SR.GetString(SR.DeviceFilterEditorDialog_Header);
            this.Text          = SR.GetString(SR.DeviceFilterEditorDialog_Title);

            int tabOffset = 0;

            this._pnlMain.TabIndex       = tabOffset++;
            this._filterList.TabIndex    = tabOffset++;
            this._pnlRight.TabIndex      = tabOffset++;
            this._glType.TabIndex        = tabOffset++;
            this._rbCompare.TabIndex     = tabOffset++;
            this._rbDelegate.TabIndex    = tabOffset++;
            this._glAttributes.TabIndex  = tabOffset++;
            this._pnlCompare.TabIndex    = tabOffset++;
            this._pnlDelegate.TabIndex   = tabOffset++;
            this._lblCompare.TabIndex    = tabOffset++;
            this._cbCompare.TabIndex     = tabOffset++;
            this._lblType.TabIndex       = tabOffset++;
            this._txtType.TabIndex       = tabOffset++;
            this._lblArgument.TabIndex   = tabOffset++;
            this._txtArgument.TabIndex   = tabOffset++;
            this._lblMethod.TabIndex     = tabOffset++;
            this._txtMethod.TabIndex     = tabOffset++;
            this._dialogButtons.TabIndex = tabOffset++;

            _webConfig = webConfig;
            this._site = site;
            GenericUI.InitDialog(this, site);

            _filterList.LblTitle.Text = SR.GetString(SR.DeviceFilterEditorDialog_DeviceFilters);
            _filterList.BtnAdd.Text   = SR.GetString(SR.DeviceFilterEditorDialog_NewDeviceFilter);

            // Attempt to load Device Filters
            ArrayList filters = null;

            try
            {
                filters = _webConfig.ReadDeviceFilters();
            }
            catch (FileNotFoundException e)
            {
                GenericUI.ShowWarningMessage(
                    SR.GetString(SR.DeviceFilterEditorDialog_Title),
                    SR.GetString(SR.DeviceFilterEditorDialog_WebConfigMissingOnOpen)
                    );
                throw new FileLoadException(
                          SR.GetString(SR.WebConfig_FileLoadException, e)
                          );
            }
            catch (Exception e)
            {
                if (e.Message.Equals(SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)))
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(SR.DeviceFilterEditorDialog_DuplicateNames)
                        );
                }
                else
                {
                    GenericUI.ShowWarningMessage(
                        SR.GetString(SR.DeviceFilterEditorDialog_Title),
                        SR.GetString(
                            SR.DeviceFilterEditorDialog_WebConfigParsingError,
                            e.Message
                            )
                        );
                }
                throw new FileLoadException(
                          SR.GetString(SR.WebConfig_FileLoadException, e)
                          );
            }

            // Make sure web.config is checked out before we make changes.
            _webConfig.EnsureWebConfigCheckedOut();

            // Insert the Device Filters into the List UI
            foreach (DeviceFilterNode filter in filters)
            {
                DeviceFilterTreeNode node = new DeviceFilterTreeNode(filter);
                _filterList.TvList.Nodes.Add(node);
            }

            // Make sure all filters have a name...
            // NOTE: Do not combine with the above loop or GetUniqueLabel()
            //       will not necessarily be unique.  It could be done if
            //       we wrote another implementation of GetUniqueLabel()
            //       that compared against filters [ArrayList returned
            //       from ReadDeviceFilters()].
            foreach (DeviceFilterTreeNode node in _filterList.TvList.Nodes)
            {
                if (String.IsNullOrEmpty(node.Text))
                {
                    node.Text = _filterList.GetUniqueLabel(
                        SR.GetString(SR.DeviceFilterNode_DefaultFilterName)
                        );
                }
            }

            // Initialize the UI
            _rbCompare.Click                  += new EventHandler(OnClickCompareRadioButton);
            _rbDelegate.Click                 += new EventHandler(OnClickDelegateRadioButton);
            _cbCompare.TextChanged            += new EventHandler(OnTextChanged);
            _cbCompare.SelectedIndexChanged   += new EventHandler(OnTextChanged);
            _txtArgument.TextChanged          += new EventHandler(OnTextChanged);
            _txtType.TextChanged              += new EventHandler(OnTextChanged);
            _txtMethod.TextChanged            += new EventHandler(OnTextChanged);
            _filterList.TvList.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _filterList.TvList.AfterSelect    += new TreeViewEventHandler(OnFilterSelected);
            _filterList.BtnAdd.Click          += new EventHandler(OnClickAddButton);
            _filterList.BtnRemove.Click       += new EventHandler(OnClickRemoveButton);
            _filterList.TvList.SelectedNode    = null;

            LoadAvailableCapabilities();
            UpdateButtonsEnabling();

            _dialogButtons.CmdOK.Click     += new EventHandler(OnClickOK);
            _dialogButtons.CmdCancel.Click += new EventHandler(OnClickCancel);
        }