Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DataProcessor/DataProcessorView.cs @ 7624

Last change on this file since 7624 was 7267, checked in by gkronber, 13 years ago

#1734 updated copyright year in all files of the DataImporter branch

File size: 24.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Linq;
27using System.Text;
28using System.Windows.Forms;
29using System.IO;
30using System.Reflection;
31using HeuristicLab.PluginInfrastructure;
32using HeuristicLab.DataImporter.DbExplorer.Interfaces;
33using HeuristicLab.DataImporter.Data;
34using HeuristicLab.DataImporter.Data.CommandBase;
35using HeuristicLab.DataImporter.Data.Model;
36using HeuristicLab.DataImporter.Data.View;
37using HeuristicLab.DataImporter.DataProcessor.Command;
38using System.Xml;
39using HeuristicLab.Persistence.Default.Xml;
40
41namespace HeuristicLab.DataImporter.DataProcessor {
42  public partial class DataProcessorView : Form {
43    private DataSetView dataSetView;
44    private BackgroundWorker backgroundWorker;
45    private string lastSavedFile;
46    private ICommand lastSavedCommand;
47    private ProgressDialog progressDlg;
48
49    private DataProcessorView() {
50      InitializeComponent();
51      this.HScroll = false;
52      this.HorizontalScroll.Visible = false;
53      backgroundWorker = new BackgroundWorker();
54      backgroundWorker.WorkerReportsProgress = true;
55      backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
56      backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
57      backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
58    }
59
60    public DataProcessorView(DataProcessor dataProcessor)
61      : this() {
62      this.dataProcessor = dataProcessor;
63      this.dataProcessor.CommandChain.Changed += this.CommandChainChanged;
64      this.dataSetView = new DataSetView(this.dataProcessor.DataSet, this.dataProcessor.CommandChain);
65      this.dataSetView.StateChanged += new EventHandler(DataSetStateChanged);
66      this.dataSetView.Dock = DockStyle.Fill;
67      this.dataSetView.ColumnGroupMaxWidth = this.splitContainer1.Panel2.Width;
68      this.splitContainer1.Panel2.Controls.Add(this.dataSetView);
69      this.splitContainer1.Panel2.Resize += new EventHandler(Panel2_Resize);
70      FillItemList();
71
72      IDbExplorer[] explorers = ApplicationManager.Manager.GetInstances<IDbExplorer>().ToArray();
73      ToolStripItem item;
74      foreach (IDbExplorer exp in explorers) {
75        item = new ToolStripMenuItem();
76        item.Text = exp.MenuItemDescription;
77        item.Tag = exp;
78        item.Click += new EventHandler(setGenericDBConnectionToolStripMenuItem_Click);
79        databaseToolStripMenuItem.DropDownItems.Add(item);
80      }
81    }
82
83    private DataProcessor dataProcessor;
84    public DataProcessor DataProcessor {
85      get { return this.dataProcessor; }
86    }
87
88    private bool UndoEnabled {
89      get { return this.undoToolStripButton.Enabled; }
90      set { this.undoToolStripButton.Enabled = value; this.undoToolStripMenuItem.Enabled = value; }
91    }
92    private bool RedoEnabled {
93      get { return this.redoToolStripButton.Enabled; }
94      set { this.redoToolStripButton.Enabled = value; this.redoToolStripMenuItem.Enabled = value; }
95    }
96
97    private bool SaveCommandChainEnabled {
98      get { return this.saveCommandChainToolStripButton.Enabled; }
99      set { this.saveCommandChainToolStripButton.Enabled = value; }
100    }
101
102    #region CommandList
103
104    private void listCommands_MouseDoubleClick(object sender, MouseEventArgs e) {
105      ListViewItem item = listCommands.HitTest(e.Location).Item;
106      if (item != null) {
107        ICommandGenerator generator = (ICommandGenerator)listCommands.FocusedItem;
108        if (generator.Enabled(dataSetView.State)) {
109          ICommand cmd = ((ICommandGenerator)generator).GenerateCommand(dataProcessor.DataSet);
110          if (cmd != null) {
111            try {
112              dataProcessor.CommandChain.Add(cmd);
113            }
114            catch (CommandExecutionException cee) {
115              MessageBox.Show(cee.Message, cee.Command.Description);
116            }
117          }
118        }
119      }
120      item.Selected = false;
121    }
122
123    private void FillItemList() {
124      //sort after ViewableCommandInfoAttribute
125      IEnumerable<Type> commands = ApplicationManager.Manager.GetTypes(typeof(ICommand)).Select(t => new {
126        Command = t,
127        Attribute = (ViewableCommandInfoAttribute)Attribute.GetCustomAttribute(t, typeof(ViewableCommandInfoAttribute))
128      })
129         .Where(t => t.Attribute != null && !t.Command.IsAbstract)
130        .OrderBy(t => t.Attribute, new AttributeComparer())
131        .Select(t => t.Command);
132      ListViewItem item = null;
133      bool addGroup;
134      foreach (Type t in commands) {
135        item = (ListViewItem)Activator.CreateInstance(typeof(CommandListViewItem<>).MakeGenericType(t));
136        addGroup = true;
137        foreach (ListViewGroup grp in listCommands.Groups)
138          if (grp.Name == item.Group.Name) {
139            item.Group = grp;
140            addGroup = false;
141            break;
142          }
143        if (addGroup) {
144          listCommands.Groups.Add(item.Group);
145        }
146        listCommands.Items.Add(item);
147      }
148      UpdateListViewItems();
149    }
150
151    public void DataSetStateChanged(object sender, EventArgs e) {
152      UpdateListViewItems();
153    }
154
155    private void UpdateListViewItems() {
156      foreach (ICommandGenerator generator in listCommands.Items) {
157        if (generator.Enabled(dataSetView.State))
158          ((ListViewItem)generator).ForeColor = Color.Black;
159        else
160          ((ListViewItem)generator).ForeColor = Color.LightGray;
161      }
162    }
163    #endregion
164
165    private void CommandChainChanged(object sender, EventArgs e) {
166      #region undo & redo updates
167      this.UndoEnabled = !this.dataProcessor.CommandChain.FirstCommandReached;
168      this.RedoEnabled = !this.dataProcessor.CommandChain.LastCommandReached;
169      this.SaveCommandChainEnabled = !this.dataProcessor.CommandChain.FirstCommandReached;
170      this.undoToolStripButton.ToolTipText = this.dataProcessor.CommandChain.PreviousCommandDescription;
171      this.redoToolStripButton.ToolTipText = this.dataProcessor.CommandChain.NextCommandDescription;
172
173      //needed to update tooltip if it is currently being shown - taken from
174      //http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=167320
175      System.Reflection.FieldInfo f = this.toolStrip.GetType().GetField("currentlyActiveTooltipItem", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
176      if (object.ReferenceEquals(f.GetValue(this.toolStrip), this.undoToolStripButton)) {
177        // Need to set currentlyActiveTooltipItem to null, so the call to UpdateToolTip actually does the update
178        f.SetValue(this.toolStrip, null);
179        System.Reflection.MethodInfo m = this.toolStrip.GetType().GetMethod("UpdateToolTip", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
180        m.Invoke(this.toolStrip, new object[] { this.undoToolStripButton });
181      }
182      f = this.toolStrip.GetType().GetField("currentlyActiveTooltipItem", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
183      if (object.ReferenceEquals(f.GetValue(this.toolStrip), this.redoToolStripButton)) {
184        // Need to set currentlyActiveTooltipItem to null, so the call to UpdateToolTip actually does the update
185        f.SetValue(this.toolStrip, null);
186        System.Reflection.MethodInfo m = this.toolStrip.GetType().GetMethod("UpdateToolTip", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
187        m.Invoke(this.toolStrip, new object[] { this.redoToolStripButton });
188      }
189      #endregion
190
191      #region macro recording
192      Bitmap image;
193      string toolTipText;
194      if (dataProcessor.CommandChain.IsMacroRecording) {
195        image = Properties.Resources.StopHS;
196        toolTipText = "Stop Macro recording";
197      } else {
198        image = Properties.Resources.RecordHS;
199        toolTipText = "Start Macro recording";
200      }
201
202      recordMacroToolStripButton.Image = image;
203      recordMacroToolStripButton.ToolTipText = toolTipText;
204      f = this.toolStrip.GetType().GetField("currentlyActiveTooltipItem", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
205      if (object.ReferenceEquals(f.GetValue(this.toolStrip), this.recordMacroToolStripButton)) {
206        // Need to set currentlyActiveTooltipItem to null, so the call to UpdateToolTip actually does the update
207        f.SetValue(this.toolStrip, null);
208        System.Reflection.MethodInfo m = this.toolStrip.GetType().GetMethod("UpdateToolTip", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
209        m.Invoke(this.toolStrip, new object[] { this.recordMacroToolStripButton });
210      }
211      #endregion
212
213      if (!string.IsNullOrEmpty(lastSavedFile)) {
214        if (lastSavedCommand != this.dataProcessor.CommandChain.LastExecutedCommand && !lastSavedFile.Contains('*'))
215          this.Text = "Data Importer - " + lastSavedFile + "*";
216        else
217          this.Text = "Data Importer - " + lastSavedFile;
218      }
219    }
220
221    private void chbReorderColumns_CheckedChanged(object sender, EventArgs e) {
222      this.dataSetView.AllowReorderColumns = chbReorder.CheckBoxControl.Checked;
223
224      if (chbReorder.CheckBoxControl.Checked) {
225        foreach (ListViewItem item in listCommands.Items)
226          item.ForeColor = Color.LightGray;
227        listCommands.Enabled = false;
228      } else {
229        Dictionary<string, int[]> dictionary = new Dictionary<string, int[]>();
230        int[] displayIndices;
231        for (int i = this.dataSetView.Controls.Count - 1; i >= 0; i--) {
232          displayIndices = ((ColumnGroupView)this.dataSetView.Controls[i]).DisplayIndexes;
233          //check if displayIndices are ordered, otherwise the array is added to the list
234          for (int j = 0; j < displayIndices.Length; j++) {
235            if (j != 0 && ((displayIndices[j] - displayIndices[j - 1]) != 1)) {
236              ColumnGroup columnGroup = this.dataSetView.DataSet.ColumnGroups.ElementAt(this.dataSetView.Controls.Count - 1 - i);
237              dictionary[columnGroup.Name] = displayIndices;
238              break;
239            }
240          }
241        }
242        if (dictionary.Count != 0)
243          this.dataProcessor.CommandChain.Add(new ReorderColumnsCommand(this.dataProcessor.DataSet, dictionary));
244
245        listCommands.Enabled = true;
246        UpdateListViewItems();
247      }
248    }
249
250    private void UpdateDataSetView() {
251      this.dataSetView.Dispose();
252      this.dataSetView = new DataSetView(this.dataProcessor.DataSet, this.dataProcessor.CommandChain);
253      this.dataSetView.StateChanged += new EventHandler(DataSetStateChanged);
254      UpdateListViewItems();
255
256      this.dataSetView.Dock = DockStyle.Fill;
257      this.splitContainer1.Panel2.Controls.Clear();
258      this.splitContainer1.Panel2.Controls.Add(this.dataSetView);
259      this.dataSetView.ColumnGroupMaxWidth = this.splitContainer1.Panel2.Width;
260      this.dataProcessor.CommandChain.Changed += this.CommandChainChanged;
261      GC.Collect();
262    }
263
264    private void Panel2_Resize(object sender, EventArgs e) {
265      this.dataSetView.ColumnGroupMaxWidth = this.splitContainer1.Panel2.Width;
266    }
267
268
269    #region BackgroundWorker
270    private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
271      CommandChain temp = (CommandChain)e.Argument;
272      int i = 0;
273      int max = temp.CommandsCount;
274      foreach (DataSetCommandBase cmd in temp) {
275        //update description
276        backgroundWorker.ReportProgress(i * 100 / max, cmd.Description);
277        cmd.DataSet = dataProcessor.DataSet;
278        if (cmd is DatabaseCommandBase)
279          ((DatabaseCommandBase)cmd).DbExplorer = this.dataProcessor.DatabaseExplorer;
280        this.dataProcessor.CommandChain.Add(cmd, false);
281        i++;
282      }
283    }
284
285    private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
286      progressDlg.ProgressBar.Value = 100;
287      progressDlg.Refresh();
288      this.Enabled = true;
289      UpdateDataSetView();
290      progressDlg.Close();
291      if (e.Error != null) {
292        string message = e.Error.Message;
293        if (e.Error is CommandExecutionException)
294          message += Environment.NewLine + "Command: " +
295            ((CommandExecutionException)e.Error).Command.GetType().ToString();
296        MessageBox.Show(message, "Error occured during loading of command chain");
297      }
298      this.dataProcessor.CommandChain.FireChanged();
299    }
300
301    private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
302      progressDlg.Label.Text = (string)e.UserState;
303      progressDlg.ProgressBar.Value = e.ProgressPercentage;
304      progressDlg.Refresh();
305    }
306    #endregion
307
308    #region GUI actions
309    private void NewFile() {
310      if (!CheckUnsavedChanges())
311        return;
312      this.DataProcessor.Reset();
313      this.lastSavedFile = "";
314      this.Text = "Data Importer";
315      UpdateDataSetView();
316    }
317
318    private void Open() {
319      if (!CheckUnsavedChanges())
320        return;
321      OpenFileDialog dlg = new OpenFileDialog();
322      dlg.Filter = "DataImporter file (*.dhl)|*.dhl|All files (*.*)|*.*";
323      dlg.RestoreDirectory = true;
324      if (dlg.ShowDialog() == DialogResult.OK) {
325        try {
326          DataProcessor dp = (DataProcessor)XmlParser.Deserialize(dlg.FileName);
327          dp.DatabaseExplorer = this.dataProcessor.DatabaseExplorer;
328          this.lastSavedFile = dlg.FileName;
329          this.Text = "Data Importer - " + lastSavedFile;
330          this.dataProcessor.Reset();
331          this.dataProcessor = dp;
332        }
333        catch (XmlException e) {
334          MessageBox.Show(e.Message, "Error occured during file open.");
335        }
336        finally {
337          this.lastSavedCommand = null;
338          UpdateDataSetView();
339          this.dataProcessor.CommandChain.FireChanged();
340        }
341      }
342    }
343
344    private bool CheckUnsavedChanges() {
345      if (this.lastSavedCommand != this.dataProcessor.CommandChain.LastExecutedCommand) {
346        DialogResult result = MessageBox.Show("Save changes (Yes), discard changes (No) or cancel the current action (Cancel)?", "Warning", MessageBoxButtons.YesNoCancel);
347        if (result == DialogResult.Yes)
348          this.Save();
349        else if (result == DialogResult.Cancel)
350          return false;
351      }
352      return true;
353    }
354
355    private void Save() {
356      if (string.IsNullOrEmpty(this.lastSavedFile))
357        this.SaveAs();
358      else
359        this.Save(this.lastSavedFile);
360    }
361
362    private void Save(string filename) {
363      try {
364        this.Cursor = Cursors.WaitCursor;
365        XmlGenerator.Serialize(this.dataProcessor, filename,9);
366        this.Cursor = Cursors.Default;
367        this.Text = "Data Importer - " + lastSavedFile;
368        this.lastSavedCommand = this.dataProcessor.CommandChain.LastExecutedCommand;
369      }
370      finally {
371        this.Cursor = Cursors.Default;
372      }
373    }
374
375    private void SaveAs() {
376      SaveFileDialog saveFileDialog = new SaveFileDialog();
377      saveFileDialog.AddExtension = true;
378      saveFileDialog.RestoreDirectory = true;
379      saveFileDialog.DefaultExt = "dhl";
380      saveFileDialog.Filter = "DataImporter file (*.dhl)|*.dhl|All files (*.*)|*.*";
381
382      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
383        this.lastSavedFile = saveFileDialog.FileName;
384        this.Save(this.lastSavedFile);
385      }
386    }
387
388    private void RecordMacro() {
389      if (dataProcessor.CommandChain.IsMacroRecording)
390        this.SaveCommandChain();
391      this.dataProcessor.CommandChain.ToggleMacroRecording();
392    }
393
394    private void OpenCommandChain() {
395      OpenFileDialog dlg = new OpenFileDialog();
396      dlg.Filter = "DataImporter Command file (*.dhlcmd)|*.dhlcmd|All files (*.*)|*.*";
397      dlg.RestoreDirectory = true;
398      if (dlg.ShowDialog() == DialogResult.OK) {
399        this.dataSetView.Dispose();
400        this.Cursor = Cursors.WaitCursor;
401        this.Enabled = false;
402        try {
403          CommandChain temp = (CommandChain)XmlParser.Deserialize(dlg.FileName);
404          progressDlg = new ProgressDialog();
405          progressDlg.DesktopLocation = new Point(this.Location.X + this.Width / 2 - progressDlg.Width / 2, this.Location.Y + this.Height / 2 - progressDlg.Height / 2);
406          backgroundWorker.RunWorkerAsync(temp);
407          progressDlg.ShowDialog();
408          this.Refresh();
409        }
410        finally {
411          this.Enabled = true;
412          this.Cursor = Cursors.Default;
413        }
414      }
415    }
416
417    private void SaveCommandChain() {
418      SaveFileDialog saveFileDialog = new SaveFileDialog();
419      saveFileDialog.AddExtension = true;
420      saveFileDialog.RestoreDirectory = true;
421      saveFileDialog.DefaultExt = "dhlcmd";
422      saveFileDialog.Filter = "DataImporter Command file (*.dhlcmd)|*.dhlcmd|All files (*.*)|*.*";
423
424      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
425        try {
426          this.Cursor = Cursors.WaitCursor;
427          XmlGenerator.Serialize(this.dataProcessor.CommandChain, saveFileDialog.FileName,9);
428        }
429        finally {
430          this.Cursor = Cursors.Default;
431        }
432      }
433    }
434
435    private void Export() {
436      ExportDialog exportDlg = new ExportDialog(this.dataProcessor.DataSet);
437      exportDlg.StartPosition = FormStartPosition.CenterParent;
438      exportDlg.ShowDialog(this);
439    }
440
441    private void Import() {
442      ImportDialog importDlg = new ImportDialog(this.dataProcessor.DataSet, this.dataProcessor.CommandChain);
443      importDlg.StartPosition = FormStartPosition.CenterParent;
444      importDlg.ShowDialog(this);
445    }
446
447    private void Undo() {
448      this.dataProcessor.CommandChain.Undo();
449      this.Focus();
450    }
451
452    private void Redo() {
453      this.dataProcessor.CommandChain.Redo();
454      this.Focus();
455    }
456
457    private void AddTables() {
458      if (dataProcessor.DatabaseExplorer == null || !dataProcessor.DatabaseExplorer.IsConnected) {
459        MessageBox.Show("Not connected to database!");
460        return;
461      }
462      DbTablesView tablesForm = new DbTablesView();
463      tablesForm.DbExplorer = dataProcessor.DatabaseExplorer;
464      tablesForm.SetTables(dataProcessor.DatabaseExplorer.AllTables);
465      tablesForm.StartPosition = FormStartPosition.CenterParent;
466      if (tablesForm.ShowDialog(this) == DialogResult.OK) {
467        progressDlg = new ProgressDialog();
468        progressDlg.Label.Text = "Loading data from database";
469        progressDlg.Show(this);
470        progressDlg.DesktopLocation = new Point(this.Location.X + this.Width / 2 - progressDlg.Width / 2, this.Location.Y + this.Height / 2 - progressDlg.Height / 2);
471        this.Refresh();
472        this.dataProcessor.CommandChain.Add(new LoadColumnGroupsFromDBCommand(this.dataProcessor.DataSet, this.dataProcessor.DatabaseExplorer,
473          tablesForm.SelectedTables));
474        progressDlg.Close();
475      }
476    }
477
478    private void DatabaseExplorer_NewRowLoaded(object sender, ProgressChangedEventArgs e) {
479      progressDlg.ProgressBar.Value = e.ProgressPercentage;
480      progressDlg.Label.Text = (string)e.UserState;
481      progressDlg.Refresh();
482    }
483
484    private void AddTablesWithSQLCommand() {
485      CommandViewDialog dlg = new CommandViewDialog();
486      dlg.StartPosition = FormStartPosition.CenterParent;
487      SqlCommandView cmdView = new SqlCommandView();
488      dlg.Panel.Controls.Add(cmdView);
489      dlg.Panel.Size = cmdView.Size;
490      dlg.ShowDialog(this);
491      if (dlg.DialogResult == DialogResult.OK) {
492        this.dataProcessor.CommandChain.Add(new LoadColumnGroupWithSqlStringFromDBCommand(this.dataProcessor.DataSet, this.dataProcessor.DatabaseExplorer, cmdView.SqlCommand));
493      }
494    }
495
496    private void SetDbConnection() {
497      dataProcessor.DatabaseExplorer.ShowDbConnectionWizard();
498      if (dataProcessor.DatabaseExplorer.IsConnected) {
499        this.lblConnectionStatus.Text = "Successfully connected to database!";
500        this.lblConnectionStatus.BackColor = Color.LightGreen;
501      } else {
502        this.lblConnectionStatus.Text = "Not connected to database!";
503        this.lblConnectionStatus.BackColor = Color.FromArgb(255, 128, 128); //light red
504      }
505    }
506    #endregion
507
508    #region GUI ClickEvents - menuitems, toolbarbuttons
509
510    private void DataProcessorView_FormClosing(object sender, FormClosingEventArgs e) {
511      if (!CheckUnsavedChanges())
512        e.Cancel = true;
513    }
514
515    #region MenuItems
516    private void newToolStripMenuItem_Click(object sender, EventArgs e) {
517      this.NewFile();
518    }
519
520    private void openToolStripMenuItem_Click(object sender, EventArgs e) {
521      this.Open();
522    }
523
524    private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
525      this.Save();
526    }
527
528    private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) {
529      this.SaveAs();
530    }
531
532    private void importToolStripMenuItem_Click(object sender, EventArgs e) {
533      this.Import();
534    }
535
536    private void exportToolStripMenuItem_Click(object sender, EventArgs e) {
537      this.Export();
538    }
539
540    private void exitToolStripMenuItem_Click(object sender, EventArgs e) {
541      this.Close();
542    }
543
544    private void undoToolStripMenuItem_Click(object sender, EventArgs e) {
545      this.Undo();
546    }
547
548    private void redoToolStripMenuItem_Click(object sender, EventArgs e) {
549      this.Redo();
550    }
551
552    private void addTablesToolStripMenuItem_Click(object sender, EventArgs e) {
553      this.AddTables();
554    }
555
556    private void addTablesWithSqlStringToolStripMenuItem_Click(object sender, EventArgs e) {
557      this.AddTablesWithSQLCommand();
558    }
559
560    private void setGenericDBConnectionToolStripMenuItem_Click(object sender, EventArgs e) {
561      this.dataProcessor.DatabaseExplorer = (IDbExplorer)((ToolStripMenuItem)sender).Tag;
562      this.dataProcessor.DatabaseExplorer.NewRowLoaded += new ProgressChangedEventHandler(DatabaseExplorer_NewRowLoaded);
563      this.SetDbConnection();
564    }
565    #endregion
566
567    #region ToolbarButtons
568    private void newToolStripButton_Click(object sender, EventArgs e) {
569      this.NewFile();
570    }
571
572    private void openToolStripButton_Click(object sender, EventArgs e) {
573      this.Open();
574    }
575
576    private void saveToolStripButton_Click(object sender, EventArgs e) {
577      this.Save();
578    }
579
580    private void recordMacroToolStripButton_Click(object sender, EventArgs e) {
581      this.RecordMacro();
582    }
583
584    private void openCommandChainToolStripButton_Click(object sender, EventArgs e) {
585      this.OpenCommandChain();
586    }
587
588    private void saveCommandChaingToolStripButton_Click(object sender, EventArgs e) {
589      this.SaveCommandChain();
590    }
591
592    private void undoToolStripButton_Click(object sender, EventArgs e) {
593      this.Undo();
594    }
595
596    private void redoToolStripButton_Click(object sender, EventArgs e) {
597      this.Redo();
598    }
599    #endregion
600    #endregion
601
602    private class AttributeComparer : IComparer<ViewableCommandInfoAttribute> {
603      public int Compare(ViewableCommandInfoAttribute x, ViewableCommandInfoAttribute y) {
604        int cmpResult = x.GroupName.CompareTo(y.GroupName);
605        if (cmpResult != 0)
606          return cmpResult;
607        cmpResult = x.Position.CompareTo(y.Position);
608        if (cmpResult != 0)
609          return cmpResult;
610        return x.Name.CompareTo(y.Name);
611      }
612    }
613  }
614}
Note: See TracBrowser for help on using the repository browser.