private void toolStripButton1_Click(object sender, EventArgs e) { if (treeView1.SelectedNode is CategoryNode || treeView1.SelectedNode is RepositoryNode) { FormAddCategory formAddCategory; if (treeView1.SelectedNode is CategoryNode) // CategoryNode { CategoryNode categoryNode = (CategoryNode)treeView1.SelectedNode; formAddCategory = new FormAddCategory(categoryNode.Repository.name, categoryNode.Category.UDDI); DialogResult res = formAddCategory.ShowDialog(); if (res == DialogResult.OK) { treeView1.SelectedNode.Nodes.Clear(); addCategory(categoryNode); } } else { RepositoryNode repositoryNode = (RepositoryNode)treeView1.SelectedNode; formAddCategory = new FormAddCategory(repositoryNode.Repository.name); DialogResult res = formAddCategory.ShowDialog(); if (res == DialogResult.OK) { treeView1.SelectedNode.Nodes.Clear(); addCategoryToRepository(repositoryNode); } } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { this.Wizard.Data[CATEGORY_ID] = null; this.Wizard.Data[REPOSITORY_ID] = null; this.toolStripButtonDeleteCategory.Enabled = false; this.toolStripButtonAddCategory.Enabled = true; if (treeView1.SelectedNode is CategoryNode || treeView1.SelectedNode is RepositoryNode) { if (treeView1.SelectedNode is CategoryNode) { CategoryNode cat = (CategoryNode)treeView1.SelectedNode; if (!OfficeApplication.OfficeApplicationProxy.canCreateCategory(cat.Repository.name, cat.Category.UDDI)) { this.toolStripButtonAddCategory.Enabled = false; return; } if (!OfficeApplication.OfficeApplicationProxy.canRemoveCategory(cat.Repository.name, cat.Category.UDDI)) { this.toolStripButtonDeleteCategory.Enabled = false; return; } this.Wizard.Data[CATEGORY_ID] = ((CategoryNode)treeView1.SelectedNode).Category.UDDI; this.Wizard.Data[REPOSITORY_ID] = ((CategoryNode)treeView1.SelectedNode).Repository; this.Cursor = Cursors.WaitCursor; try { if (OfficeApplication.OfficeApplicationProxy.canDeleteCategory(this.Wizard.Data[REPOSITORY_ID].ToString(), this.Wizard.Data[CATEGORY_ID].ToString())) { this.toolStripButtonDeleteCategory.Enabled = true; } } catch (Exception ue) { Debug.WriteLine(ue.StackTrace); } this.Cursor = Cursors.Default; } else { if (treeView1.SelectedNode is RepositoryNode) { RepositoryNode rep = (RepositoryNode)treeView1.SelectedNode; if (!OfficeApplication.OfficeApplicationProxy.canCreateCategory(rep.Text)) { this.toolStripButtonAddCategory.Enabled = false; return; } } if (e.Node.Nodes.Count == 0) { MessageBox.Show(this, "¡No existen categorias en este repositorio!" + "\r\n" + "Debe crear una para poder publicar el contenido", "Agregar Categoria", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.toolStripButtonAddCategory.Enabled = true; } }
private void loadTree() { this.treeView1.Nodes.Clear(); TreeNode root = this.treeView1.Nodes.Add("Repositorios", "Repositorios", 0, 1); try { foreach (RepositoryInfo repository in OfficeApplication.OfficeApplicationProxy.getRepositories()) { if (!repository.name.Equals("defaultWorkspace@swb")) { RepositoryNode repositoryNode = new RepositoryNode(repository); root.Nodes.Add(repositoryNode); foreach (CategoryInfo category in OfficeApplication.OfficeApplicationProxy.getCategories(repository.name)) { CategoryNode categoryNode = new CategoryNode(category, repository); repositoryNode.Nodes.Add(categoryNode); if (category.childs > 0) { TreeNode dummyNode = new DummyNode(); categoryNode.Nodes.Add(dummyNode); } } } else { if (showDefaultRepository) { RepositoryNode repositoryNode = new RepositoryNode(repository); root.Nodes.Add(repositoryNode); foreach (CategoryInfo category in OfficeApplication.OfficeApplicationProxy.getCategories(repository.name)) { CategoryNode categoryNode = new CategoryNode(category, repository); repositoryNode.Nodes.Add(categoryNode); if (category.childs > 0) { TreeNode dummyNode = new DummyNode(); categoryNode.Nodes.Add(dummyNode); } } } } } } catch (Exception e) { OfficeApplication.WriteError(e); } if (this.treeView1.Nodes.Count > 0) { this.treeView1.Nodes[0].Expand(); } }
private void addCategoryToRepository(RepositoryNode repository) { try { foreach (CategoryInfo category in OfficeApplication.OfficeApplicationProxy.getCategories(repository.Repository.name)) { CategoryNode categoryNode = new CategoryNode(category, repository.Repository); repository.Nodes.Add(categoryNode); if (category.childs > 0) { TreeNode dummyNode = new DummyNode(); categoryNode.Nodes.Add(dummyNode); } } } catch { } }