Changeset 418 for trunk/sources
- Timestamp:
- 08/01/08 16:50:58 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Core
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs
r417 r418 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.CEDMA.DB.Interfaces; 7 using HeuristicLab.Operators; 7 8 8 9 namespace HeuristicLab.CEDMA.Core { … … 29 30 30 31 public void Save() { 31 Dictionary<IOperator, long> newKnownOperators = new Dictionary<IOperator, long>();32 Dictionary<IOperator, long> newKnownOperators = new Dictionary<IOperator, long>(); 32 33 foreach(IOperator op in group.Operators) { 33 34 if(knownOperators.ContainsKey(op)) { 34 35 // update 35 long id = knownOperators[op];36 long id = knownOperators[op]; 36 37 Database.UpdateOperator(id, op.Name, PersistenceManager.SaveToGZip(op)); 37 38 knownOperators.Remove(op); … … 47 48 Database.DeleteOperator(id); 48 49 } 49 50 50 51 knownOperators = newKnownOperators; 51 52 } … … 62 63 group.AddOperator(op); 63 64 } 65 66 // patch all OperatorLinks 67 foreach(IOperator op in group.Operators) { 68 PatchLinks(op); 69 } 70 } 71 72 private void PatchLinks(IOperator op) { 73 if(op is OperatorLink) { 74 OperatorLink link = op as OperatorLink; 75 link.Operator = FindOperator(link.Id); 76 } 77 else if(op is CombinedOperator) { 78 CombinedOperator combinedOp = op as CombinedOperator; 79 foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) { 80 PatchLinks(internalOp); 81 } 82 } 83 } 84 85 private IOperator FindOperator(long id) { 86 foreach(KeyValuePair<IOperator, long> p in knownOperators) if(p.Value == id) return p.Key; 87 return null; 64 88 } 65 89 … … 80 104 return new DatabaseOperatorLibraryView(this); 81 105 } 106 107 internal long GetId(IOperator op) { 108 return knownOperators[op]; 109 } 82 110 } 83 111 } -
trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibraryView.cs
r417 r418 56 56 57 57 int result = string.Compare(tx.Text, ty.Text); 58 if 58 if(result == 0) 59 59 result = tx.Index.CompareTo(ty.Index); 60 60 return result; … … 67 67 addOperatorButton.Enabled = false; 68 68 removeButton.Enabled = false; 69 if 69 if(OperatorLibrary == null) { 70 70 Caption = "Operator Library"; 71 71 operatorsGroupBox.Enabled = false; … … 98 98 } 99 99 private void RemoveTreeNode(TreeNode node) { 100 if 100 if(node.Tag is IOperatorGroup) { 101 101 IOperatorGroup group = node.Tag as IOperatorGroup; 102 102 IOperatorGroup parent = node.Parent.Tag as IOperatorGroup; 103 103 parent.RemoveSubGroup(group); 104 } else if 104 } else if(node.Tag is IOperator) { 105 105 IOperator op = node.Tag as IOperator; 106 106 IOperatorGroup group = node.Parent.Tag as IOperatorGroup; … … 116 116 operatorsTreeView.Focus(); 117 117 118 if 119 if 118 if(operatorsTreeView.SelectedNode != null) { 119 if(operatorsTreeView.SelectedNode.Parent != null) 120 120 removeButton.Enabled = true; 121 if 121 if(operatorsTreeView.SelectedNode.Tag is IOperatorGroup) { 122 122 addOperatorButton.Enabled = true; 123 123 } … … 133 133 134 134 string name = e.Label; 135 if 136 if 135 if(name != null) { 136 if(e.Node.Tag is IOperatorGroup) 137 137 ((IOperatorGroup)e.Node.Tag).Name = name; 138 else if 138 else if(e.Node.Tag is IOperator) 139 139 ((IOperator)e.Node.Tag).Name = name; 140 140 } 141 141 } 142 142 private void operatorsTreeView_DoubleClick(object sender, EventArgs e) { 143 if 143 if(operatorsTreeView.SelectedNode != null) { 144 144 IOperator op = operatorsTreeView.SelectedNode.Tag as IOperator; 145 if 145 if(op != null) { 146 146 IView view = op.CreateView(); 147 if 147 if(view != null) 148 148 PluginManager.ControlManager.ShowControl(view); 149 149 } … … 154 154 #region Button Events 155 155 private void addOperatorButton_Click(object sender, EventArgs e) { 156 if 157 if 156 if(chooseOperatorDialog == null) chooseOperatorDialog = new ChooseOperatorDialog(); 157 if(chooseOperatorDialog.ShowDialog(this) == DialogResult.OK) { 158 158 TreeNode node = operatorsTreeView.SelectedNode; 159 159 IOperatorGroup group = node.Tag as IOperatorGroup; … … 173 173 private void operatorsTreeView_KeyDown(object sender, KeyEventArgs e) { 174 174 TreeNode node = operatorsTreeView.SelectedNode; 175 if 175 if((e.KeyCode == Keys.Delete) && (node != null) && (node.Parent != null)) 176 176 RemoveTreeNode(operatorsTreeView.SelectedNode); 177 if 177 if((e.KeyCode == Keys.F2) && (node != null)) 178 178 node.BeginEdit(); 179 179 } … … 183 183 #region Mouse Events 184 184 private void operatorsTreeView_MouseDown(object sender, MouseEventArgs e) { 185 if 185 if(e.Button != MouseButtons.Right) return; 186 186 TreeNode clickedNode = operatorsTreeView.GetNodeAt(e.X, e.Y); 187 if 187 if(clickedNode != null) { 188 188 operatorsTreeView.SelectedNode = clickedNode; 189 189 operatorsTreeView.Refresh(); … … 196 196 TreeNode node = (TreeNode)e.Item; 197 197 IOperator op = node.Tag as IOperator; 198 if (op != null) { 198 if(op != null) { 199 long opId = ((DatabaseOperatorLibrary)OperatorLibrary).GetId(op); 200 OperatorLink link = new OperatorLink(opId, op); 199 201 DataObject data = new DataObject(); 200 data.SetData("IOperator", op);202 data.SetData("IOperator", link); 201 203 data.SetData("DragSource", operatorsTreeView); 202 204 DoDragDrop(data, DragDropEffects.Copy); … … 205 207 private void operatorsTreeView_DragEnter(object sender, DragEventArgs e) { 206 208 e.Effect = DragDropEffects.None; 207 if 209 if(e.Data.GetDataPresent("IOperator")) { 208 210 Point p = operatorsTreeView.PointToClient(new Point(e.X, e.Y)); 209 211 TreeNode node = operatorsTreeView.GetNodeAt(p); 210 if 212 if((node != null) && (node.Tag is IOperatorGroup)) 211 213 e.Effect = DragDropEffects.Copy; 212 214 } … … 214 216 private void operatorsTreeView_DragOver(object sender, DragEventArgs e) { 215 217 e.Effect = DragDropEffects.None; 216 if 218 if(e.Data.GetDataPresent("IOperator")) { 217 219 Point p = operatorsTreeView.PointToClient(new Point(e.X, e.Y)); 218 220 TreeNode node = operatorsTreeView.GetNodeAt(p); 219 if 221 if((node != null) && (node.Tag is IOperatorGroup)) 220 222 e.Effect = DragDropEffects.Copy; 221 223 } 222 224 } 223 225 private void operatorsTreeView_DragDrop(object sender, DragEventArgs e) { 224 if 225 if 226 if(e.Effect != DragDropEffects.None) { 227 if(e.Data.GetDataPresent("IOperator")) { 226 228 IOperator op = (IOperator)e.Data.GetData("IOperator"); 227 229 Point p = operatorsTreeView.PointToClient(new Point(e.X, e.Y)); 228 230 TreeNode node = operatorsTreeView.GetNodeAt(p); 229 if 231 if(node != null) { 230 232 op = (IOperator)op.Clone(); 231 233 232 while 234 while(op.SubOperators.Count > 0) 233 235 op.RemoveSubOperator(0); 234 236 -
trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r417 r418 69 69 <DependentUpon>DatabaseOperatorLibraryView.cs</DependentUpon> 70 70 </Compile> 71 <Compile Include="OperatorLink.cs" /> 71 72 <Compile Include="Result.cs" /> 72 73 <Compile Include="IResult.cs" /> … … 100 101 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 101 102 <Name>HeuristicLab.Core</Name> 103 </ProjectReference> 104 <ProjectReference Include="..\HeuristicLab.Operators\HeuristicLab.Operators.csproj"> 105 <Project>{A9983BA2-B3B2-475E-8E2C-62050B71D1C5}</Project> 106 <Name>HeuristicLab.Operators</Name> 102 107 </ProjectReference> 103 108 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> -
trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLabCedmaCorePlugin.cs
r403 r418 30 30 [Dependency(Dependency = "HeuristicLab.Core")] 31 31 [Dependency(Dependency = "HeuristicLab.CEDMA.DB.Interfaces")] 32 [Dependency(Dependency = "HeuristicLab.Operators")] 32 33 public class HeuristicLabCedmaCorePlugin : PluginBase { 33 34 }
Note: See TracChangeset
for help on using the changeset viewer.