Changeset 17436


Ignore:
Timestamp:
02/17/20 09:29:51 (19 months ago)
Author:
dpiringe
Message:

#3026:

  • removed unnecessary code in FileManager
  • updated ExportJsonDialog and Testprogram (Heuristiclab.ConfigStarter/Program.cs) to use the new GenerateTemplate method
Location:
branches/3026_IntegrationIntoSymSpace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/FileManager.cs

    r17404 r17436  
    1414namespace HeuristicLab.JsonInterface.OptimizerIntegration {
    1515  internal static class FileManager {
    16     private static SaveFileDialog saveFileDialog;
    1716    private static OpenFileDialog openFileDialog;
    1817    private static ExportJsonDialog exportDialog = new ExportJsonDialog();
     
    2625    public static void ExportJsonTemplate(IContentView view) {
    2726      // TODO: view to select free params, warning if no results are generated
    28      
    29 
    30 
    3127      IStorableContent content = view.Content as IStorableContent;
    3228      if (!view.Locked && content != null) {
    3329        exportDialog.Content = content;
    3430        exportDialog.ShowDialog();
    35         /*
    36         if (saveFileDialog == null) {
    37           saveFileDialog = new SaveFileDialog();
    38           saveFileDialog.Title = "Export .json-Template";
    39           saveFileDialog.DefaultExt = "json";
    40           saveFileDialog.Filter = ".json-Template|*.json|All Files|*.*";
    41           saveFileDialog.FilterIndex = 1;
    42         }
    43 
    44         INamedItem namedItem = content as INamedItem;
    45         string suggestedFileName = string.Empty;
    46         if (!string.IsNullOrEmpty(content.Filename)) suggestedFileName = content.Filename;
    47         else if (namedItem != null) suggestedFileName = namedItem.Name;
    48         else suggestedFileName = "Item";
    49 
    50         saveFileDialog.FileName = suggestedFileName + " " + namedItem.GetType().Name;
    51 
    52         if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    53           IAlgorithm alg = namedItem as IAlgorithm;
    54           File.WriteAllText(saveFileDialog.FileName, JCGenerator.GenerateTemplate(alg));
    55         }
    56         */
    5731      }
    5832    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs

    r17435 r17436  
    2222    private IList<JsonItemVMBase> VMs { get; set; }
    2323    private JCGenerator Generator { get; set; } = new JCGenerator();
    24     private IDictionary<string, IJsonItem> ResultItems = new Dictionary<string, IJsonItem>();
     24    private IDictionary<string, IJsonItem> ResultItems { get; set; } = new Dictionary<string, IJsonItem>();
    2525
    2626    private IContent content;
     
    3333        treeView.Nodes.Clear();
    3434        ResultItems.Clear();
    35        
     35        resultItems.Items.Clear();
     36
    3637        Optimizer = content as IOptimizer;
    3738        Root = JsonItemConverter.Extract(Optimizer);
     
    9394
    9495      if (SaveFileDialog.ShowDialog() == DialogResult.OK) {
    95         File.WriteAllText(SaveFileDialog.FileName, Generator.GenerateTemplate(Root, Optimizer));
     96        Generator.GenerateTemplate(@"C:\Users\p41997\Desktop", "template", Optimizer, Root);
    9697      }
    9798
  • branches/3026_IntegrationIntoSymSpace/Heuristiclab.ConfigStarter/Program.cs

    r17417 r17436  
    4646
    4747      JCGenerator generator = new JCGenerator();
    48 
    49       File.WriteAllText(@"C:\Workspace\Template.json", generator.GenerateTemplate(alg));
     48      generator.GenerateTemplate(@"C:\Workspace\Template.json", alg);
    5049      JsonTemplateInstantiator.Instantiate(@"C:\Workspace\Template.json");
    5150      /*
Note: See TracChangeset for help on using the changeset viewer.