private void okButton_Click(object sender, EventArgs e) { #region Preconditions if (!okButton.Enabled) { throw new ApplicationException("ViewConstructor -- Can not construct view given the current conditions/resource types configuration"); } #endregion Preconditions okButton.Enabled = false; if (isResourceNewAndNameExist(FilterManagerProps.ViewResName)) { DialogResult result = MessageBox.Show(this, "View with such name already exists. Do you want to overwrite it?", "Names collision", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } #region Debug Check // The following check is crazy, but bug #6066 is caused by the // null string passed to the DeleteView method. // Here I want to be sure that I'm not completely mad about // that guards. if (_editHeading.Text == null) { throw new ArgumentException("ViewConstructor -- Null value of TextEdit control"); } #endregion Debug Check FMgr.DeleteView(_editHeading.Text); } //------------------------------------------------------------- IResource[][] conditionGroups = Controls2Resources(panelConditions.Controls); IResource[] exceptions = ConvertTemplates2Conditions(panelExceptions.Controls); string[] formTypes = ReformatTypes(CurrentResTypeDeep); //------------------------------------------------------------- // - Create new view as usual; // - For an existing view - do not create it anew, but save all // its existing characteristics like base view folder and // position in the tree. Additionally, editing existing view // will not cause Views Pane to flash. //------------------------------------------------------------- if (BaseResource == null) // new view? { BaseResource = FMgr.RegisterView(_editHeading.Text, formTypes, conditionGroups, exceptions); } else { FMgr.ReregisterView(BaseResource, _editHeading.Text, formTypes, conditionGroups, exceptions); } LinkWithWorkspaces(); FreeConditionLists(panelConditions.Controls); FreeConditionLists(panelExceptions.Controls); DialogResult = DialogResult.OK; }
private void okButton_Click(object sender, EventArgs e) { Debug.Assert(okButton.Enabled); cancelButton.Enabled = okButton.Enabled = false; if (isResourceNewAndNameExist(FilterManagerProps.RuleResName)) { DialogResult result = MessageBox.Show(this, "Rule with such name already exists. Do you want to overwrite it?", "Names collision", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } FMgr.DeleteRule(_editHeading.Text); } //----------------------------------------------------------------- IResource[][] conds = Controls2Resources(panelConditions.Controls); IResource[] excConds = ConvertTemplates2Conditions(panelExceptions.Controls); IResource[] actions = (IResource[])CollectActions().ToArray(typeof(IResource)); string[] formTypes = ReformatTypes(CurrentResTypeDeep); string eventName = (string)_comboActivationTime.SelectedItem; eventName = (string)EventNamesMap[eventName]; //----------------------------------------------------------------- // If it is a new rule - do nothing special, otherwise register // the rule over the top of the existing one. //----------------------------------------------------------------- if (BaseResource == null) // new resource { BaseResource = FMgr.RegisterRule(eventName, _editHeading.Text, formTypes, conds, excConds, actions); } else { FMgr.ReregisterRule(eventName, BaseResource, _editHeading.Text, formTypes, conds, excConds, actions); } FreeConditionLists(panelConditions.Controls); FreeConditionLists(panelExceptions.Controls); FreeConditionLists(_panelActions.Controls); DialogResult = DialogResult.OK; }
private void PerformSearch() { string query = _editHeading.Text.Trim(); IResource[][] conditions = Controls2Resources(panelConditions.Controls); if (query.Length > 0) { IResource queryCondition = ((FilterRegistry)FMgr).CreateQueryConditionAux(null, query, comboSection.Text); FilterRegistry.ReferCondition2Template(queryCondition, FMgr.Std.BodyMatchesSearchQueryXName); // Copy query condition to every subgroup or create the single one. if (conditions != null && conditions.Length > 0) { for (int i = 0; i < conditions.Length; i++) { IResource[] group = conditions[i]; IResource[] newGroup = new IResource[group.Length + 1]; for (int j = 0; j < group.Length; j++) { newGroup[j] = group[j]; } newGroup[newGroup.Length - 1] = queryCondition; conditions[i] = newGroup; } } else { conditions = FilterRegistry.Convert2Group(queryCondition); } UpdateStoredQueriesList(query); } IResource[] exceptions = ConvertTemplates2Conditions(panelExceptions.Controls); //----------------------------------------------------------------- // need to remove existing basic View? // NB: it removes all underlying AUX conditions including query search //----------------------------------------------------------------- IResource view = RStore.FindUniqueResource(FilterManagerProps.ViewResName, "DeepName", FMgr.ViewNameForSearchResults); string[] formTypes = ReformatTypes(CurrentResTypeDeep); if (view != null) { BaseResource = view; FMgr.ReregisterView(view, FMgr.ViewNameForSearchResults, formTypes, conditions, exceptions); } else { BaseResource = FMgr.RegisterView(FMgr.ViewNameForSearchResults, formTypes, conditions, exceptions); } //----------------------------------------------------------------- bool showContext = (query.Length > 0) && Core.SettingStore.ReadBool("Resources", "ShowSearchContext", true); ResourceProxy proxy = new ResourceProxy(BaseResource); proxy.BeginUpdate(); proxy.SetProp(Core.Props.Name, SearchViewPrefix + query); proxy.SetProp(Core.Props.ShowDeletedItems, true); proxy.SetProp("ForceExec", true); proxy.SetProp("ShowContexts", showContext); if (BaseResource.HasProp(Core.Props.ContentType) || BaseResource.HasProp("ContentLinks")) { proxy.DeleteProp("ShowInAllTabs"); } else { proxy.SetProp("ShowInAllTabs", true); } proxy.EndUpdate(); // if search is done specifically for the particular resource // type - set the focus onto that tab. Core.ResourceTreeManager.LinkToResourceRoot(BaseResource, 1); if ((CurrentResTypeDeep != null) && (CurrentResTypeDeep.IndexOf('|') == -1) && (CurrentResTypeDeep.IndexOf('#') == -1)) { Core.TabManager.SelectResourceTypeTab(CurrentResTypeDeep); } else { Core.TabManager.SelectResourceTypeTab(""); } Core.UIManager.BeginUpdateSidebar(); Core.LeftSidebar.ActivateViewPane(StandardViewPanes.ViewsCategories); Core.UIManager.EndUpdateSidebar(); Core.LeftSidebar.DefaultViewPane.SelectResource(BaseResource); BringToFront(); }