private void AddParticipants(object sender, EventArgs e) { var item = (ToolStripMenuItem)sender; var role = (ICmPossibility)item.Tag; string roleName = role.Name.BestAnalysisAlternative.Text; string displayWs = "analysis vernacular"; if (m_configurationNode != null) { XmlNode node = m_configurationNode.SelectSingleNode("deParams"); if (node != null) { displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower(); } } IEnumerable <ObjectLabel> labels = ObjectLabel.CreateObjectLabels(m_cache, m_cache.LanguageProject.PeopleOA.PossibilitiesOS, DisplayNameProperty, displayWs); using (var chooser = new SimpleListChooser(m_persistenceProvider, labels, m_fieldName, m_cache, null, m_mediator.HelpTopicProvider)) { chooser.TextParamHvo = m_cache.LanguageProject.PeopleOA.Hvo; chooser.SetHelpTopic(GetChooserHelpTopicID()); if (m_configurationNode != null) { chooser.InitializeExtras(m_configurationNode, Mediator); } DialogResult res = chooser.ShowDialog(); if (DialogResult.Cancel == res) { return; } if (m_configurationNode != null) { chooser.HandleAnyJump(); } if (chooser.ChosenObjects != null) { IRnRoledPartic roledPartic = null; UndoableUnitOfWorkHelper.Do(string.Format(LexEdStrings.ksUndoAddParticipants, roleName), string.Format(LexEdStrings.ksRedoAddParticipants, roleName), role, () => { roledPartic = m_cache.ServiceLocator.GetInstance <IRnRoledParticFactory>().Create(); Record.ParticipantsOC.Add(roledPartic); roledPartic.RoleRA = role; foreach (ICmPerson person in chooser.ChosenObjects) { roledPartic.ParticipantsRC.Add(person); } }); ExpandNewNode(roledPartic); } } }
private void ExpandNewNode(IRnRoledPartic roledPartic) { try { ContainingDataTree.DeepSuspendLayout(); XmlNode caller = null; if (Key.Length > 1) { caller = Key[Key.Length - 2] as XmlNode; } int insPos = IndexInContainer + Record.ParticipantsOC.Count - 1; GenerateChildNode(roledPartic, m_configurationNode, caller, Indent, ref insPos, new ArrayList(Key), new ObjSeqHashMap()); Expansion = DataTree.TreeItemState.ktisExpanded; } finally { ContainingDataTree.DeepResumeLayout(); } }
protected override void InitLauncher() { CheckDisposed(); IRnRoledPartic defaultRoledPartic = Record.DefaultRoledParticipants; Func <ICmObject> defaultRoleCreator = null; if (defaultRoledPartic == null) { // Initialize the view with an action that can create one if the use clicks on it. defaultRoleCreator = () => { // create a default roled participants object if it does not already exist NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => { defaultRoledPartic = Record.MakeDefaultRoledParticipant(); }); return(defaultRoledPartic); }; } // this slice displays the default roled participants var vrl = (VectorReferenceLauncher)Control; vrl.Initialize(m_cache, defaultRoledPartic, RnRoledParticTags.kflidParticipants, m_fieldName, m_persistenceProvider, Mediator, m_propertyTable, DisplayNameProperty, BestWsName); // TODO: Get better default 'best ws'. vrl.ObjectCreator = defaultRoleCreator; vrl.ConfigurationNode = ConfigurationNode; vrl.ViewSizeChanged += OnViewSizeChanged; var view = (VectorReferenceView)vrl.MainControl; view.ViewSizeChanged += OnViewSizeChanged; // We don't want to be visible until later, since otherwise we get a temporary // display in the wrong place with the wrong size that serves only to annoy the // user. See LT-1518 "The drawing of the DataTree for Lexicon/Advanced Edit draws // some initial invalid controls." Becoming visible when we set the width and // height seems to delay things enough to avoid this visual clutter. vrl.Visible = false; }
private void GenerateChildNode(IRnRoledPartic roledPartic, XmlNode node, XmlNode caller, int indent, ref int insPos, ArrayList path, ObjSeqHashMap reuseMap) { var sliceElem = new XElement("slice", new XAttribute("label", roledPartic.RoleRA.Name.BestAnalysisAlternative.Text), new XAttribute("field", "Participants"), new XAttribute("editor", "possVectorReference"), new XAttribute("menu", "mnuDataTree-Participants")); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.NodeType != XmlNodeType.Comment) { sliceElem.Add(XElement.Parse(childNode.OuterXml)); } } node.InnerXml = sliceElem.ToString(); CreateIndentedNodes(caller, roledPartic, indent, ref insPos, path, reuseMap, node); node.InnerXml = ""; }
private void ExpandNewNode(IRnRoledPartic roledPartic) { try { ContainingDataTree.DeepSuspendLayout(); XmlNode caller = null; if (Key.Length > 1) caller = Key[Key.Length - 2] as XmlNode; int insPos = IndexInContainer + Record.ParticipantsOC.Count - 1; GenerateChildNode(roledPartic, m_configurationNode, caller, Indent, ref insPos, new ArrayList(Key), new ObjSeqHashMap()); Expansion = DataTree.TreeItemState.ktisExpanded; } finally { ContainingDataTree.DeepResumeLayout(); } }
private void GenerateChildNode(IRnRoledPartic roledPartic, XmlNode node, XmlNode caller, int indent, ref int insPos, ArrayList path, ObjSeqHashMap reuseMap) { var sliceElem = new XElement("slice", new XAttribute("label", roledPartic.RoleRA.Name.BestAnalysisAlternative.Text), new XAttribute("field", "Participants"), new XAttribute("editor", "possVectorReference"), new XAttribute("menu", "mnuDataTree-Participants")); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.NodeType != XmlNodeType.Comment) sliceElem.Add(XElement.Parse(childNode.OuterXml)); } node.InnerXml = sliceElem.ToString(); CreateIndentedNodes(caller, roledPartic, indent, ref insPos, path, reuseMap, node); node.InnerXml = ""; }