Changeset 1414 for branches/New Persistence Exploration/Persistence
- Timestamp:
- 03/25/09 14:06:31 (15 years ago)
- Location:
- branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.Designer.cs
r1400 r1414 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 System.Windows.Forms.TabPage nullFormatterConfig;27 System.Windows.Forms.DataGridView dataGridView1;28 System.Windows.Forms.DataGridViewTextBoxColumn Column1;29 System.Windows.Forms.DataGridViewCheckBoxColumn Column2;30 System.Windows.Forms.DataGridViewComboBoxColumn Column3;31 System.Windows.Forms.ListViewItem listViewItem16 = new System.Windows.Forms.ListViewItem("Bli");32 System.Windows.Forms.ListViewItem listViewItem17 = new System.Windows.Forms.ListViewItem("Bla");33 System.Windows.Forms.ListViewItem listViewItem18 = new System.Windows.Forms.ListViewItem("Blo");34 System.Windows.Forms.SplitContainer splitContainer1;35 System.Windows.Forms.SplitContainer splitContainer2;36 26 System.Windows.Forms.Button updateButton; 37 System.Windows.Forms.Label label1; 38 this.decomposerList = new System.Windows.Forms.ListView(); 39 this.DecomposersColumn = new System.Windows.Forms.ColumnHeader(); 40 this.checkBox = new System.Windows.Forms.ListBox(); 41 this.formatterTabs = new System.Windows.Forms.TabControl(); 42 nullFormatterConfig = new System.Windows.Forms.TabPage(); 43 dataGridView1 = new System.Windows.Forms.DataGridView(); 44 Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 45 Column2 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 46 Column3 = new System.Windows.Forms.DataGridViewComboBoxColumn(); 47 splitContainer1 = new System.Windows.Forms.SplitContainer(); 48 splitContainer2 = new System.Windows.Forms.SplitContainer(); 27 this.configurationTabs = new System.Windows.Forms.TabControl(); 49 28 updateButton = new System.Windows.Forms.Button(); 50 label1 = new System.Windows.Forms.Label();51 nullFormatterConfig.SuspendLayout();52 ((System.ComponentModel.ISupportInitialize)(dataGridView1)).BeginInit();53 splitContainer1.Panel1.SuspendLayout();54 splitContainer1.Panel2.SuspendLayout();55 splitContainer1.SuspendLayout();56 splitContainer2.Panel1.SuspendLayout();57 splitContainer2.Panel2.SuspendLayout();58 splitContainer2.SuspendLayout();59 this.formatterTabs.SuspendLayout();60 29 this.SuspendLayout(); 61 //62 // nullFormatterConfig63 //64 nullFormatterConfig.Controls.Add(dataGridView1);65 nullFormatterConfig.Location = new System.Drawing.Point(4, 22);66 nullFormatterConfig.Name = "nullFormatterConfig";67 nullFormatterConfig.Size = new System.Drawing.Size(386, 554);68 nullFormatterConfig.TabIndex = 0;69 nullFormatterConfig.Text = "EmptyFormatterConfig";70 nullFormatterConfig.UseVisualStyleBackColor = true;71 //72 // dataGridView173 //74 dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;75 dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {76 Column1,77 Column2,78 Column3});79 dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;80 dataGridView1.Location = new System.Drawing.Point(0, 0);81 dataGridView1.Name = "dataGridView1";82 dataGridView1.Size = new System.Drawing.Size(386, 554);83 dataGridView1.TabIndex = 0;84 //85 // Column186 //87 Column1.HeaderText = "Column1";88 Column1.Name = "Column1";89 //90 // Column291 //92 Column2.HeaderText = "Column2";93 Column2.Name = "Column2";94 //95 // Column396 //97 Column3.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox;98 Column3.HeaderText = "Column3";99 Column3.Name = "Column3";100 //101 // decomposerList102 //103 this.decomposerList.Activation = System.Windows.Forms.ItemActivation.OneClick;104 this.decomposerList.AllowDrop = true;105 this.decomposerList.CheckBoxes = true;106 this.decomposerList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {107 this.DecomposersColumn});108 this.decomposerList.Dock = System.Windows.Forms.DockStyle.Fill;109 this.decomposerList.FullRowSelect = true;110 this.decomposerList.GridLines = true;111 this.decomposerList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;112 listViewItem16.Checked = true;113 listViewItem16.StateImageIndex = 1;114 listViewItem16.Tag = "";115 listViewItem17.Checked = true;116 listViewItem17.StateImageIndex = 1;117 listViewItem18.Checked = true;118 listViewItem18.StateImageIndex = 1;119 this.decomposerList.Items.AddRange(new System.Windows.Forms.ListViewItem[] {120 listViewItem16,121 listViewItem17,122 listViewItem18});123 this.decomposerList.Location = new System.Drawing.Point(0, 0);124 this.decomposerList.Name = "decomposerList";125 this.decomposerList.ShowGroups = false;126 this.decomposerList.Size = new System.Drawing.Size(199, 290);127 this.decomposerList.TabIndex = 0;128 this.decomposerList.UseCompatibleStateImageBehavior = false;129 this.decomposerList.View = System.Windows.Forms.View.Details;130 this.decomposerList.Resize += new System.EventHandler(this.decomposerList_Resize);131 this.decomposerList.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.decomposerList_ItemChecked);132 this.decomposerList.DragDrop += new System.Windows.Forms.DragEventHandler(this.decomposerList_DragDrop);133 this.decomposerList.DragEnter += new System.Windows.Forms.DragEventHandler(this.decomposerList_DragEnter);134 this.decomposerList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.decomposerList_ItemDrag);135 //136 // DecomposersColumn137 //138 this.DecomposersColumn.Text = "Decomposers";139 this.DecomposersColumn.Width = 190;140 //141 // splitContainer1142 //143 splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;144 splitContainer1.Location = new System.Drawing.Point(0, 0);145 splitContainer1.Name = "splitContainer1";146 //147 // splitContainer1.Panel1148 //149 splitContainer1.Panel1.Controls.Add(splitContainer2);150 //151 // splitContainer1.Panel2152 //153 splitContainer1.Panel2.Controls.Add(updateButton);154 splitContainer1.Panel2.Controls.Add(this.formatterTabs);155 splitContainer1.Size = new System.Drawing.Size(597, 580);156 splitContainer1.SplitterDistance = 199;157 splitContainer1.TabIndex = 2;158 //159 // splitContainer2160 //161 splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;162 splitContainer2.Location = new System.Drawing.Point(0, 0);163 splitContainer2.Name = "splitContainer2";164 splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;165 //166 // splitContainer2.Panel1167 //168 splitContainer2.Panel1.Controls.Add(this.decomposerList);169 //170 // splitContainer2.Panel2171 //172 splitContainer2.Panel2.Controls.Add(label1);173 splitContainer2.Panel2.Controls.Add(this.checkBox);174 splitContainer2.Size = new System.Drawing.Size(199, 580);175 splitContainer2.SplitterDistance = 290;176 splitContainer2.TabIndex = 1;177 //178 // checkBox179 //180 this.checkBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)181 | System.Windows.Forms.AnchorStyles.Left)182 | System.Windows.Forms.AnchorStyles.Right)));183 this.checkBox.Enabled = false;184 this.checkBox.FormattingEnabled = true;185 this.checkBox.Location = new System.Drawing.Point(0, 18);186 this.checkBox.Name = "checkBox";187 this.checkBox.Size = new System.Drawing.Size(199, 264);188 this.checkBox.TabIndex = 0;189 //190 // formatterTabs191 //192 this.formatterTabs.Controls.Add(nullFormatterConfig);193 this.formatterTabs.Dock = System.Windows.Forms.DockStyle.Fill;194 this.formatterTabs.Location = new System.Drawing.Point(0, 0);195 this.formatterTabs.Name = "formatterTabs";196 this.formatterTabs.SelectedIndex = 0;197 this.formatterTabs.Size = new System.Drawing.Size(394, 580);198 this.formatterTabs.TabIndex = 0;199 30 // 200 31 // updateButton 201 32 // 202 33 updateButton.Dock = System.Windows.Forms.DockStyle.Bottom; 203 updateButton.Location = new System.Drawing.Point(0, 55 7);34 updateButton.Location = new System.Drawing.Point(0, 555); 204 35 updateButton.Name = "updateButton"; 205 updateButton.Size = new System.Drawing.Size( 394, 23);36 updateButton.Size = new System.Drawing.Size(597, 25); 206 37 updateButton.TabIndex = 1; 207 38 updateButton.Text = "Define Configuration"; … … 209 40 updateButton.Click += new System.EventHandler(this.updateButton_Click); 210 41 // 211 // label142 // configurationTabs 212 43 // 213 label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 214 | System.Windows.Forms.AnchorStyles.Right))); 215 label1.Location = new System.Drawing.Point(3, 0); 216 label1.Name = "label1"; 217 label1.Size = new System.Drawing.Size(193, 13); 218 label1.TabIndex = 1; 219 label1.Text = "Configuration Preview"; 220 label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; 44 this.configurationTabs.Dock = System.Windows.Forms.DockStyle.Fill; 45 this.configurationTabs.Location = new System.Drawing.Point(0, 0); 46 this.configurationTabs.Name = "configurationTabs"; 47 this.configurationTabs.SelectedIndex = 0; 48 this.configurationTabs.Size = new System.Drawing.Size(597, 580); 49 this.configurationTabs.TabIndex = 0; 221 50 // 222 51 // PersistenceConfigurationForm … … 225 54 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 226 55 this.ClientSize = new System.Drawing.Size(597, 580); 227 this.Controls.Add(splitContainer1); 56 this.Controls.Add(updateButton); 57 this.Controls.Add(this.configurationTabs); 228 58 this.Name = "PersistenceConfigurationForm"; 229 this.Text = "PersistenceConfigurationForm"; 230 nullFormatterConfig.ResumeLayout(false); 231 ((System.ComponentModel.ISupportInitialize)(dataGridView1)).EndInit(); 232 splitContainer1.Panel1.ResumeLayout(false); 233 splitContainer1.Panel2.ResumeLayout(false); 234 splitContainer1.ResumeLayout(false); 235 splitContainer2.Panel1.ResumeLayout(false); 236 splitContainer2.Panel2.ResumeLayout(false); 237 splitContainer2.ResumeLayout(false); 238 this.formatterTabs.ResumeLayout(false); 59 this.Text = "PersistenceConfigurationForm"; 239 60 this.ResumeLayout(false); 240 61 … … 243 64 #endregion 244 65 245 private System.Windows.Forms.ListView decomposerList; 246 private System.Windows.Forms.ColumnHeader DecomposersColumn; 247 private System.Windows.Forms.TabControl formatterTabs; 248 private System.Windows.Forms.ListBox checkBox; 66 private System.Windows.Forms.TabControl configurationTabs; 249 67 } 250 68 } -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.cs
r1405 r1414 19 19 private readonly Dictionary<Type, string> reverseTypeNameTable; 20 20 21 public PersistenceConfigurationForm() { 21 public PersistenceConfigurationForm() { 22 22 InitializeComponent(); 23 23 formatterTable = new Dictionary<string, IFormatter>(); 24 24 reverseFormatterTable = new Dictionary<IFormatter, string>(); 25 25 typeNameTable = new Dictionary<string, Type>(); 26 reverseTypeNameTable = new Dictionary<Type, string>(); 27 initializeDecomposerList(); 28 initializeFormatterPages(); 29 //ConfigurationService.Instance.DefineConfiguration( 30 // XmlFormat.Instance, 31 // new Configuration( 32 // new Dictionary<Type, IFormatter> {{typeof (bool), new FakeBoolean2XmlFormatter()}}, 33 // new List<IDecomposer>{new ArrayDecomposer(), new DictionaryDecomposer()})); 34 initializeFromConfigurationService(); 35 } 36 37 private void initializeFromConfigurationService() { 38 foreach ( IFormat format in ConfigurationService.Instance.Formatters.Keys ) { 39 Configuration config = ConfigurationService.Instance.GetConfiguration(format); 40 foreach (ListViewItem item in decomposerList.Items) { 41 if (item != null) { 42 string name = item.Tag.GetType().AssemblyQualifiedName; 43 item.Checked = 44 config.Decomposers.Count( 45 d => d.GetType().AssemblyQualifiedName == name) > 0; 46 26 reverseTypeNameTable = new Dictionary<Type, string>(); 27 initializeConfigPages(); 28 UpdateFromConfigurationService(); 29 } 30 31 private void UpdateFormatterGrid(DataGridView formatterGrid, Configuration config) { 32 foreach (DataGridViewRow row in formatterGrid.Rows) { 33 if (row.Cells["Type"] != null) { 34 IFormatter formatter = config.GetFormatter(typeNameTable[(string)row.Cells["Type"].Value]); 35 if (formatter == null) { 36 row.Cells["Active"].Value = false; 37 } else { 38 foreach (var pair in formatterTable) { 39 if (pair.Value.GetType().FullName == formatter.GetType().FullName) { 40 row.Cells["Formatter"].Value = pair.Key; 41 row.Cells["Active"].Value = true; 42 break; 43 } 44 } 47 45 } 48 46 } 49 foreach ( TabPage page in formatterTabs.TabPages ) { 50 if (page.Tag == format) { 51 DataGridView gridView = (DataGridView)page.Controls.Find("GridView", false)[0]; 52 foreach ( DataGridViewRow row in gridView.Rows ) { 53 if (row.Cells["Type"] != null) { 54 IFormatter formatter = config.GetFormatter(typeNameTable[(string) row.Cells["Type"].Value]); 55 if (formatter == null) { 56 row.Cells["Active"].Value = false; 57 } else { 58 foreach (var pair in formatterTable) { 59 if ( pair.Value.GetType().AssemblyQualifiedName == formatter.GetType().AssemblyQualifiedName ) { 60 row.Cells["Formatter"].Value = pair.Key; 61 row.Cells["Active"].Value = true; 62 break; 63 } 64 } 65 } 66 } 67 } 68 } 69 } 70 } 71 } 72 73 private void initializeFormatterPages() { 74 formatterTabs.TabPages.Clear(); 75 foreach ( var formats in ConfigurationService.Instance.Formatters ) { 76 TabPage page = new TabPage(formats.Key.Name) {Tag = formats.Key}; 77 formatterTabs.TabPages.Add(page); 78 DataGridView gridView = new DataGridView { 79 Name = "GridView", 47 } 48 } 49 50 private void UpdateDecomposerList(ListView decomposerList, Configuration config) { 51 decomposerList.Items.Clear(); 52 var availableDecomposers = new Dictionary<string, IDecomposer>(); 53 foreach (IDecomposer d in ConfigurationService.Instance.Decomposers) { 54 availableDecomposers.Add(d.GetType().FullName, d); 55 } 56 foreach (IDecomposer decomposer in config.Decomposers) { 57 var item = decomposerList.Items.Add(decomposer.GetType().Name); 58 item.Checked = true; 59 item.Tag = decomposer; 60 availableDecomposers.Remove(decomposer.GetType().FullName); 61 } 62 foreach (KeyValuePair<string, IDecomposer> pair in availableDecomposers) { 63 var item = decomposerList.Items.Add(pair.Value.GetType().Name); 64 item.Checked = false; 65 item.Tag = pair.Value; 66 } 67 } 68 69 private void UpdateFromConfigurationService() { 70 foreach (IFormat format in ConfigurationService.Instance.Formatters.Keys) { 71 Configuration config = ConfigurationService.Instance.GetConfiguration(format); 72 UpdateFormatterGrid( 73 (DataGridView)GetControlsOnPage(format.Name, "GridView"), 74 config); 75 UpdateDecomposerList( 76 (ListView)GetControlsOnPage(format.Name, "DecomposerList"), 77 config); 78 } 79 } 80 81 private void initializeConfigPages() { 82 configurationTabs.TabPages.Clear(); 83 foreach ( var formats in ConfigurationService.Instance.Formatters ) { 84 TabPage page = new TabPage(formats.Key.Name) { 85 Name = formats.Key.Name, 86 Tag = formats.Key, 87 }; 88 configurationTabs.TabPages.Add(page); 89 SplitContainer verticalSplit = new SplitContainer { 80 90 Dock = DockStyle.Fill, 81 EditMode = DataGridViewEditMode.EditOnEnter, 82 AllowUserToAddRows = false, 83 AllowUserToDeleteRows = false, 84 AllowUserToResizeRows = false, 85 AllowUserToOrderColumns = true, 91 Orientation = Orientation.Vertical, 92 BorderStyle = BorderStyle.Fixed3D, 86 93 }; 87 gridView.CellValueChanged += gridView_CellValueChanged; 88 gridView.Columns.Add(new DataGridViewTextBoxColumn { 89 Name = "Type", ReadOnly = true, 90 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill 91 }); 92 gridView.Columns.Add(new DataGridViewCheckBoxColumn { 93 Name = "Active", 94 AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells}); 95 gridView.Columns.Add(new DataGridViewComboBoxColumn { 96 Name = "Formatter", 97 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill}); 98 page.Controls.Add(gridView); 94 page.Controls.Add(verticalSplit); 95 SplitContainer horizontalSplit = new SplitContainer { 96 Dock = DockStyle.Fill, 97 Orientation = Orientation.Horizontal, 98 BorderStyle = BorderStyle.Fixed3D, 99 }; 100 verticalSplit.Panel1.Controls.Add(horizontalSplit); 101 ListView decomposerList = createDecomposerList(); 102 horizontalSplit.Panel1.Controls.Add(decomposerList); 103 DataGridView gridView = createGridView(); 104 verticalSplit.Panel2.Controls.Add(gridView); 99 105 fillDataGrid(gridView, formats.Value); 100 } 106 ListBox checkBox = new ListBox { 107 Name = "CheckBox", 108 Dock = DockStyle.Fill, 109 Enabled = false, 110 }; 111 horizontalSplit.Panel2.Controls.Add(checkBox); 112 } 113 } 114 115 private DataGridView createGridView() { 116 DataGridView gridView = new DataGridView { 117 Name = "GridView", 118 Dock = DockStyle.Fill, 119 RowHeadersVisible = false, 120 MultiSelect = false, 121 EditMode = DataGridViewEditMode.EditOnEnter, 122 AllowUserToAddRows = false, 123 AllowUserToDeleteRows = false, 124 AllowUserToResizeRows = false, 125 AllowUserToOrderColumns = true, 126 }; 127 gridView.CellValueChanged += gridView_CellValueChanged; 128 gridView.Columns.Add(new DataGridViewTextBoxColumn { 129 Name = "Type", ReadOnly = true, 130 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill 131 }); 132 gridView.Columns.Add(new DataGridViewCheckBoxColumn { 133 Name = "Active", 134 AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells 135 }); 136 gridView.Columns.Add(new DataGridViewComboBoxColumn { 137 Name = "Formatter", 138 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill 139 }); 140 return gridView; 141 } 142 143 private ListView createDecomposerList() { 144 ListView decomposerList = new ListView { 145 Activation = ItemActivation.OneClick, 146 AllowDrop = true, 147 CheckBoxes = true, 148 Dock = DockStyle.Fill, 149 FullRowSelect = true, 150 GridLines = true, 151 HeaderStyle = ColumnHeaderStyle.Nonclickable, 152 Name = "DecomposerList", 153 ShowGroups = false, 154 View = View.Details 155 }; 156 decomposerList.Resize += decomposerList_Resize; 157 decomposerList.ItemChecked += decomposerList_ItemChecked; 158 decomposerList.DragDrop += decomposerList_DragDrop; 159 decomposerList.DragEnter += decomposerList_DragEnter; 160 decomposerList.ItemDrag += decomposerList_ItemDrag; 161 decomposerList.Columns.Add( 162 new ColumnHeader { 163 Name = "DecomposerColumn", Text = "Decomposers", 164 }); 165 foreach (IDecomposer decomposer in ConfigurationService.Instance.Decomposers) { 166 var item = decomposerList.Items.Add(decomposer.GetType().Name); 167 item.Checked = true; 168 item.Tag = decomposer; 169 } 170 return decomposerList; 101 171 } 102 172 … … 107 177 var row = gridView.Rows[gridView.Rows.Add()]; 108 178 row.Cells["Type"].Value = formatterMapping.Key; 109 row.Cells[" Active"].ToolTipText = formatterMapping.Key;110 row.Cells[" Formatter"].Value = true;111 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[ 2];179 row.Cells["Type"].ToolTipText = formatterMapping.Key; 180 row.Cells["Active"].Value = true; 181 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells["Formatter"]; 112 182 foreach ( var formatter in formatterMapping.Value ) { 113 183 comboBoxCell.Items.Add(formatter); … … 167 237 } 168 238 } 169 } 170 171 private void initializeDecomposerList() { 172 decomposerList.Items.Clear(); 173 foreach ( IDecomposer decomposer in ConfigurationService.Instance.Decomposers ) { 174 var item = decomposerList.Items.Add(decomposer.GetType().Name); 175 item.Checked = true; 176 item.Tag = decomposer; 177 } 178 } 239 } 179 240 180 241 void gridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { … … 183 244 184 245 private void decomposerList_ItemDrag(object sender, ItemDragEventArgs e) { 246 ListView decomposerList = (ListView) sender; 185 247 decomposerList.DoDragDrop(decomposerList.SelectedItems, DragDropEffects.Move); 186 248 } … … 193 255 194 256 private void decomposerList_DragDrop(object sender, DragEventArgs e) { 257 ListView decomposerList = (ListView)sender; 195 258 if (decomposerList.SelectedItems.Count == 0) { 196 259 return; … … 218 281 219 282 private void decomposerList_Resize(object sender, EventArgs e) { 220 DecomposersColumn.Width = decomposerList.Width - 4; 221 } 222 223 private IEnumerable<IDecomposer> GetDecomposers() { 224 List<IDecomposer> decomposers = new List<IDecomposer>(); 225 foreach ( ListViewItem item in decomposerList.Items ) { 226 if (item != null && item.Checked) 227 decomposers.Add((IDecomposer) item.Tag); 228 } 229 return decomposers; 230 } 231 283 ListView decomposerList = (ListView)sender; 284 decomposerList.Columns["DecomposerColumn"].Width = decomposerList.Width - 4; 285 } 286 232 287 private void UpdatePreview() { 233 checkBox.Items.Clear(); 234 IFormat activeFormat = (IFormat)formatterTabs.SelectedTab.Tag; 235 if (activeFormat != null) { 236 foreach (var formatter in GetCurrentConfiguration(activeFormat).Formatters) { 288 ListBox checkBox = (ListBox)GetActiveControl("CheckBox"); 289 IFormat activeFormat = (IFormat)configurationTabs.SelectedTab.Tag; 290 if (activeFormat != null && checkBox != null ) { 291 checkBox.Items.Clear(); 292 Configuration activeConfig = GetActiveConfiguration(); 293 foreach (var formatter in activeConfig.Formatters) { 237 294 checkBox.Items.Add(formatter.GetType().Name + " (F)"); 238 295 } 239 }240 foreach (var decomposer in GetDecomposers())241 checkBox.Items.Add(decomposer.GetType().Name + " (D)");296 foreach (var decomposer in activeConfig.Decomposers) 297 checkBox.Items.Add(decomposer.GetType().Name + " (D)"); 298 } 242 299 } 243 300 … … 246 303 } 247 304 248 public Configuration GetCurrentConfiguration(IFormat format) { 249 Dictionary<Type, IFormatter> formatters = new Dictionary<Type, IFormatter>(); 250 foreach ( TabPage page in formatterTabs.TabPages ) { 251 if ( page.Text == format.Name ) { 252 Control[] controls = page.Controls.Find("GridView", false); 253 if (controls.Length == 1) { 254 foreach (DataGridViewRow row in ((DataGridView) controls[0]).Rows) { 255 if ( row.Cells["Type"].Value != null && 256 row.Cells["Active"].Value != null && 257 row.Cells["Formatter"].Value != null && 258 (bool)row.Cells["Active"].Value == true ) { 259 formatters.Add( 260 typeNameTable[(string)row.Cells["Type"].Value], 261 formatterTable[(string)row.Cells["Formatter"].Value]); 262 } 263 } 264 } 305 private Control GetActiveControl(string name) { 306 Control[] controls = configurationTabs.SelectedTab.Controls.Find(name, true); 307 if (controls.Length == 1) { 308 return controls[0]; 309 } else { 310 return null; 311 } 312 } 313 314 private Control GetControlsOnPage(string pageName, string name) { 315 Control[] controls = configurationTabs.TabPages[pageName].Controls.Find(name, true); 316 if (controls.Length == 1) { 317 return controls[0]; 318 } else { 319 return null; 320 } 321 } 322 323 private Configuration GenerateConfiguration(DataGridView formatterGrid, ListView decomposerList) { 324 if (formatterGrid == null || decomposerList == null) 325 return null; 326 var formatters = new Dictionary<Type, IFormatter>(); 327 foreach (DataGridViewRow row in formatterGrid.Rows) { 328 if (row.Cells["Type"].Value != null && 329 row.Cells["Active"].Value != null && 330 row.Cells["Formatter"].Value != null && 331 (bool)row.Cells["Active"].Value == true) { 332 formatters.Add( 333 typeNameTable[(string)row.Cells["Type"].Value], 334 formatterTable[(string)row.Cells["Formatter"].Value]); 265 335 } 266 336 } 267 return new Configuration(formatters, GetDecomposers()); 268 } 269 337 var decomposers = new List<IDecomposer>(); 338 foreach (ListViewItem item in decomposerList.Items) { 339 if (item != null && item.Checked) 340 decomposers.Add((IDecomposer)item.Tag); 341 } 342 return new Configuration(formatters, decomposers); 343 } 344 345 private Configuration GetActiveConfiguration() { 346 return GenerateConfiguration( 347 (DataGridView)GetActiveControl("GridView"), 348 (ListView)GetActiveControl("DecomposerList")); 349 } 350 351 private Configuration GetConfiguration(IFormat format) { 352 return GenerateConfiguration( 353 (DataGridView)GetControlsOnPage(format.Name, "GridView"), 354 (ListView)GetControlsOnPage(format.Name, "DecomposerList")); 355 } 356 270 357 private void updateButton_Click(object sender, EventArgs e) { 271 IFormat format = (IFormat) formatterTabs.SelectedTab.Tag;358 IFormat format = (IFormat)configurationTabs.SelectedTab.Tag; 272 359 if (format != null) 273 360 ConfigurationService.Instance.DefineConfiguration( 274 361 format, 275 Get CurrentConfiguration(format));276 } 362 GetActiveConfiguration()); 363 } 277 364 365 } 366 367 [EmptyStorableClass] 368 public class EmptyFormat : Format { 369 public override string Name { get { return "Empty"; } } 370 public static EmptyFormat Instance = new EmptyFormat(); 371 } 372 373 [EmptyStorableClass] 374 public class EmptyFormatter : IFormatter { 375 376 public Type Type { get { return typeof(Type); } } 377 public IFormat Format { get { return EmptyFormat.Instance; } } 378 379 public object DoFormat(object o) { 380 return null; 381 } 382 383 public object Parse(object o) { 384 return null; 385 } 278 386 } 279 387 -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.resx
r1400 r1414 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="nullFormatterConfig.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">121 <value>False</value>122 </metadata>123 <metadata name="dataGridView1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">124 <value>False</value>125 </metadata>126 <metadata name="Column1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">127 <value>False</value>128 </metadata>129 <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">130 <value>True</value>131 </metadata>132 <metadata name="Column2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">133 <value>False</value>134 </metadata>135 <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">136 <value>True</value>137 </metadata>138 <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">139 <value>True</value>140 </metadata>141 <metadata name="Column3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">142 <value>False</value>143 </metadata>144 <metadata name="splitContainer1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">145 <value>False</value>146 </metadata>147 <metadata name="splitContainer2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">148 <value>False</value>149 </metadata>150 <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">151 <value>False</value>152 </metadata>153 120 <metadata name="updateButton.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 154 121 <value>False</value>
Note: See TracChangeset
for help on using the changeset viewer.