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 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);
            }
        }