Changeset 3045 for branches/DeploymentServer Prototype
- Timestamp:
- 03/15/10 19:34:35 (15 years ago)
- Location:
- branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient
- Files:
-
- 7 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/HeuristicLab.DeploymentService.AdminClient.csproj
r3015 r3045 94 94 <DependentUpon>PluginComparisonView.cs</DependentUpon> 95 95 </Compile> 96 <Compile Include="PluginEditor.cs"> 97 <SubType>UserControl</SubType> 98 </Compile> 99 <Compile Include="PluginEditor.Designer.cs"> 100 <DependentUpon>PluginEditor.cs</DependentUpon> 101 </Compile> 102 <Compile Include="PluginListView.cs"> 103 <SubType>UserControl</SubType> 104 </Compile> 105 <Compile Include="PluginListView.Designer.cs"> 106 <DependentUpon>PluginListView.cs</DependentUpon> 107 </Compile> 96 108 <Compile Include="PluginView.cs"> 97 109 <SubType>UserControl</SubType> … … 113 125 <Compile Include="MainForm.cs"> 114 126 <SubType>Form</SubType> 115 </Compile>116 <Compile Include="PluginListView.cs">117 <SubType>UserControl</SubType>118 </Compile>119 <Compile Include="PluginListView.Designer.cs">120 <DependentUpon>PluginListView.cs</DependentUpon>121 127 </Compile> 122 128 <Compile Include="Properties\AssemblyInfo.cs" /> … … 157 163 <DependentUpon>PluginComparisonView.cs</DependentUpon> 158 164 </EmbeddedResource> 165 <EmbeddedResource Include="PluginEditor.resx"> 166 <DependentUpon>PluginEditor.cs</DependentUpon> 167 </EmbeddedResource> 168 <EmbeddedResource Include="PluginListView.resx"> 169 <DependentUpon>PluginListView.cs</DependentUpon> 170 </EmbeddedResource> 159 171 <EmbeddedResource Include="PluginView.resx"> 160 172 <DependentUpon>PluginView.cs</DependentUpon> … … 162 174 <EmbeddedResource Include="ProductEditor.resx"> 163 175 <DependentUpon>ProductEditor.cs</DependentUpon> 164 </EmbeddedResource>165 <EmbeddedResource Include="PluginListView.resx">166 <DependentUpon>PluginListView.cs</DependentUpon>167 176 </EmbeddedResource> 168 177 </ItemGroup> -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/MainForm.cs
r2922 r3045 16 16 protected override void OnInitialized(EventArgs e) { 17 17 base.OnInitialized(e); 18 (new Plugin ListView()).Show();18 (new PluginEditor()).Show(); 19 19 } 20 20 -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/OpenServerProductsEditMenuItem.cs
r2802 r3045 8 8 class OpenServerProductsEditorMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IUserInterfaceItemProvider { 9 9 public override string Name { 10 get { return "Edit products"; }10 get { return "Edit Products"; } 11 11 } 12 12 13 13 public override IEnumerable<string> Structure { 14 get { return new string[] { "Plugin server" }; }14 get { return new string[] { "Plugin Server" }; } 15 15 } 16 16 -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginEditor.Designer.cs
r3038 r3045 1 1 namespace HeuristicLab.DeploymentService.AdminClient { 2 partial class Plugin ListView{2 partial class PluginEditor { 3 3 /// <summary> 4 4 /// Required designer variable. -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginEditor.cs
r3038 r3045 16 16 17 17 namespace HeuristicLab.DeploymentService.AdminClient { 18 public partial class Plugin ListView: HeuristicLab.MainForm.WindowsForms.View {18 public partial class PluginEditor : HeuristicLab.MainForm.WindowsForms.View { 19 19 private Dictionary<IPluginDescription, PluginDeploymentService.PluginDescription> localAndServerPlugins; 20 20 private BackgroundWorker pluginUploadWorker; 21 21 private BackgroundWorker updateServerPluginsWorker; 22 22 23 public Plugin ListView() {23 public PluginEditor() { 24 24 InitializeComponent(); 25 25 imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly); … … 156 156 } 157 157 158 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 158 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 159 159 // also check all dependencies 160 160 if (e.Item.Checked) { -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.Designer.cs
r3015 r3045 1 namespace HeuristicLab.DeploymentService.AdminClient { 2 partial class PluginListView { 3 /// <summary> 4 /// Required designer variable. 5 /// </summary> 6 private System.ComponentModel.IContainer components = null; 1 namespace HeuristicLab.DeploymentService.AdminClient 2 { 3 partial class PluginListView 4 { 5 /// <summary> 6 /// Required designer variable. 7 /// </summary> 8 private System.ComponentModel.IContainer components = null; 7 9 8 /// <summary> 9 /// Clean up any resources being used. 10 /// </summary> 11 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 12 protected override void Dispose(bool disposing) { 13 if (disposing && (components != null)) { 14 components.Dispose(); 15 } 16 base.Dispose(disposing); 17 } 10 /// <summary> 11 /// Clean up any resources being used. 12 /// </summary> 13 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 14 protected override void Dispose(bool disposing) 15 { 16 if (disposing && (components != null)) 17 { 18 components.Dispose(); 19 } 20 base.Dispose(disposing); 21 } 18 22 19 23 #region Component Designer generated code 20 24 21 22 23 24 25 private void InitializeComponent() { 26 this.components = new System.ComponentModel.Container(); 25 /// <summary> 26 /// Required method for Designer support - do not modify 27 /// the contents of this method with the code editor. 28 /// </summary> 29 private void InitializeComponent() 30 { 27 31 this.listView = new System.Windows.Forms.ListView(); 28 32 this.nameHeader = new System.Windows.Forms.ColumnHeader(); 29 this.localVersion = new System.Windows.Forms.ColumnHeader(); 30 this.serverVersion = new System.Windows.Forms.ColumnHeader(); 31 this.imageList = new System.Windows.Forms.ImageList(this.components); 32 this.refreshButton = new System.Windows.Forms.Button(); 33 this.uploadButton = new System.Windows.Forms.Button(); 33 this.versionHeader = new System.Windows.Forms.ColumnHeader(); 34 34 this.SuspendLayout(); 35 35 // 36 36 // listView 37 37 // 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 38 this.listView.CheckBoxes = true; 43 39 this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 44 40 this.nameHeader, 45 this.localVersion, 46 this.serverVersion}); 47 this.listView.Enabled = false; 41 this.versionHeader}); 42 this.listView.Dock = System.Windows.Forms.DockStyle.Fill; 48 43 this.listView.FullRowSelect = true; 49 this.listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 50 this.listView.Location = new System.Drawing.Point(0, 30); 44 this.listView.Location = new System.Drawing.Point(0, 0); 51 45 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; 46 this.listView.Size = new System.Drawing.Size(341, 320); 55 47 this.listView.TabIndex = 0; 56 48 this.listView.UseCompatibleStateImageBehavior = false; 57 49 this.listView.View = System.Windows.Forms.View.Details; 58 this.listView.ItemActivate += new System.EventHandler(this.listView_ItemActivate);59 50 this.listView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView_ItemChecked); 60 51 // … … 62 53 // 63 54 this.nameHeader.Text = "Name"; 64 this.nameHeader.Width = 188;65 55 // 66 // localVersion56 // versionHeader 67 57 // 68 this.localVersion.Text = "Local version"; 69 this.localVersion.Width = 100; 70 // 71 // serverVersion 72 // 73 this.serverVersion.Text = "Server version"; 74 this.serverVersion.Width = 100; 75 // 76 // imageList 77 // 78 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 79 this.imageList.ImageSize = new System.Drawing.Size(16, 16); 80 this.imageList.TransparentColor = System.Drawing.Color.Transparent; 81 // 82 // refreshButton 83 // 84 this.refreshButton.Location = new System.Drawing.Point(3, 3); 85 this.refreshButton.Name = "refreshButton"; 86 this.refreshButton.Size = new System.Drawing.Size(75, 23); 87 this.refreshButton.TabIndex = 6; 88 this.refreshButton.Text = "Refresh"; 89 this.refreshButton.UseVisualStyleBackColor = true; 90 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 91 // 92 // uploadButton 93 // 94 this.uploadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 95 this.uploadButton.Location = new System.Drawing.Point(3, 482); 96 this.uploadButton.Name = "uploadButton"; 97 this.uploadButton.Size = new System.Drawing.Size(75, 23); 98 this.uploadButton.TabIndex = 7; 99 this.uploadButton.Text = "Upload"; 100 this.uploadButton.UseVisualStyleBackColor = true; 101 this.uploadButton.Click += new System.EventHandler(this.uploadButton_Click); 58 this.versionHeader.Text = "Version"; 102 59 // 103 60 // PluginListView … … 105 62 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 106 63 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 107 this.Controls.Add(this.uploadButton);108 this.Controls.Add(this.refreshButton);109 64 this.Controls.Add(this.listView); 110 65 this.Name = "PluginListView"; 111 this.Size = new System.Drawing.Size( 539, 508);66 this.Size = new System.Drawing.Size(341, 320); 112 67 this.ResumeLayout(false); 113 68 114 69 } 115 70 116 71 #endregion 117 72 118 73 private System.Windows.Forms.ListView listView; 119 74 private System.Windows.Forms.ColumnHeader nameHeader; 120 private System.Windows.Forms.ColumnHeader localVersion; 121 private System.Windows.Forms.ColumnHeader serverVersion; 122 private System.Windows.Forms.Button refreshButton; 123 private System.Windows.Forms.Button uploadButton; 124 private System.Windows.Forms.ImageList imageList; 125 } 75 private System.Windows.Forms.ColumnHeader versionHeader; 76 } 126 77 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.cs
r3015 r3045 7 7 using System.Text; 8 8 using System.Windows.Forms; 9 using HeuristicLab.MainForm;10 9 using HeuristicLab.PluginInfrastructure; 11 using PluginDeploymentService = HeuristicLab.PluginInfrastructure.Advanced.DeploymentService;12 using HeuristicLab.PluginInfrastructure.Manager;13 using System.ServiceModel;14 using ICSharpCode.SharpZipLib.Zip;15 using System.IO;16 10 17 11 namespace HeuristicLab.DeploymentService.AdminClient { 18 public partial class PluginListView : HeuristicLab.MainForm.WindowsForms.View { 19 private Dictionary<IPluginDescription, PluginDeploymentService.PluginDescription> localAndServerPlugins; 20 private BackgroundWorker pluginUploadWorker; 21 private BackgroundWorker updateServerPluginsWorker; 12 public partial class PluginListView : UserControl { 13 public event ItemCheckedEventHandler ItemChecked; 14 15 private IEnumerable<IPluginDescription> plugins; 16 public IEnumerable<IPluginDescription> Plugins { 17 get { return plugins; } 18 set { 19 plugins = value; 20 UpdateControls(); 21 } 22 } 23 24 public IEnumerable<IPluginDescription> CheckedPlugins { 25 get { 26 return from item in listView.Items.OfType<ListViewItem>() 27 where item.Checked 28 select item.Tag as IPluginDescription; 29 } 30 } 31 32 private bool suppressItemCheckedEvents = false; 22 33 23 34 public PluginListView() { 24 35 InitializeComponent(); 25 imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly);26 imageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.ArrowUp);27 Caption = "Plugins";28 29 localAndServerPlugins = new Dictionary<IPluginDescription, PluginDeploymentService.PluginDescription>();30 31 #region initialize backgroundworkers32 pluginUploadWorker = new BackgroundWorker();33 pluginUploadWorker.DoWork += new DoWorkEventHandler(pluginUploadWorker_DoWork);34 pluginUploadWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(pluginUploadWorker_RunWorkerCompleted);35 36 updateServerPluginsWorker = new BackgroundWorker();37 updateServerPluginsWorker.DoWork += new DoWorkEventHandler(updateServerPluginsWorker_DoWork);38 updateServerPluginsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(updateServerPluginsWorker_RunWorkerCompleted);39 #endregion40 36 } 41 37 42 #region refresh plugins from server backgroundworker 43 void updateServerPluginsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 44 if (!e.Cancelled && e.Result != null) { 45 // refresh local plugins 46 localAndServerPlugins.Clear(); 47 foreach (var plugin in ApplicationManager.Manager.Plugins) { 48 localAndServerPlugins.Add(plugin, null); 49 } 50 // refresh server plugins (find matching local plugins) 51 var plugins = (PluginDeploymentService.PluginDescription[])e.Result; 52 foreach (var plugin in plugins) { 53 var matchingLocalPlugin = (from localPlugin in localAndServerPlugins.Keys 54 where localPlugin.Name == plugin.Name 55 where localPlugin.Version == localPlugin.Version 56 select localPlugin).SingleOrDefault(); 57 if (matchingLocalPlugin != null) { 58 localAndServerPlugins[matchingLocalPlugin] = plugin; 59 } 60 } 61 // refresh the list view with plugins 62 listView.Items.Clear(); 63 foreach (var pair in localAndServerPlugins) { 64 var item = MakeListViewItem(pair.Key); 65 listView.Items.Add(item); 66 } 67 UpdateControlsConnectedState(); 68 } else { 69 UpdateControlsDisconnectedState(); 70 } 71 // make sure cursor is set correctly 72 Cursor = Cursors.Default; 73 } 74 75 void updateServerPluginsWorker_DoWork(object sender, DoWorkEventArgs e) { 76 try { 77 var client = PluginDeploymentService.UpdateClientFactory.CreateClient(); 78 e.Result = client.GetPlugins(); 79 e.Cancel = false; 80 } 81 catch (EndpointNotFoundException) { 82 e.Result = null; 83 e.Cancel = true; 84 } 85 catch (FaultException) { 86 e.Result = null; 87 e.Cancel = true; 88 } 89 } 90 #endregion 91 92 #region upload plugins to server backgroundworker 93 void pluginUploadWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { 94 Cursor = Cursors.Default; 95 if (e.Cancelled) { 96 UpdateControlsDisconnectedState(); 97 } else { 98 UpdateControlsConnectedState(); 99 // start another async call to refresh plugin information from server 100 RefreshPluginsAsync(); 38 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; 101 46 } 102 47 } 103 48 104 void pluginUploadWorker_DoWork(object sender, DoWorkEventArgs e) { 105 try { 106 var selectedPlugins = (IEnumerable<IPluginDescription>)e.Argument; 107 PluginDeploymentService.AdminClient adminClient = PluginDeploymentService.AdminClientFactory.CreateClient(); 108 109 foreach (var plugin in IteratePlugins(selectedPlugins)) { 110 adminClient.DeployPlugin(MakePluginDescription(plugin), CreateZipPackage(plugin)); 49 private void UpdateControls() { 50 if (plugins != null) { 51 listView.Items.Clear(); 52 suppressItemCheckedEvents = true; 53 foreach (var plugin in plugins) { 54 listView.Items.Add(CreateListViewItem(plugin)); 111 55 } 112 e.Cancel = false; 113 } 114 catch (EndpointNotFoundException) { 115 e.Cancel = true; 116 } 117 catch (FaultException) { 118 e.Cancel = true; 119 } 120 } 121 #endregion 122 123 124 #region button events 125 private void uploadButton_Click(object sender, EventArgs e) { 126 var selectedPlugins = from item in listView.Items.Cast<ListViewItem>() 127 where item.Checked 128 where item.Tag is IPluginDescription 129 select item.Tag as IPluginDescription; 130 if (selectedPlugins.Count() > 0) { 131 Cursor = Cursors.AppStarting; 132 DisableControl(); 133 pluginUploadWorker.RunWorkerAsync(selectedPlugins.ToList()); 56 suppressItemCheckedEvents = false; 134 57 } 135 58 } 136 59 137 private void connectButton_Click(object sender, EventArgs e) { 138 var connectionSetupView = new ConnectionSetupView(); 139 connectionSetupView.Show(); 60 private ListViewItem CreateListViewItem(IPluginDescription plugin) { 61 var item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString() }); 62 item.Tag = plugin; 63 return item; 140 64 } 141 65 142 private void refreshButton_Click(object sender, EventArgs e) { 143 DisableControl(); 144 RefreshPluginsAsync(); 66 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 67 if (suppressItemCheckedEvents) return; 68 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; 75 } 76 suppressItemCheckedEvents = false; 77 } 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; 84 } 85 suppressItemCheckedEvents = false; 86 } 87 OnItemChecked(e); 145 88 } 146 89 147 #endregion 90 private IEnumerable<ListViewItem> FindItemsForPlugin(IPluginDescription plugin) { 91 return from item in listView.Items.OfType<ListViewItem>() 92 let p = item.Tag as IPluginDescription 93 where p.Name == plugin.Name 94 where p.Version == plugin.Version 95 select item; 96 } 148 97 149 #region item list events 150 private void listView_ItemActivate(object sender, EventArgs e) { 151 foreach (var item in listView.SelectedItems) { 152 var plugin = (IPluginDescription)((ListViewItem)item).Tag; 153 var compView = new PluginComparisonView(plugin, localAndServerPlugins[plugin]); 154 compView.Show(); 98 private IEnumerable<IPluginDescription> GetAllDependents(IPluginDescription plugin) { 99 return from p in plugins 100 let matchingEntries = from dep in GetAllDependencies(p) 101 where dep.Name == plugin.Name 102 where dep.Version == plugin.Version 103 select dep 104 where matchingEntries.Any() 105 select p; 106 } 107 108 private IEnumerable<IPluginDescription> GetAllDependencies(IPluginDescription plugin) { 109 foreach (var dep in plugin.Dependencies) { 110 foreach (var recDep in GetAllDependencies(dep)) { 111 yield return recDep; 112 } 113 yield return dep; 155 114 } 156 115 } 157 116 158 private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { 159 // also check all dependencies 160 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; 177 } 178 } 179 } 117 private void OnItemChecked(ItemCheckedEventArgs e) { 118 if (ItemChecked != null && !suppressItemCheckedEvents) ItemChecked(this, e); 180 119 } 181 #endregion182 183 #region helper methods184 private byte[] CreateZipPackage(IPluginDescription plugin) {185 using (MemoryStream stream = new MemoryStream()) {186 ZipFile zipFile = new ZipFile(stream);187 zipFile.BeginUpdate();188 foreach (var file in plugin.Files) {189 zipFile.Add(file.Name);190 }191 zipFile.CommitUpdate();192 stream.Seek(0, SeekOrigin.Begin);193 return stream.GetBuffer();194 }195 }196 197 private ListViewItem MakeListViewItem(IPluginDescription plugin) {198 ListViewItem item;199 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 });203 }204 item.Tag = plugin;205 item.Checked = false;206 return item;207 }208 209 private ListViewItem FindItemForPlugin(IPluginDescription dep) {210 return (from i in listView.Items.Cast<ListViewItem>()211 where i.Tag == dep212 select i).Single();213 }214 215 private PluginDeploymentService.PluginDescription MakePluginDescription(IPluginDescription plugin) {216 var dependencies = from dep in plugin.Dependencies217 select MakePluginDescription(dep);218 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 }229 230 // start background process to refresh the plugin list (local and server)231 private void RefreshPluginsAsync() {232 Cursor = Cursors.AppStarting;233 DisableControl();234 updateServerPluginsWorker.RunWorkerAsync();235 }236 237 // is called by all methods that start a background process238 // controls must be enabled manuall again when the backgroundworker finishes239 private void DisableControl() {240 MainFormManager.GetMainForm<MainForm>().ShowProgressBar();241 foreach (Control ctrl in Controls)242 ctrl.Enabled = false;243 }244 245 private void UpdateControlsDisconnectedState() {246 refreshButton.Enabled = false;247 248 localAndServerPlugins.Clear();249 listView.Items.Clear();250 listView.Enabled = false;251 uploadButton.Enabled = false;252 MainFormManager.GetMainForm<MainForm>().HideProgressBar();253 }254 255 private void UpdateControlsConnectedState() {256 refreshButton.Enabled = true;257 listView.Enabled = true;258 uploadButton.Enabled = false;259 MainFormManager.GetMainForm<MainForm>().HideProgressBar();260 }261 #endregion262 120 } 263 121 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/ProductEditor.Designer.cs
r3015 r3045 29 29 this.newProductButton = new System.Windows.Forms.Button(); 30 30 this.splitContainer = new System.Windows.Forms.SplitContainer(); 31 this.productsListView = new System.Windows.Forms.ListView(); 32 this.productNameHeader = new System.Windows.Forms.ColumnHeader(); 33 this.productVersionHeader = new System.Windows.Forms.ColumnHeader(); 34 this.productImageList = new System.Windows.Forms.ImageList(this.components); 35 this.pluginImageList = new System.Windows.Forms.ImageList(this.components); 31 36 this.pluginsLabel = new System.Windows.Forms.Label(); 32 37 this.versionTextBox = new System.Windows.Forms.TextBox(); … … 35 40 this.nameLabel = new System.Windows.Forms.Label(); 36 41 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 37 this.productsListView = new System.Windows.Forms.ListView(); 38 this.productNameHeader = new System.Windows.Forms.ColumnHeader(); 39 this.productVersionHeader = new System.Windows.Forms.ColumnHeader(); 40 this.productImageList = new System.Windows.Forms.ImageList(this.components); 41 this.pluginImageList = new System.Windows.Forms.ImageList(this.components); 42 this.pluginsListView = new System.Windows.Forms.ListView(); 43 this.pluginNameHeader = new System.Windows.Forms.ColumnHeader(); 44 this.pluginVersionHeader = new System.Windows.Forms.ColumnHeader(); 42 this.pluginListView = new HeuristicLab.DeploymentService.AdminClient.PluginListView(); 45 43 this.splitContainer.Panel1.SuspendLayout(); 46 44 this.splitContainer.Panel2.SuspendLayout(); … … 61 59 // saveButton 62 60 // 63 this.saveButton.Location = new System.Drawing.Point(84, 3); 61 this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 62 this.saveButton.Location = new System.Drawing.Point(3, 365); 64 63 this.saveButton.Name = "saveButton"; 65 64 this.saveButton.Size = new System.Drawing.Size(96, 23); … … 71 70 // newProductButton 72 71 // 73 this.newProductButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 74 this.newProductButton.Location = new System.Drawing.Point(3, 365); 72 this.newProductButton.Location = new System.Drawing.Point(84, 3); 75 73 this.newProductButton.Name = "newProductButton"; 76 74 this.newProductButton.Size = new System.Drawing.Size(91, 23); … … 91 89 // 92 90 this.splitContainer.Panel1.Controls.Add(this.productsListView); 93 this.splitContainer.Panel1.Controls.Add(this. newProductButton);91 this.splitContainer.Panel1.Controls.Add(this.saveButton); 94 92 // 95 93 // splitContainer.Panel2 96 94 // 97 this.splitContainer.Panel2.Controls.Add(this.plugin sListView);95 this.splitContainer.Panel2.Controls.Add(this.pluginListView); 98 96 this.splitContainer.Panel2.Controls.Add(this.pluginsLabel); 99 97 this.splitContainer.Panel2.Controls.Add(this.versionTextBox); … … 104 102 this.splitContainer.SplitterDistance = 319; 105 103 this.splitContainer.TabIndex = 4; 106 //107 // pluginsLabel108 //109 this.pluginsLabel.AutoSize = true;110 this.pluginsLabel.Location = new System.Drawing.Point(11, 69);111 this.pluginsLabel.Name = "pluginsLabel";112 this.pluginsLabel.Size = new System.Drawing.Size(44, 13);113 this.pluginsLabel.TabIndex = 6;114 this.pluginsLabel.Text = "Plugins:";115 //116 // versionTextBox117 //118 this.versionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)119 | System.Windows.Forms.AnchorStyles.Right)));120 this.versionTextBox.Location = new System.Drawing.Point(68, 29);121 this.versionTextBox.Name = "versionTextBox";122 this.versionTextBox.Size = new System.Drawing.Size(233, 20);123 this.versionTextBox.TabIndex = 5;124 this.versionTextBox.TextChanged += new System.EventHandler(this.versionTextBox_TextChanged);125 //126 // versionLabel127 //128 this.versionLabel.AutoSize = true;129 this.versionLabel.Location = new System.Drawing.Point(10, 32);130 this.versionLabel.Name = "versionLabel";131 this.versionLabel.Size = new System.Drawing.Size(45, 13);132 this.versionLabel.TabIndex = 4;133 this.versionLabel.Text = "Version:";134 //135 // nameTextBox136 //137 this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)138 | System.Windows.Forms.AnchorStyles.Right)));139 this.nameTextBox.Location = new System.Drawing.Point(68, 3);140 this.nameTextBox.Name = "nameTextBox";141 this.nameTextBox.Size = new System.Drawing.Size(233, 20);142 this.nameTextBox.TabIndex = 3;143 this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged);144 //145 // nameLabel146 //147 this.nameLabel.AutoSize = true;148 this.nameLabel.Location = new System.Drawing.Point(17, 6);149 this.nameLabel.Name = "nameLabel";150 this.nameLabel.Size = new System.Drawing.Size(38, 13);151 this.nameLabel.TabIndex = 2;152 this.nameLabel.Text = "Name:";153 //154 // errorProvider155 //156 this.errorProvider.ContainerControl = this;157 104 // 158 105 // productsListView … … 197 144 this.pluginImageList.TransparentColor = System.Drawing.Color.Transparent; 198 145 // 199 // pluginsListView 200 // 201 this.pluginsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 146 // pluginsLabel 147 // 148 this.pluginsLabel.AutoSize = true; 149 this.pluginsLabel.Location = new System.Drawing.Point(11, 69); 150 this.pluginsLabel.Name = "pluginsLabel"; 151 this.pluginsLabel.Size = new System.Drawing.Size(44, 13); 152 this.pluginsLabel.TabIndex = 6; 153 this.pluginsLabel.Text = "Plugins:"; 154 // 155 // versionTextBox 156 // 157 this.versionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 158 | System.Windows.Forms.AnchorStyles.Right))); 159 this.versionTextBox.Location = new System.Drawing.Point(68, 29); 160 this.versionTextBox.Name = "versionTextBox"; 161 this.versionTextBox.Size = new System.Drawing.Size(233, 20); 162 this.versionTextBox.TabIndex = 5; 163 this.versionTextBox.TextChanged += new System.EventHandler(this.versionTextBox_TextChanged); 164 // 165 // versionLabel 166 // 167 this.versionLabel.AutoSize = true; 168 this.versionLabel.Location = new System.Drawing.Point(10, 32); 169 this.versionLabel.Name = "versionLabel"; 170 this.versionLabel.Size = new System.Drawing.Size(45, 13); 171 this.versionLabel.TabIndex = 4; 172 this.versionLabel.Text = "Version:"; 173 // 174 // nameTextBox 175 // 176 this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 177 | System.Windows.Forms.AnchorStyles.Right))); 178 this.nameTextBox.Location = new System.Drawing.Point(68, 3); 179 this.nameTextBox.Name = "nameTextBox"; 180 this.nameTextBox.Size = new System.Drawing.Size(233, 20); 181 this.nameTextBox.TabIndex = 3; 182 this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged); 183 // 184 // nameLabel 185 // 186 this.nameLabel.AutoSize = true; 187 this.nameLabel.Location = new System.Drawing.Point(17, 6); 188 this.nameLabel.Name = "nameLabel"; 189 this.nameLabel.Size = new System.Drawing.Size(38, 13); 190 this.nameLabel.TabIndex = 2; 191 this.nameLabel.Text = "Name:"; 192 // 193 // errorProvider 194 // 195 this.errorProvider.ContainerControl = this; 196 // 197 // pluginListView 198 // 199 this.pluginListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 202 200 | System.Windows.Forms.AnchorStyles.Left) 203 201 | System.Windows.Forms.AnchorStyles.Right))); 204 this.pluginsListView.CheckBoxes = true; 205 this.pluginsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 206 this.pluginNameHeader, 207 this.pluginVersionHeader}); 208 this.pluginsListView.Location = new System.Drawing.Point(3, 85); 209 this.pluginsListView.Name = "pluginsListView"; 210 this.pluginsListView.Size = new System.Drawing.Size(333, 303); 211 this.pluginsListView.SmallImageList = this.pluginImageList; 212 this.pluginsListView.TabIndex = 7; 213 this.pluginsListView.UseCompatibleStateImageBehavior = false; 214 this.pluginsListView.View = System.Windows.Forms.View.Details; 215 this.pluginsListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.pluginsListView_ItemChecked); 216 // 217 // pluginNameHeader 218 // 219 this.pluginNameHeader.Text = "Name"; 220 this.pluginNameHeader.Width = 220; 221 // 222 // pluginVersionHeader 223 // 224 this.pluginVersionHeader.Text = "Version"; 225 this.pluginVersionHeader.Width = 120; 202 this.pluginListView.Location = new System.Drawing.Point(3, 85); 203 this.pluginListView.Name = "pluginListView"; 204 this.pluginListView.Plugins = null; 205 this.pluginListView.Size = new System.Drawing.Size(330, 303); 206 this.pluginListView.TabIndex = 7; 207 this.pluginListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.pluginListView_ItemChecked); 226 208 // 227 209 // ProductEditor … … 230 212 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 231 213 this.Controls.Add(this.splitContainer); 232 this.Controls.Add(this. saveButton);214 this.Controls.Add(this.newProductButton); 233 215 this.Controls.Add(this.refreshButton); 234 216 this.Name = "ProductEditor"; … … 260 242 private System.Windows.Forms.ImageList productImageList; 261 243 private System.Windows.Forms.ImageList pluginImageList; 262 private System.Windows.Forms.ListView pluginsListView; 263 private System.Windows.Forms.ColumnHeader pluginNameHeader; 264 private System.Windows.Forms.ColumnHeader pluginVersionHeader; 244 private PluginListView pluginListView; 265 245 266 246 } -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/ProductEditor.cs
r3015 r3045 100 100 versionTextBox.Text = activeProduct.Version.ToString(); 101 101 102 pluginsListView.Items.Clear(); 103 foreach (PluginDeploymentService.PluginDescription pluginDesc in plugins) { 104 var matching = from p in activeProduct.Plugins 105 where p.Name == pluginDesc.Name 106 where p.Version == pluginDesc.Version 107 select p; 108 109 if (matching.Any()) pluginsListView.Items.Add(CreateCheckedListViewItem(pluginDesc)); 110 else pluginsListView.Items.Add(CreateUncheckedListViewItem(pluginDesc)); 111 } 112 } 113 114 private ListViewItem CreateUncheckedListViewItem(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.PluginDescription pluginDesc) { 115 ListViewItem item = new ListViewItem(new string[] { pluginDesc.Name, pluginDesc.Version.ToString() }); 116 item.Checked = false; 117 item.Tag = pluginDesc; 118 item.ImageIndex = 0; 119 return item; 120 } 121 122 private ListViewItem CreateCheckedListViewItem(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.PluginDescription pluginDesc) { 123 ListViewItem item = new ListViewItem(new string[] { pluginDesc.Name, pluginDesc.Version.ToString() }); 124 item.Checked = true; 125 item.Tag = pluginDesc; 126 item.ImageIndex = 0; 127 return item; 102 UpdatePluginsListView(); 128 103 } 129 104 … … 135 110 } 136 111 137 private void refreshButton_Click(object sender, EventArgs e) {138 SetControlsEnabled(false);139 Cursor = Cursors.AppStarting;140 refreshProductsWorker.RunWorkerAsync();141 }142 143 112 private void SetControlsEnabled(bool enabled) { 144 113 saveButton.Enabled = enabled; 145 114 refreshButton.Enabled = enabled; 115 newProductButton.Enabled = enabled; 146 116 splitContainer.Enabled = enabled; 147 117 } 148 118 119 #region button event handlers 149 120 private void newProductButton_Click(object sender, EventArgs e) { 150 121 var newProduct = new PluginDeploymentService.ProductDescription("New product", new Version("0.0.0.0")); … … 158 129 uploadChangedProductsWorker.RunWorkerAsync(dirtyProducts); 159 130 } 160 131 private void refreshButton_Click(object sender, EventArgs e) { 132 SetControlsEnabled(false); 133 Cursor = Cursors.AppStarting; 134 refreshProductsWorker.RunWorkerAsync(); 135 } 136 137 #endregion 138 139 #region textbox changed event handlers 161 140 private void nameTextBox_TextChanged(object sender, EventArgs e) { 162 141 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; … … 198 177 } 199 178 } 200 201 private void pluginsListView_ItemChecked(object sender, ItemCheckedEventArgs e) { 202 var pluginItem = e.Item; 203 var activePlugin = (IPluginDescription)pluginItem.Tag; 204 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 205 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag; 206 if (pluginItem.Checked && !activeProduct.Plugins.Contains(activePlugin)) { 207 activeProduct.AddPlugin(activePlugin); 208 MarkProductDirty(activeProduct); 209 } else if (!pluginItem.Checked && activeProduct.Plugins.Contains(activePlugin)) { 210 activeProduct.RemovePlugin(activePlugin); 211 MarkProductDirty(activeProduct); 212 } 213 } 179 #endregion 180 181 182 #region plugin list view 183 private void UpdatePluginsListView() { 184 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 185 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag; 186 pluginListView.Plugins = plugins.OfType<IPluginDescription>(); 187 foreach (var plugin in activeProduct.Plugins) pluginListView.CheckPlugin(plugin); 188 } 189 190 private void pluginListView_ItemChecked(object sender, ItemCheckedEventArgs e) { 191 ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0]; 192 PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag; 193 activeProduct.Plugins = pluginListView.CheckedPlugins.Cast<PluginDeploymentService.PluginDescription>().ToArray(); 194 MarkProductDirty(activeProduct); 195 } 196 #endregion 214 197 215 198 private void MarkProductDirty(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.ProductDescription activeProduct) { … … 220 203 } 221 204 } 222 223 205 private ListViewItem FindItemForProduct(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.ProductDescription activeProduct) { 224 206 return (from item in productsListView.Items.OfType<ListViewItem>()
Note: See TracChangeset
for help on using the changeset viewer.