Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11565


Ignore:
Timestamp:
11/24/14 03:12:49 (10 years ago)
Author:
swagner
Message:

#2205: Continued working on programmable network items

  • allowed code changes only in user-defined nodes and networks
  • added manual initialization of compiled programmable network items
Location:
branches/OptimizationNetworks
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.CodeEditor/3.3/CodeEditor.cs

    r10359 r11565  
    2626// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727
     28using HeuristicLab.Common.Resources;
     29using ICSharpCode.TextEditor;
     30using ICSharpCode.TextEditor.Document;
    2831using System;
    2932using System.CodeDom.Compiler;
     
    3538using System.Threading;
    3639using System.Windows.Forms;
    37 using HeuristicLab.Common.Resources;
    38 using ICSharpCode.TextEditor;
    39 using ICSharpCode.TextEditor.Document;
    4040using Dom = ICSharpCode.SharpDevelop.Dom;
    4141using NRefactory = ICSharpCode.NRefactory;
     
    131131        Doc.CommitUpdate();
    132132      }
     133    }
     134
     135    public bool ReadOnly {
     136      get { return Doc.ReadOnly; }
     137      set { Doc.ReadOnly = value; }
    133138    }
    134139
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNetworkView.Designer.cs

    r11564 r11565  
    4747      this.codeTabPage = new System.Windows.Forms.TabPage();
    4848      this.programmableItemView = new HeuristicLab.Core.Views.ProgrammableItemView();
     49      this.initializeButton = new System.Windows.Forms.Button();
    4950      this.tabControl.SuspendLayout();
    5051      this.nodesTabPage.SuspendLayout();
    5152      this.portsTabPage.SuspendLayout();
    5253      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     54      this.codeTabPage.SuspendLayout();
    5355      this.SuspendLayout();
    5456      //
     
    6769      // codeTabPage
    6870      //
     71      this.codeTabPage.Controls.Add(this.initializeButton);
    6972      this.codeTabPage.Controls.Add(this.programmableItemView);
    7073      this.codeTabPage.Location = new System.Drawing.Point(4, 22);
     
    8083      this.programmableItemView.Content = null;
    8184      this.programmableItemView.Dock = System.Windows.Forms.DockStyle.Fill;
    82       this.programmableItemView.Location = new System.Drawing.Point(3, 3);
     85      this.programmableItemView.Location = new System.Drawing.Point(0, 0);
    8386      this.programmableItemView.Name = "programmableItemView";
    8487      this.programmableItemView.ReadOnly = false;
    85       this.programmableItemView.Size = new System.Drawing.Size(631, 459);
     88      this.programmableItemView.Size = new System.Drawing.Size(637, 465);
    8689      this.programmableItemView.TabIndex = 0;
     90      //
     91      // initializeButton
     92      //
     93      this.initializeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
     94      this.initializeButton.Location = new System.Drawing.Point(33, 3);
     95      this.initializeButton.Name = "initializeButton";
     96      this.initializeButton.Size = new System.Drawing.Size(24, 24);
     97      this.initializeButton.TabIndex = 1;
     98      this.toolTip.SetToolTip(this.initializeButton, "Initialize");
     99      this.initializeButton.UseVisualStyleBackColor = true;
     100      this.initializeButton.Click += new System.EventHandler(this.initializeButton_Click);
    87101      //
    88102      // UserDefinedNetworkView
     
    93107      this.portsTabPage.ResumeLayout(false);
    94108      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     109      this.codeTabPage.ResumeLayout(false);
    95110      this.ResumeLayout(false);
    96111      this.PerformLayout();
     
    102117    protected System.Windows.Forms.TabPage codeTabPage;
    103118    protected HeuristicLab.Core.Views.ProgrammableItemView programmableItemView;
     119    protected System.Windows.Forms.Button initializeButton;
    104120  }
    105121}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNetworkView.cs

    r11564 r11565  
    4343      programmableItemView.Content = Content;
    4444    }
     45
     46    protected override void SetEnabledStateOfControls() {
     47      base.SetEnabledStateOfControls();
     48      initializeButton.Enabled = Content != null && !ReadOnly && !Locked;
     49    }
     50
     51    private void initializeButton_Click(object sender, System.EventArgs e) {
     52      Content.Initialize();
     53    }
    4554  }
    4655}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNodeView.Designer.cs

    r11564 r11565  
    4747      this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl();
    4848      this.portsTabPage = new System.Windows.Forms.TabPage();
     49      this.portCollectionView = new HeuristicLab.Core.Networks.Views.PortCollectionView();
    4950      this.codeTabPage = new System.Windows.Forms.TabPage();
    50       this.portCollectionView = new HeuristicLab.Core.Networks.Views.PortCollectionView();
    5151      this.programmableItemView = new HeuristicLab.Core.Views.ProgrammableItemView();
     52      this.initializeButton = new System.Windows.Forms.Button();
    5253      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5354      this.tabControl.SuspendLayout();
    5455      this.portsTabPage.SuspendLayout();
     56      this.codeTabPage.SuspendLayout();
    5557      this.SuspendLayout();
    5658      //
     
    8587      this.portsTabPage.UseVisualStyleBackColor = true;
    8688      //
    87       // codeTabPage
    88       //
    89       this.codeTabPage.Controls.Add(this.programmableItemView);
    90       this.codeTabPage.Location = new System.Drawing.Point(4, 22);
    91       this.codeTabPage.Name = "codeTabPage";
    92       this.codeTabPage.Padding = new System.Windows.Forms.Padding(3);
    93       this.codeTabPage.Size = new System.Drawing.Size(637, 465);
    94       this.codeTabPage.TabIndex = 1;
    95       this.codeTabPage.Text = "Code";
    96       this.codeTabPage.UseVisualStyleBackColor = true;
    97       //
    9889      // portCollectionView
    9990      //
     
    10899      this.portCollectionView.TabIndex = 0;
    109100      //
     101      // codeTabPage
     102      //
     103      this.codeTabPage.Controls.Add(this.initializeButton);
     104      this.codeTabPage.Controls.Add(this.programmableItemView);
     105      this.codeTabPage.Location = new System.Drawing.Point(4, 22);
     106      this.codeTabPage.Name = "codeTabPage";
     107      this.codeTabPage.Padding = new System.Windows.Forms.Padding(3);
     108      this.codeTabPage.Size = new System.Drawing.Size(637, 465);
     109      this.codeTabPage.TabIndex = 1;
     110      this.codeTabPage.Text = "Code";
     111      this.codeTabPage.UseVisualStyleBackColor = true;
     112      //
    110113      // programmableItemView
    111114      //
     
    118121      this.programmableItemView.Size = new System.Drawing.Size(631, 459);
    119122      this.programmableItemView.TabIndex = 0;
     123      //
     124      // initializeButton
     125      //
     126      this.initializeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
     127      this.initializeButton.Location = new System.Drawing.Point(36, 6);
     128      this.initializeButton.Name = "initializeButton";
     129      this.initializeButton.Size = new System.Drawing.Size(24, 24);
     130      this.initializeButton.TabIndex = 1;
     131      this.toolTip.SetToolTip(this.initializeButton, "Initialize");
     132      this.initializeButton.UseVisualStyleBackColor = true;
     133      this.initializeButton.Click += new System.EventHandler(this.initializeButton_Click);
    120134      //
    121135      // UserDefinedNodeView
     
    130144      this.tabControl.ResumeLayout(false);
    131145      this.portsTabPage.ResumeLayout(false);
     146      this.codeTabPage.ResumeLayout(false);
    132147      this.ResumeLayout(false);
    133148      this.PerformLayout();
     
    142157    protected System.Windows.Forms.TabPage codeTabPage;
    143158    protected HeuristicLab.Core.Views.ProgrammableItemView programmableItemView;
     159    protected System.Windows.Forms.Button initializeButton;
    144160
    145161  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Networks.Views/UserDefinedNodeView.cs

    r11564 r11565  
    4242      programmableItemView.Content = Content;
    4343    }
     44
     45    protected override void SetEnabledStateOfControls() {
     46      base.SetEnabledStateOfControls();
     47      initializeButton.Enabled = Content != null && !ReadOnly && !Locked;
     48    }
     49
     50    private void initializeButton_Click(object sender, System.EventArgs e) {
     51      Content.Initialize();
     52    }
    4453  }
    4554}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Core.Views/ProgrammableItemView.cs

    r11564 r11565  
    2121
    2222using HeuristicLab.Common.Resources;
    23 using HeuristicLab.Core.Views;
    2423using HeuristicLab.MainForm;
    2524using HeuristicLab.PluginInfrastructure;
     
    7170    protected override void SetEnabledStateOfControls() {
    7271      base.SetEnabledStateOfControls();
    73       compileButton.Enabled = Content != null && !Locked && !ReadOnly;
    74       codeEditor.Enabled = Content != null;
     72      compileButton.Enabled = Content != null && Content.CanChangeCode && !Locked && !ReadOnly;
     73      codeEditor.Enabled = Content != null && !Locked;
     74      codeEditor.ReadOnly = ReadOnly || Locked || ((Content != null) && !Content.CanChangeCode);
    7575    }
    7676
     
    9797    }
    9898    private void codeEditor_Validated(object sender, EventArgs e) {
    99       if (Content != null) Content.Code = codeEditor.UserCode;
     99      if ((Content != null) && Content.CanChangeCode) Content.Code = codeEditor.UserCode;
    100100    }
    101101    private void errorsListView_DoubleClick(object sender, EventArgs e) {
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/IUserDefinedNetwork.cs

    r11564 r11565  
    2424    new PortCollection Ports { get; }
    2525    new NodeCollection Nodes { get; }
     26
     27    void Initialize();
    2628  }
    2729}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/IUserDefinedNode.cs

    r11564 r11565  
    2323  public interface IUserDefinedNode : IProgrammableNode {
    2424    new PortCollection Ports { get; }
     25
     26    void Initialize();
    2527  }
    2628}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/ProgrammableNetwork.cs

    r11564 r11565  
    103103      }
    104104
     105      public override void Initialize() {
     106        base.Initialize();
     107        Nodes.Clear();
     108      }
     109
    105110      #region Events
    106111      public override void RegisterEvents() {
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/ProgrammableNetworkItem.cs

    r11564 r11565  
    100100      get { return ReadCodeTemplate("HeuristicLab.Optimization.Networks.Core.Networks.ProgrammableNetworkItemTemplate.cs"); }
    101101    }
    102 
    103102    [Storable]
    104103    private string code;
     
    106105      get { return code; }
    107106      set {
     107        if (!CanChangeCode) throw new NotSupportedException("Code cannot be changed.");
    108108        if (value != code) {
    109109          code = value;
     
    112112      }
    113113    }
    114 
    115114    private CompilerErrorCollection compileErrors;
    116115    public CompilerErrorCollection CompileErrors {
     
    120119        OnCompileErrorsChanged();
    121120      }
     121    }
     122    public virtual bool CanChangeCode {
     123      get { return false; }
    122124    }
    123125
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/ProgrammableNode.cs

    r11564 r11565  
    119119      }
    120120
     121      public override void Initialize() {
     122        base.Initialize();
     123        Ports.Clear();
     124      }
     125
    121126      protected virtual void MessagePort_MessageReceived(object sender, EventArgs<IMessage, CancellationToken> e) { }
    122127
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/UserDefinedNetwork.cs

    r11564 r11565  
    3434      get { return base.Nodes; }
    3535    }
     36    public override bool CanChangeCode {
     37      get { return true; }
     38    }
    3639
    3740    [StorableConstructor]
     
    4548      return new UserDefinedNetwork(this, cloner);
    4649    }
     50
     51    public void Initialize() {
     52      CompiledNetworkItem.DeregisterEvents();
     53      CompiledNetworkItem.Initialize();
     54      CompiledNetworkItem.RegisterEvents();
     55    }
    4756  }
    4857}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/UserDefinedNode.cs

    r11564 r11565  
    3030      get { return base.Ports; }
    3131    }
     32    public override bool CanChangeCode {
     33      get { return true; }
     34    }
    3235
    3336    [StorableConstructor]
     
    4144      return new UserDefinedNode(this, cloner);
    4245    }
     46
     47    public void Initialize() {
     48      CompiledNetworkItem.DeregisterEvents();
     49      CompiledNetworkItem.Initialize();
     50      CompiledNetworkItem.RegisterEvents();
     51    }
    4352  }
    4453}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core/IProgrammableItem.cs

    r11564 r11565  
    2929    string Code { get; set; }
    3030    CompilerErrorCollection CompileErrors { get; }
     31    bool CanChangeCode { get; }
    3132
    3233    void Compile();
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11564 r11565  
    153153  </ItemGroup>
    154154  <ItemGroup>
    155     <ProjectReference Include="..\..\HeuristicLab.Algorithms.GeneticAlgorithm\3.3\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.csproj">
    156       <Project>{a51da44f-cb35-4f6f-99f5-2a2e904ab93b}</Project>
    157       <Name>HeuristicLab.Algorithms.GeneticAlgorithm-3.3</Name>
    158       <Private>False</Private>
    159     </ProjectReference>
    160155    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    161156      <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project>
     
    183178      <Private>False</Private>
    184179    </ProjectReference>
    185     <ProjectReference Include="..\..\HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj">
    186       <Project>{66d249c3-a01d-42a8-82a2-919bc8ec3d83}</Project>
    187       <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
    188       <Private>False</Private>
    189     </ProjectReference>
    190     <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
    191       <Project>{dbecb8b0-b166-4133-baf1-ed67c3fd7fca}</Project>
    192       <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
    193       <Private>False</Private>
    194     </ProjectReference>
    195180    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    196181      <Project>{23da7ff4-d5b8-41b6-aa96-f0561d24f3ee}</Project>
     
    216201      <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project>
    217202      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    218       <Private>False</Private>
    219     </ProjectReference>
    220     <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    221       <Project>{3540e29e-4793-49e7-8ee2-fea7f61c3994}</Project>
    222       <Name>HeuristicLab.Problems.Instances-3.3</Name>
    223       <Private>False</Private>
    224     </ProjectReference>
    225     <ProjectReference Include="..\..\HeuristicLab.Problems.Knapsack\3.3\HeuristicLab.Problems.Knapsack-3.3.csproj">
    226       <Project>{e10f395f-c8a6-48ad-b470-9aa7a1f43809}</Project>
    227       <Name>HeuristicLab.Problems.Knapsack-3.3</Name>
    228       <Private>False</Private>
    229     </ProjectReference>
    230     <ProjectReference Include="..\..\HeuristicLab.Problems.TravelingSalesman\3.3\HeuristicLab.Problems.TravelingSalesman-3.3.csproj">
    231       <Project>{d767c38d-8014-46b0-9a32-03a3aecce34a}</Project>
    232       <Name>HeuristicLab.Problems.TravelingSalesman-3.3</Name>
    233203      <Private>False</Private>
    234204    </ProjectReference>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Optimization.Networks.KSPTSP/KSPTSPConnectorCode.cs

    r11564 r11565  
    2828using System.Drawing;
    2929using System.Linq;
     30using System.Threading;
    3031
    3132namespace HeuristicLab.Optimization.Networks.KSPTSP {
     
    4849
    4950    public override void Initialize() {
     51      base.Initialize();
    5052      var parameters = new MessagePort("Parameters");
    5153      Ports.Add(parameters);
     
    7880    }
    7981
    80     private void Knapsack_MessageReceived(object sender, EventArgs<IMessage, System.Threading.CancellationToken> e) {
     82    private void Knapsack_MessageReceived(object sender, EventArgs<IMessage, CancellationToken> e) {
    8183      // get parameters
    8284      var parametersPort = (IMessagePort)Ports["Parameters"];
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Optimization.Networks.KSPTSP/KSPTSPNetworkCode.cs

    r11564 r11565  
    5353
    5454    public override void Initialize() {
     55      base.Initialize();
     56
    5557      #region ParametersNode
    5658      var paramsNode = new UserDefinedNode("ParametersNode");
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame

    r11520 r11565  
    2828  [Plugin("HeuristicLab.Optimization.Networks", "3.3.11.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Optimization.Networks-3.3.dll", PluginFileType.Assembly)]
    30   [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
    3130  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3231  [PluginDependency("HeuristicLab.Common", "3.3")]
     
    3433  [PluginDependency("HeuristicLab.Core", "3.3")]
    3534  [PluginDependency("HeuristicLab.Data", "3.3")]
    36   [PluginDependency("HeuristicLab.Encodings.BinaryVectorEncoding", "3.3")]
    37   [PluginDependency("HeuristicLab.Encodings.PermutationEncoding", "3.3")]
    3835  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3936  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    4037  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4138  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    42   [PluginDependency("HeuristicLab.Problems.Knapsack", "3.3")]
    43   [PluginDependency("HeuristicLab.Problems.TravelingSalesman", "3.3")]
    4439  public class HeuristicLabOptimizationNetworksPlugin : PluginBase {
    4540  }
Note: See TracChangeset for help on using the changeset viewer.