public void AddDomain(Domain domain) { // Get the iter for the owner of this new domain object. long applicationId = (long) domain.GetValue("ApplicationId"); long propertyId = (long) domain.GetValue("PropertyId"); DomainDAO dao = DomainFactory.GetDAO("PropertyDefinition"); Domain propDef = dao.GetObject(propertyId); string category = (string) propDef.GetValue("Category"); domain.SetValue("Category", category); domain.SetValue("PropertyName", propDef.GetValue("Name")); TreeIter appIter = FindApplicationIter(applicationId); if (! appIter.Equals(TreeIter.Zero)) { // Found the application, now find the category to // hook up to... TreeIter catIter = FindCategoryIter(appIter, category); TreeIter propIter = TreeIter.Zero; if (! catIter.Equals(TreeIter.Zero)) { propIter = treeStore.AppendValues(catIter, RenderLabel(domain), domain.IdAttribute.Value, domain.GetType().Name); } else { // The category isn't there; need to create one. catIter = treeStore.AppendValues(appIter, Render(domain, "CategoryLabel"), domain.IdAttribute.Value, domain.GetType().Name); propIter = treeStore.AppendValues(catIter, RenderLabel(domain), domain.IdAttribute.Value, domain.GetType().Name); } // Now highlight the specified row SelectRow(propIter); } else { log.ErrorFormat("Unable to find application Id ({0}) to add domain", applicationId); } }
/// <summary> /// Adds a new domain object to the data context. /// </summary> /// <remarks> /// The name with which the domain object is registered is the Class /// name of the domain object (not fully qualified). /// </remarks> /// <param name="obj"> /// Reference to the domain object to be registered in the context. /// </param> public void AddObject(Domain obj) { AddObject(obj.GetType().Name, obj); }
/// <summary> /// Adds a ValueCriteria domain object to the TreeView. /// </summary> /// <param name="valueCriteria"> /// The ValueCriteria domain object to add. /// </param> public void AddValueCriteria(Domain valueCriteria) { // Get the iterator of the select item (effective date) TreeModel model = null; TreeIter edIter = TreeIter.Zero; if (GetSelected(out model, out edIter)) { TreeIter vcIter = treeStore.AppendValues(edIter, RenderLabel(valueCriteria), valueCriteria.IdAttribute.Value, valueCriteria.GetType().Name); SelectRow(vcIter); } }
/// <summary> /// Adds a new effective date domain object to the TreeView. /// </summary> /// <param name="effectiveDate"> /// The EffectiveValue domain object to add to the TreeView. /// </param> public void AddEffectiveDate(Domain effectiveDate) { // Get the iterator for the top of the tree... TreeIter topIter = TreeIter.Zero; if (treeStore.GetIterFirst(out topIter)) { TreeIter edIter = treeStore.AppendValues(topIter, RenderLabel(effectiveDate), effectiveDate.IdAttribute.Value, effectiveDate.GetType().Name); SelectRow(edIter); } }
/// <summary> /// Adds a new domain object to the TreeView. /// </summary> /// <param name="domain"> /// The domain object to add. /// </param> public void AddDomain(Domain domain) { object category = domain.GetValue("Category"); // Find the correct category to add the new domain into TreeIter iter = TreeIter.Zero; bool more = treeStore.GetIterFirst(out iter); while (more) { string label = (string) treeStore.GetValue(iter, LABEL_CELL); if (label.Equals(category)) { // Found the right category TreeIter propIter = TreeIter.Zero; propIter = treeStore.AppendValues(iter, RenderLabel(domain), domain.IdAttribute.Value, domain.GetType().Name); SelectRow(propIter); break; } more = treeStore.IterNext(ref iter); } if (! more) { // This means that we didn't find the category; add // a category and property TreeIter catIter = treeStore.AppendValues(Render(domain, "CategoryLabel"), domain.IdAttribute.Value, domain.GetType().Name); TreeIter propIter = treeStore.AppendValues(catIter, RenderLabel(domain), domain.IdAttribute.Value, domain.GetType().Name); SelectRow(propIter); } }
/// <summary> /// Renders the specified domain object using the specified template. /// </summary> /// <param name="domain"> /// Reference to the domain object to render. /// </param> /// <param name="type"> /// The name of the macro to render the object. /// </param> /// <returns> /// The rendered text. /// </returns> public string RenderObject(Domain domain, string type) { StringTemplateGroup stGroup = this[domain.GetType().Name]; StringTemplate st = stGroup.GetInstanceOf(type); st.RegisterAttributeRenderer(typeof(DateTime), dateRenderer); st.SetAttribute("domain", domain); return st.ToString(); }
/// <summary> /// Adds a domain object to the list control. /// </summary> /// <remarks> /// This method takes care of generating the label and other information for /// the list control as well as providing enough information to later reference the /// domain object. /// </remarks> /// <param name="domain"> /// A reference to the domain object. /// </param> public void AddDomain(Domain domain) { listStore.AppendValues(RenderLabel(domain), domain.IdAttribute.Value, domain.GetType().Name); }