internal override RepositoryItem GetEditor(TreeListNode senderNode, TreeListColumn senderColumn) { try { //assess whether the policy is switchable for the specific system, i.e. is controlled via the switches-dialog and the run-tool if (ExtensionAndGroupManager.ShowExtensionSwitchEditor(_policyRows[(senderColumn.Tag as SystemTreeListTag).GetSystemRow().ID])) { return(GetSwitchEditor()); } } catch (Exception exception) { Tools.UserInfoHandler.RecordIgnoredException("PolicyTreeListTag.GetEditor", exception); } return(_mainForm.OnOffToggleEditor); //if no return the (standard) combobox, which allows selecting the switch (on, off, ...) }
// avoid that user's paste something else than on/off/etc. into policy- and function-switches internal bool IsPermittedPasteValue(string value, string systemID) { if (GetDefaultParameterRow() != null) { return(true); // no check for parameters } if ((GetDefaultFunctionRow() != null && ExtensionAndGroupManager.ShowExtensionSwitchEditor(GetDefaultFunctionRow())) || (GetDefaultPolicyRow() != null && ExtensionAndGroupManager.ShowExtensionSwitchEditor(GetDefaultPolicyRow()))) { return(false); // if switch='switch' the cell is not-editable } return(value.ToLower() == DefPar.Value.ON || value.ToLower() == DefPar.Value.OFF || value.ToLower() == DefPar.Value.TOGGLE || value.ToLower() == DefPar.Value.NA); }
internal override void PerformAction() { TreeListNode policyNode = _senderNode; if (_senderNode.ParentNode != null) { policyNode = _senderNode.ParentNode; } int newFunctionNodeIndex = -1; List <CountryConfig.FunctionRow> newFunctionRows = new List <CountryConfig.FunctionRow>(); foreach (CountryConfig.PolicyRow policyRow in (policyNode.Tag as PolicyTreeListTag).GetPolicyRows()) //loop over systems { CountryConfig.FunctionRow newFunctionRow = null; //(1) add function //if the sender node is a policy node: insert as last function ('Add Function' was called from policy node or 'Add Function After' was called from last function node in policy) if (_senderNode == policyNode) { newFunctionRow = CountryConfigFacade.AddFunctionRowAtTail(_functionName, policyRow, // the switch of a function inside an extension-policy cannot be changed, therefore add as on (otherwise one would need to remove the policy from the extension to be able to change the switch to on) ExtensionAndGroupManager.ShowExtensionSwitchEditor(policyRow) ? DefPar.Value.ON : DefPar.Value.NA); } //if the sender node is a function node: insert before ('Add Function Before' was called from function node) else { CountryConfig.FunctionRow neighbourFunction = (_senderNode.Tag as FunctionTreeListTag).GetFunctionRowOfSystem(policyRow.SystemRow.ID); newFunctionRow = CountryConfigFacade.AddFunctionRow(_functionName, neighbourFunction, true, ExtensionAndGroupManager.ShowExtensionSwitchEditor(policyRow) ? DefPar.Value.ON : DefPar.Value.NA); // see comment above newFunctionNodeIndex = _mainForm.treeList.GetNodeIndex(_senderNode); } _addedFunctionsIDs.Add(newFunctionRow.ID); //(2) add compulsory parameters DefinitionAdmin.Fun fun = DefinitionAdmin.GetFunDefinition(_functionName, false); if (fun != null) { for (short doCommon = 0; doCommon < 2; ++doCommon) // add function-specific parameters before common { foreach (var p in fun.GetParList()) { AddPar(p, false); } foreach (var pg in fun.GetGroupParList()) { if (pg.minCount > 0) { foreach (var p in pg.par) { AddPar(p, true); } } } void AddPar(KeyValuePair <string, DefinitionAdmin.Par> p, bool group) { string parName = p.Key.ToUpper() == DefPar.PAR_TYPE.PLACEHOLDER.ToString().ToUpper() ? DefinitionAdmin.ParTypeToString(DefPar.PAR_TYPE.PLACEHOLDER) : p.Key; DefinitionAdmin.Par parDef = p.Value; if (parDef.minCount > 0 && ((doCommon == 0 && !parDef.isCommon) || (doCommon == 1 && parDef.isCommon))) { CountryConfigFacade.AddParameterRowAtTail(newFunctionRow, parName, parDef, group ? "1" : string.Empty); } } } } newFunctionRows.Add(newFunctionRow); } _mainForm.GetTreeListBuilder().InsertFunctionNode(newFunctionRows, policyNode, newFunctionNodeIndex); }