- Timestamp:
- 03/16/10 17:14:35 (15 years ago)
- Location:
- branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/HeuristicLab.DeploymentService.AdminClient.csproj
r3045 r3068 87 87 <Compile Include="LicenseView.Designer.cs"> 88 88 <DependentUpon>LicenseView.cs</DependentUpon> 89 </Compile> 90 <Compile Include="MultiSelectListView.cs"> 91 <SubType>Component</SubType> 92 </Compile> 93 <Compile Include="MultiSelectListView.Designer.cs"> 94 <DependentUpon>MultiSelectListView.cs</DependentUpon> 89 95 </Compile> 90 96 <Compile Include="PluginComparisonView.cs"> -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginEditor.Designer.cs
r3045 r3068 25 25 private void InitializeComponent() { 26 26 this.components = new System.ComponentModel.Container(); 27 this.listView = new System.Windows.Forms.ListView();28 this.nameHeader = new System.Windows.Forms.ColumnHeader();29 this.localVersion = new System.Windows.Forms.ColumnHeader();30 this.serverVersion = new System.Windows.Forms.ColumnHeader();31 27 this.imageList = new System.Windows.Forms.ImageList(this.components); 32 28 this.refreshButton = new System.Windows.Forms.Button(); 33 29 this.uploadButton = new System.Windows.Forms.Button(); 30 this.listView = new HeuristicLab.DeploymentService.AdminClient.MultiSelectListView(); 31 this.pluginNameHeader = new System.Windows.Forms.ColumnHeader(); 32 this.localVersionHeader = new System.Windows.Forms.ColumnHeader(); 33 this.serverVersionHeader = new System.Windows.Forms.ColumnHeader(); 34 this.descriptionHeader = new System.Windows.Forms.ColumnHeader(); 34 35 this.SuspendLayout(); 35 //36 // listView37 //38 this.listView.Activation = System.Windows.Forms.ItemActivation.TwoClick;39 this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)40 | System.Windows.Forms.AnchorStyles.Left)41 | System.Windows.Forms.AnchorStyles.Right)));42 this.listView.CheckBoxes = true;43 this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {44 this.nameHeader,45 this.localVersion,46 this.serverVersion});47 this.listView.Enabled = false;48 this.listView.FullRowSelect = true;49 this.listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;50 this.listView.Location = new System.Drawing.Point(0, 30);51 this.listView.Name = "listView";52 this.listView.ShowGroups = false;53 this.listView.Size = new System.Drawing.Size(536, 446);54 this.listView.StateImageList = this.imageList;55 this.listView.TabIndex = 0;56 this.listView.UseCompatibleStateImageBehavior = false;57 this.listView.View = System.Windows.Forms.View.Details;58 this.listView.ItemActivate += new System.EventHandler(this.listView_ItemActivate);59 this.listView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView_ItemChecked);60 //61 // nameHeader62 //63 this.nameHeader.Text = "Name";64 this.nameHeader.Width = 188;65 //66 // localVersion67 //68 this.localVersion.Text = "Local version";69 this.localVersion.Width = 100;70 //71 // serverVersion72 //73 this.serverVersion.Text = "Server version";74 this.serverVersion.Width = 100;75 36 // 76 37 // imageList 77 38 // 78 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth 8Bit;39 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; 79 40 this.imageList.ImageSize = new System.Drawing.Size(16, 16); 80 41 this.imageList.TransparentColor = System.Drawing.Color.Transparent; … … 101 62 this.uploadButton.Click += new System.EventHandler(this.uploadButton_Click); 102 63 // 103 // PluginListView 64 // listView 65 // 66 this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 67 | System.Windows.Forms.AnchorStyles.Left) 68 | System.Windows.Forms.AnchorStyles.Right))); 69 this.listView.CheckBoxes = true; 70 this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 71 this.pluginNameHeader, 72 this.localVersionHeader, 73 this.serverVersionHeader, 74 this.descriptionHeader}); 75 this.listView.Location = new System.Drawing.Point(3, 32); 76 this.listView.Name = "listView"; 77 this.listView.Size = new System.Drawing.Size(536, 444); 78 this.listView.StateImageList = this.imageList; 79 this.listView.SuppressItemCheckedEvents = false; 80 this.listView.TabIndex = 8; 81 this.listView.UseCompatibleStateImageBehavior = false; 82 this.listView.View = System.Windows.Forms.View.Details; 83 this.listView.ItemActivate += new System.EventHandler(this.listView_ItemActivate); 84 this.listView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView_ItemChecked); 85 // 86 // pluginNameHeader 87 // 88 this.pluginNameHeader.Text = "Name"; 89 this.pluginNameHeader.Width = 161; 90 // 91 // localVersionHeader 92 // 93 this.localVersionHeader.Text = "Local Version"; 94 this.localVersionHeader.Width = 85; 95 // 96 // serverVersionHeader 97 // 98 this.serverVersionHeader.Text = "Server Version"; 99 this.serverVersionHeader.Width = 91; 100 // 101 // descriptionHeader 102 // 103 this.descriptionHeader.Text = "Description"; 104 this.descriptionHeader.Width = 194; 105 // 106 // PluginEditor 104 107 // 105 108 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 106 109 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 110 this.Controls.Add(this.listView); 107 111 this.Controls.Add(this.uploadButton); 108 112 this.Controls.Add(this.refreshButton); 109 this.Controls.Add(this.listView); 110 this.Name = "PluginListView"; 113 this.Name = "PluginEditor"; 111 114 this.Size = new System.Drawing.Size(539, 508); 112 115 this.ResumeLayout(false); … … 116 119 #endregion 117 120 118 private System.Windows.Forms.ListView listView;119 private System.Windows.Forms.ColumnHeader nameHeader;120 private System.Windows.Forms.ColumnHeader localVersion;121 private System.Windows.Forms.ColumnHeader serverVersion;122 121 private System.Windows.Forms.Button refreshButton; 123 122 private System.Windows.Forms.Button uploadButton; 124 123 private System.Windows.Forms.ImageList imageList; 124 private MultiSelectListView listView; 125 private System.Windows.Forms.ColumnHeader pluginNameHeader; 126 private System.Windows.Forms.ColumnHeader localVersionHeader; 127 private System.Windows.Forms.ColumnHeader serverVersionHeader; 128 private System.Windows.Forms.ColumnHeader descriptionHeader; 125 129 } 126 130 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginEditor.cs
r3045 r3068 61 61 // refresh the list view with plugins 62 62 listView.Items.Clear(); 63 listView.CheckBoxes = false; 64 //suppressCheckedEvents = true; 63 65 foreach (var pair in localAndServerPlugins) { 64 66 var item = MakeListViewItem(pair.Key); 65 67 listView.Items.Add(item); 66 68 } 69 //listView.suppressCheckedEvents = false; 70 listView.CheckBoxes = true; 67 71 UpdateControlsConnectedState(); 68 72 } else { … … 108 112 109 113 foreach (var plugin in IteratePlugins(selectedPlugins)) { 110 adminClient.DeployPlugin(MakePluginDescription(plugin), CreateZipPackage(plugin));114 adminClient.DeployPlugin(MakePluginDescription(plugin), CreateZipPackage(plugin)); 111 115 } 112 116 e.Cancel = false; … … 156 160 } 157 161 158 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 159 // also check all dependencies162 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 163 List<IPluginDescription> modifiedPlugins = new List<IPluginDescription>(); 160 164 if (e.Item.Checked) { 161 uploadButton.Enabled = true; 162 var plugin = (IPluginDescription)e.Item.Tag; 163 foreach (var dep in plugin.Dependencies) { 164 var depItem = FindItemForPlugin(dep); 165 if (!depItem.Checked) depItem.Checked = true; 166 } 167 } else { 168 uploadButton.Enabled = (from i in listView.Items.Cast<ListViewItem>() 169 where i.Checked 170 select i).Any(); 171 // also uncheck all dependent plugins 172 var plugin = (IPluginDescription)e.Item.Tag; 173 foreach (ListViewItem item in listView.Items) { 174 var dep = (IPluginDescription)item.Tag; 175 if (dep.Dependencies.Contains(plugin) && item.Checked) { 176 item.Checked = false; 165 foreach (ListViewItem item in listView.SelectedItems) { 166 var plugin = (IPluginDescription)item.Tag; 167 // also check all dependencies 168 modifiedPlugins.Add(plugin); 169 foreach (var dep in GetAllDependencies(plugin)) { 170 modifiedPlugins.Add(dep); 177 171 } 178 172 } 179 } 173 listView.CheckItems(modifiedPlugins.Select(x => FindItemForPlugin(x))); 174 } else { 175 foreach (ListViewItem item in listView.SelectedItems) { 176 var plugin = (IPluginDescription)item.Tag; 177 // also uncheck all dependent plugins 178 modifiedPlugins.Add(plugin); 179 foreach (var dep in GetAllDependents(plugin)) { 180 modifiedPlugins.Add(dep); 181 } 182 } 183 listView.UncheckItems(modifiedPlugins.Select(x => FindItemForPlugin(x))); 184 } 185 uploadButton.Enabled = (from i in listView.Items.OfType<ListViewItem>() 186 where i.Checked 187 select i).Any(); 180 188 } 181 189 #endregion 182 190 183 191 #region helper methods 192 private IEnumerable<IPluginDescription> GetAllDependents(IPluginDescription plugin) { 193 return from p in localAndServerPlugins.Keys 194 let matchingEntries = from dep in GetAllDependencies(p) 195 where dep.Name == plugin.Name 196 where dep.Version == plugin.Version 197 select dep 198 where matchingEntries.Any() 199 select p; 200 } 201 202 private IEnumerable<IPluginDescription> GetAllDependencies(IPluginDescription plugin) { 203 foreach (var dep in plugin.Dependencies) { 204 foreach (var recDep in GetAllDependencies(dep)) { 205 yield return recDep; 206 } 207 yield return dep; 208 } 209 } 210 211 private IEnumerable<IPluginDescription> IteratePlugins(IEnumerable<IPluginDescription> plugins) { 212 foreach (var plugin in plugins) { 213 foreach (var dependency in IteratePlugins(plugin.Dependencies)) { 214 yield return dependency; 215 } 216 yield return plugin; 217 } 218 } 219 184 220 private byte[] CreateZipPackage(IPluginDescription plugin) { 185 221 using (MemoryStream stream = new MemoryStream()) { … … 198 234 ListViewItem item; 199 235 if (localAndServerPlugins[plugin] != null) { 200 item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), localAndServerPlugins[plugin].Version.ToString() }); 201 } else { 202 item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), string.Empty }); 236 item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), 237 localAndServerPlugins[plugin].Version.ToString(), localAndServerPlugins[plugin].Description }); 238 } else { 239 item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), 240 string.Empty, plugin.Description }); 203 241 } 204 242 item.Tag = plugin; … … 217 255 select MakePluginDescription(dep); 218 256 return new PluginDeploymentService.PluginDescription(plugin.Name, plugin.Version, dependencies, plugin.ContactName, plugin.ContactEmail, plugin.LicenseText); 219 }220 221 private IEnumerable<IPluginDescription> IteratePlugins(IEnumerable<IPluginDescription> plugins) {222 foreach (var plugin in plugins) {223 foreach (var dependency in IteratePlugins(plugin.Dependencies)) {224 yield return dependency;225 }226 yield return plugin;227 }228 257 } 229 258 -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.Designer.cs
r3045 r3068 29 29 private void InitializeComponent() 30 30 { 31 this.listView = new System.Windows.Forms.ListView();31 this.listView = new HeuristicLab.DeploymentService.AdminClient.MultiSelectListView(); 32 32 this.nameHeader = new System.Windows.Forms.ColumnHeader(); 33 33 this.versionHeader = new System.Windows.Forms.ColumnHeader(); … … 41 41 this.versionHeader}); 42 42 this.listView.Dock = System.Windows.Forms.DockStyle.Fill; 43 this.listView.FullRowSelect = true;44 43 this.listView.Location = new System.Drawing.Point(0, 0); 45 44 this.listView.Name = "listView"; 46 45 this.listView.Size = new System.Drawing.Size(341, 320); 47 this.listView.TabIndex = 0;46 this.listView.TabIndex = 1; 48 47 this.listView.UseCompatibleStateImageBehavior = false; 49 48 this.listView.View = System.Windows.Forms.View.Details; … … 71 70 #endregion 72 71 73 private System.Windows.Forms.ListView listView;72 private MultiSelectListView listView; 74 73 private System.Windows.Forms.ColumnHeader nameHeader; 75 74 private System.Windows.Forms.ColumnHeader versionHeader; 76 } 75 76 } 77 77 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.cs
r3045 r3068 10 10 11 11 namespace HeuristicLab.DeploymentService.AdminClient { 12 /// <summary> 13 /// Wraps a ListView and adds functionality to automatically check and uncheck dependencies of plugins. 14 /// </summary> 12 15 public partial class PluginListView : UserControl { 13 16 public event ItemCheckedEventHandler ItemChecked; … … 18 21 set { 19 22 plugins = value; 23 checkedPlugins.Clear(); 20 24 UpdateControls(); 21 25 } 22 26 } 23 27 28 private List<IPluginDescription> checkedPlugins = new List<IPluginDescription>(); 24 29 public IEnumerable<IPluginDescription> CheckedPlugins { 25 30 get { 26 return from item in listView.Items.OfType<ListViewItem>() 27 where item.Checked 28 select item.Tag as IPluginDescription; 31 return checkedPlugins; 29 32 } 30 33 } 31 32 private bool suppressItemCheckedEvents = false;33 34 34 35 public PluginListView() { … … 37 38 38 39 public void CheckPlugin(IPluginDescription plugin) { 39 var items = FindItemsForPlugin(plugin); 40 if (items.Count() == 0) throw new ArgumentException(); 41 var item = items.Single(); 42 if (!item.Checked) { 43 suppressItemCheckedEvents = true; 44 item.Checked = true; 45 suppressItemCheckedEvents = false; 46 } 40 MarkPluginChecked(plugin); 41 listView.CheckItems(new IPluginDescription[] { plugin }.Select(x => FindItemsForPlugin(x).Single())); 47 42 } 43 48 44 49 45 private void UpdateControls() { 50 46 if (plugins != null) { 51 47 listView.Items.Clear(); 52 suppressItemCheckedEvents = true;48 listView.SuppressItemCheckedEvents = true; 53 49 foreach (var plugin in plugins) { 54 50 listView.Items.Add(CreateListViewItem(plugin)); 55 51 } 56 suppressItemCheckedEvents = false;52 listView.SuppressItemCheckedEvents = false; 57 53 } 58 54 } … … 60 56 private ListViewItem CreateListViewItem(IPluginDescription plugin) { 61 57 var item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString() }); 58 item.Checked = (from p in checkedPlugins where p.Name == plugin.Name where p.Version == plugin.Version select p).Any(); 62 59 item.Tag = plugin; 63 60 return item; … … 65 62 66 63 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 67 if (suppressItemCheckedEvents) return;64 List<IPluginDescription> modifiedPlugins = new List<IPluginDescription>(); 68 65 if (e.Item.Checked) { 69 // also check all dependencies 70 suppressItemCheckedEvents = true; 71 var dependencies = GetAllDependencies(e.Item.Tag as IPluginDescription); 72 foreach (var dep in dependencies) { 73 var item = FindItemsForPlugin(dep).Single(); 74 if (!item.Checked) item.Checked = true; 66 foreach (ListViewItem item in listView.SelectedItems) { 67 var plugin = (IPluginDescription)item.Tag; 68 // also check all dependencies 69 MarkPluginChecked(plugin); 70 modifiedPlugins.Add(plugin); 71 foreach (var dep in GetAllDependencies(plugin)) { 72 MarkPluginChecked(dep); 73 modifiedPlugins.Add(dep); 74 } 75 75 } 76 suppressItemCheckedEvents = false; 76 listView.CheckItems(modifiedPlugins.Select(x => FindItemsForPlugin(x).Single())); 77 OnItemChecked(e); 77 78 } else { 78 // also uncheck all dependencies 79 suppressItemCheckedEvents = true; 80 var dependents = GetAllDependents(e.Item.Tag as IPluginDescription); 81 foreach (var dep in dependents) { 82 var item = FindItemsForPlugin(dep).Single(); 83 if (item.Checked) item.Checked = false; 79 foreach (ListViewItem item in listView.SelectedItems) { 80 var plugin = (IPluginDescription)item.Tag; 81 // also uncheck all dependent plugins 82 MarkPluginUnchecked(plugin); 83 modifiedPlugins.Add(plugin); 84 foreach (var dep in GetAllDependents(plugin)) { 85 MarkPluginUnchecked(dep); 86 modifiedPlugins.Add(dep); 87 } 88 84 89 } 85 suppressItemCheckedEvents = false; 90 listView.UncheckItems(modifiedPlugins.Select(x => FindItemsForPlugin(x).Single())); 91 OnItemChecked(e); 86 92 } 87 OnItemChecked(e); 93 } 94 95 private void MarkPluginChecked(IPluginDescription plugin) { 96 var matching = from p in checkedPlugins 97 where p.Name == plugin.Name 98 where p.Version == plugin.Version 99 select p; 100 if (!matching.Any()) checkedPlugins.Add(plugin); 101 } 102 103 private void MarkPluginUnchecked(IPluginDescription plugin) { 104 checkedPlugins = (from p in checkedPlugins 105 where p.Name != plugin.Name || 106 p.Version != plugin.Version 107 select p).ToList(); 88 108 } 89 109 … … 116 136 117 137 private void OnItemChecked(ItemCheckedEventArgs e) { 118 if (ItemChecked != null && !suppressItemCheckedEvents) ItemChecked(this, e);138 if (ItemChecked != null) ItemChecked(this, e); 119 139 } 120 140 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.resx
r2860 r3068 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="imageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">121 <value>17, 17</value>122 </metadata>123 120 </root>
Note: See TracChangeset
for help on using the changeset viewer.