private void EnableDisableNextButton() { bool enabled = false; // Enable the next button on the form if we have any site collections or web apps checked // Note that a web app being checked doesn't count unless the tree node has not yet been populated // We do this to avoid race conditions that could occur foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes) { ExtendedTreeNode extendedWebAppTreeNode = webAppTreeNode as ExtendedTreeNode; if (extendedWebAppTreeNode != null && extendedWebAppTreeNode.Checked && !extendedWebAppTreeNode.Populated) { enabled = true; break; } else { foreach (TreeNode siteCollTreeNode in webAppTreeNode.Nodes) { if (siteCollTreeNode.Checked) { enabled = true; break; } } } } Form.NextButton.Enabled = enabled; }
void WebAppTreeNode_TreeNodePopulate(object sender, TreeViewCancelEventArgs e) { WebApplicationInfo webAppInfo = e.Node.Tag as WebApplicationInfo; bool preCheck = (((webAppInfo.Application.IsAdministrationWebApplication || webAppInfo.IsSRP) && InstallConfiguration.SuggestDeploymentToCentralAdminWebApplication) || ((!(webAppInfo.Application.IsAdministrationWebApplication || webAppInfo.IsSRP)) && InstallConfiguration.SuggestDeploymentToAllContentWebApplications)); if (webAppInfo != null) { if (webAppInfo.Application.Sites.Count >= SiteCollectionCountWarning) { string msg = String.Format(res.ManySitesWarning, webAppInfo.Application.Sites.Count); if (MessageBox.Show(msg, res.ManySites, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { e.Cancel = true; } } if (!e.Cancel) { foreach (SPSite site in webAppInfo.Application.Sites) { SiteCollectionInfo siteCollInfo = new SiteCollectionInfo(site, false); ExtendedTreeNode.AddNewExtendedTreeNode(e.Node.Nodes, siteCollInfo.ToString(), siteCollInfo).Checked = preCheck; } } } }
private void PopulateTreeViewForWebApps(TreeNodeCollection treeNodes, SPWebApplicationCollection webApps) { foreach (SPWebApplication application in webApps) { WebApplicationInfo webAppInfo = new WebApplicationInfo(application, false); ExtendedTreeNode webAppTreeNode = ExtendedTreeNode.AddNewExtendedTreeNode(treeNodes, webAppInfo.ToString(), true, webAppInfo); webAppTreeNode.Checked = (((application.IsAdministrationWebApplication || webAppInfo.IsSRP) && InstallConfiguration.SuggestDeploymentToCentralAdminWebApplication) || ((!(application.IsAdministrationWebApplication || webAppInfo.IsSRP)) && InstallConfiguration.SuggestDeploymentToAllContentWebApplications)); webAppTreeNode.TreeNodePopulate += new ExtendedTreeNode.TreeNodeEventHandler(WebAppTreeNode_TreeNodePopulate); } }
protected internal override void Close(InstallOptions options) { WebApplicationInfo webAppInfo; if (InstallConfiguration.RequireDeploymentToCentralAdminWebApplication) { foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes) { if (((webAppInfo = webAppTreeNode.Tag as WebApplicationInfo) != null) && (webAppInfo.IsSRP || ((webAppInfo.Application != null) && webAppInfo.Application.IsAdministrationWebApplication))) { webAppTreeNode.Checked = true; foreach (TreeNode tn in webAppTreeNode.Nodes) { tn.Checked = true; } } } } foreach (TreeNode webAppTreeNode in siteCollectionsTreeView.Nodes) { // Add the web application as a target if (webAppTreeNode.Checked && ((webAppInfo = webAppTreeNode.Tag as WebApplicationInfo) != null)) { options.WebApplicationTargets.Add(webAppInfo.Application); ExtendedTreeNode extendedWebAppTreeNode = webAppTreeNode as ExtendedTreeNode; if (extendedWebAppTreeNode != null) { if (!extendedWebAppTreeNode.Populated) { // Add ALL site collections within the web app as targets foreach (SPSite siteCollection in webAppInfo.Application.Sites) { options.SiteCollectionTargets.Add(siteCollection); } } else { // Add the checked site collections within this web application as targets foreach (TreeNode siteCollTreeNode in webAppTreeNode.Nodes) { if (siteCollTreeNode.Checked) { SiteCollectionInfo siteCollInfo = siteCollTreeNode.Tag as SiteCollectionInfo; if (siteCollInfo != null) { options.SiteCollectionTargets.Add(siteCollInfo.SiteCollection); } } } } } } } }
public static ExtendedTreeNode AddNewExtendedTreeNode(TreeNodeCollection parentNodeCollection, string text, bool populateOnDemand, object tag) { ExtendedTreeNode extendedTreeNode = new ExtendedTreeNode(text, populateOnDemand, tag); parentNodeCollection.Add(extendedTreeNode); if (extendedTreeNode.TreeView == null) { throw new InvalidOperationException("You cannot add a new ExtendedTreeNode to a node that is not already a member of a TreeView."); } extendedTreeNode.Prepare(); return(extendedTreeNode); }
private void CheckParentNode(TreeNode node, bool value) { ExtendedTreeNode extendedNode = node as ExtendedTreeNode; if (extendedNode != null) { extendedNode.PreventChildCheck = true; } try { node.Checked = value; } finally { if (extendedNode != null) { extendedNode.PreventChildCheck = false; } } }