Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/09 18:12:38 (16 years ago)
Author:
epitzer
Message:

Refactor saving into IEditor and provide choice of compressed and uncompressed HeuristicLab archives during saving (#646)

Location:
trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.Designer.cs

    r1529 r1921  
    103103            this.exitToolStripMenuItem});
    104104      this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
    105       this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
     105      this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
    106106      this.fileToolStripMenuItem.Text = "&File";
    107107      //
     
    109109      //
    110110      this.newToolStripMenuItem.Name = "newToolStripMenuItem";
    111       this.newToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     111      this.newToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    112112      this.newToolStripMenuItem.Text = "&New";
    113113      //
     
    116116      this.openToolStripMenuItem.Name = "openToolStripMenuItem";
    117117      this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
    118       this.openToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     118      this.openToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    119119      this.openToolStripMenuItem.Text = "&Open...";
    120120      this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
     
    125125      this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
    126126      this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
    127       this.saveToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     127      this.saveToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    128128      this.saveToolStripMenuItem.Text = "&Save";
    129129      this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
     
    133133      this.saveAsToolStripMenuItem.Enabled = false;
    134134      this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
    135       this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     135      this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    136136      this.saveAsToolStripMenuItem.Text = "Save &As...";
    137137      this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
     
    143143      this.saveAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
    144144                  | System.Windows.Forms.Keys.S)));
    145       this.saveAllToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     145      this.saveAllToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    146146      this.saveAllToolStripMenuItem.Text = "Save Al&l";
    147147      this.saveAllToolStripMenuItem.Click += new System.EventHandler(this.saveAllToolStripMenuItem_Click);
     
    151151      this.closeToolStripMenuItem.Enabled = false;
    152152      this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
    153       this.closeToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     153      this.closeToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    154154      this.closeToolStripMenuItem.Text = "&Close";
    155155      this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
     
    159159      this.closeAllToolStripMenuItem.Enabled = false;
    160160      this.closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem";
    161       this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     161      this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    162162      this.closeAllToolStripMenuItem.Text = "Clos&e All";
    163163      this.closeAllToolStripMenuItem.Click += new System.EventHandler(this.closeAllToolStripMenuItem_Click);
     
    166166      //
    167167      this.toolStripMenuItem1.Name = "toolStripMenuItem1";
    168       this.toolStripMenuItem1.Size = new System.Drawing.Size(188, 6);
     168      this.toolStripMenuItem1.Size = new System.Drawing.Size(184, 6);
    169169      //
    170170      // exitToolStripMenuItem
    171171      //
    172172      this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
    173       this.exitToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
     173      this.exitToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
    174174      this.exitToolStripMenuItem.Text = "E&xit";
    175175      this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
     
    180180            this.availableOperatorsToolStripMenuItem});
    181181      this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
    182       this.viewToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
     182      this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
    183183      this.viewToolStripMenuItem.Text = "&View";
    184184      //
     
    186186      //
    187187      this.availableOperatorsToolStripMenuItem.Name = "availableOperatorsToolStripMenuItem";
    188       this.availableOperatorsToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
     188      this.availableOperatorsToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
    189189      this.availableOperatorsToolStripMenuItem.Text = "Available &Operators...";
    190190      this.availableOperatorsToolStripMenuItem.Click += new System.EventHandler(this.availableOperatorsToolStripMenuItem_Click);
     
    195195            this.collectGarbageToolStripMenuItem});
    196196      this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
    197       this.toolsToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
     197      this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
    198198      this.toolsToolStripMenuItem.Text = "&Tools";
    199199      //
     
    201201      //
    202202      this.collectGarbageToolStripMenuItem.Name = "collectGarbageToolStripMenuItem";
    203       this.collectGarbageToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
     203      this.collectGarbageToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
    204204      this.collectGarbageToolStripMenuItem.Text = "Collect &Garbage";
    205205      this.collectGarbageToolStripMenuItem.Click += new System.EventHandler(this.collectGarbageToolStripMenuItem_Click);
     
    210210            this.aboutToolStripMenuItem});
    211211      this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
    212       this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
     212      this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
    213213      this.helpToolStripMenuItem.Text = "&Help";
    214214      //
     
    216216      //
    217217      this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
    218       this.aboutToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
     218      this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
    219219      this.aboutToolStripMenuItem.Text = "&About";
    220220      this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
     
    238238      this.saveFileDialog.DefaultExt = "hl";
    239239      this.saveFileDialog.FileName = "item";
    240       this.saveFileDialog.Filter = "HeuristicLab files|*.hl|All files|*.*";
     240      this.saveFileDialog.Filter = "HeuristicLab archives|*.hl|Compressed HeuristicLab archives|*.hl|All files|*.*";
    241241      this.saveFileDialog.Title = "Save file as ...";
    242242      //
  • trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.cs

    r1853 r1921  
    184184        else {
    185185          editor.Filename = task.filename;
     186          editor.SaveFinished += new EventHandler(SaveFinished);
    186187          PluginManager.ControlManager.ShowControl(editor);
    187188        }
     
    193194      }
    194195    }
     196
    195197    private void Save(EditorForm form) {
    196198      if (form.Editor.Filename == null)
    197199        SaveAs(form);
    198200      else {
     201        Cursor = Cursors.AppStarting;
    199202        lock (locker) runningTasks++;
    200         Cursor = Cursors.AppStarting;
    201         ((Control)form.Editor).Enabled = false;
    202203        EnableDisableItems();
    203         Task task = new Task(form.Editor.Filename, form.Editor.Item, form.Editor);
    204         ThreadPool.QueueUserWorkItem(new WaitCallback(AsynchronousSave), task);
     204        form.Editor.Save();
    205205      }
    206206    }
    207207    private void SaveAs(EditorForm form) {
     208      if (form.Editor.Compressed)
     209        saveFileDialog.FilterIndex = 2;
     210      else
     211        saveFileDialog.FilterIndex = 1;
     212
    208213      if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    209214        form.Editor.Filename = saveFileDialog.FileName;
     215        form.Editor.Compressed = saveFileDialog.FilterIndex == 2;
    210216        Save(form);
    211217      }
    212 
    213     }
    214     private void AsynchronousSave(object state) {
    215       Task task = (Task)state;
    216       try {
    217         PersistenceManager.Save(task.storable, task.filename);
    218       } catch (Exception e) {
    219         MessageBox.Show(String.Format(
    220           "Sorry couldn't save file \"{0}\".\n The following exception occurred: {1}",
    221           task.filename, e.ToString()),
    222           "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    223       }
    224       SaveFinished(task);
    225     }
    226     private void SaveFinished(Task task) {
     218    }
     219    private void SaveFinished(object sender, EventArgs e) {
    227220      if (InvokeRequired)
    228         Invoke(new TaskFinishedDelegate(SaveFinished), task);
     221        Invoke(new EventHandler(SaveFinished), sender, e);
    229222      else {
    230         ((Control)task.editor).Enabled = true;
    231223        EnableDisableItems();
    232224        lock (locker) {
     
    255247          MessageBox.Show("The selected item doesn't provide an editor.", "Editor Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    256248        } else {
     249          editor.SaveFinished += new EventHandler(SaveFinished);
    257250          PluginManager.ControlManager.ShowControl(editor);
    258251          EnableDisableItems();
Note: See TracChangeset for help on using the changeset viewer.