diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-05-05 12:20:43 +0400 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-05-05 12:21:19 +0400 |
commit | c6647061083e3e399c5fa096a32716b387a10780 (patch) | |
tree | adb00433efe7e111ac0dead1318ba2aa44a144a3 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels | |
parent | 180a40a993b7a611d031b3636f5cb7dc4e882db7 (diff) |
Split custom commands panel in two panels: build and run.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels')
3 files changed, 69 insertions, 14 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanel.cs index 89d69ada0c..36b031897f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanel.cs @@ -37,6 +37,12 @@ namespace MonoDevelop.Ide.Projects.OptionPanels internal class CustomCommandPanel: MultiConfigItemOptionsPanel { CustomCommandPanelWidget widget; + CustomCommandType[] supportedTypes; + + public CustomCommandPanel (CustomCommandType[] supportedTypes) + { + this.supportedTypes = supportedTypes; + } public override Gtk.Widget CreatePanelWidget () { @@ -45,7 +51,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels public override void LoadConfigData () { - widget.Load (ConfiguredSolutionItem, CurrentConfiguration.CustomCommands, CurrentConfiguration.Selector); + widget.Load (ConfiguredSolutionItem, CurrentConfiguration.CustomCommands, CurrentConfiguration.Selector, supportedTypes); } public override void ApplyChanges () @@ -53,4 +59,30 @@ namespace MonoDevelop.Ide.Projects.OptionPanels // Do nothing. Changes to cloned configurations are automatically applied. } } + + internal class BuildCustomCommandPanel: CustomCommandPanel + { + public BuildCustomCommandPanel (): base (new CustomCommandType[] { + CustomCommandType.BeforeBuild, + CustomCommandType.Build, + CustomCommandType.AfterBuild, + CustomCommandType.BeforeClean, + CustomCommandType.Clean, + CustomCommandType.AfterClean, + CustomCommandType.Custom + }) + { + } + } + + internal class ExecutionCustomCommandPanel: CustomCommandPanel + { + public ExecutionCustomCommandPanel (): base (new CustomCommandType[] { + CustomCommandType.BeforeExecute, + CustomCommandType.Execute, + CustomCommandType.AfterExecute + }) + { + } + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanelWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanelWidget.cs index a6639bb7f8..c310913674 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanelWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandPanelWidget.cs @@ -27,6 +27,7 @@ using System; +using System.Linq; using MonoDevelop.Projects; namespace MonoDevelop.Ide.Projects.OptionPanels @@ -39,17 +40,19 @@ namespace MonoDevelop.Ide.Projects.OptionPanels CustomCommandWidget lastSlot; SolutionEntityItem entry; ConfigurationSelector configSelector; + CustomCommandType[] supportedTypes; public CustomCommandPanelWidget () { this.Build(); } - public void Load (SolutionEntityItem entry, CustomCommandCollection commands, ConfigurationSelector configSelector) + public void Load (SolutionEntityItem entry, CustomCommandCollection commands, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes) { this.entry = entry; this.commands = commands; this.configSelector = configSelector; + this.supportedTypes = supportedTypes; // Clean the list foreach (CustomCommandWidget ccw in vboxCommands.Children) { @@ -60,7 +63,8 @@ namespace MonoDevelop.Ide.Projects.OptionPanels } foreach (CustomCommand cmd in commands) { - AddCommandSlot (cmd); + if (supportedTypes.Contains (cmd.Type)) + AddCommandSlot (cmd); } // Add an empty slot to allow adding more commands. AddCommandSlot (null); @@ -68,7 +72,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels void AddCommandSlot (CustomCommand cmd) { - CustomCommandWidget widget = new CustomCommandWidget (entry, cmd, configSelector); + CustomCommandWidget widget = new CustomCommandWidget (entry, cmd, configSelector, supportedTypes); vboxCommands.PackStart (widget, false, false, 0); widget.CommandCreated += OnCommandCreated; widget.CommandRemoved += OnCommandRemoved; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandWidget.cs index e78d025a65..139aa03ff7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects.OptionPanels/CustomCommandWidget.cs @@ -41,16 +41,36 @@ namespace MonoDevelop.Ide.Projects.OptionPanels CustomCommand cmd; IWorkspaceObject entry; bool updating; + CustomCommandType[] supportedTypes; - public CustomCommandWidget (IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector) + string[] commandNames = { + GettextCatalog.GetString ("Before Build"), + GettextCatalog.GetString ("Build"), + GettextCatalog.GetString ("After Build"), + GettextCatalog.GetString ("Before Execute"), + GettextCatalog.GetString ("Execute"), + GettextCatalog.GetString ("After Execute"), + GettextCatalog.GetString ("Before Clean"), + GettextCatalog.GetString ("Clean"), + GettextCatalog.GetString ("After Clean"), + GettextCatalog.GetString ("Custom Command") + }; + + public CustomCommandWidget (IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes) { this.Build(); + this.supportedTypes = supportedTypes; this.cmd = cmd; - if (cmd != null) { - updating = true; - comboType.RemoveText (0); - updating = false; - } + + updating = true; + + if (cmd == null) + comboType.AppendText (GettextCatalog.GetString ("(Select a project operation)")); + + foreach (var ct in supportedTypes) + comboType.AppendText (commandNames [(int)ct]); + + updating = false; this.entry = entry; UpdateControls (); @@ -85,8 +105,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels comboType.Active = 0; } else { - Array array = Enum.GetValues (typeof (CustomCommandType)); - comboType.Active = Array.IndexOf (array, cmd.Type); + comboType.Active = Array.IndexOf (supportedTypes, cmd.Type); labelName.Visible = entryName.Visible = (cmd.Type == CustomCommandType.Custom); entryName.Text = cmd.Name ?? ""; entryCommand.Text = cmd.Command ?? ""; @@ -134,7 +153,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels if (comboType.Active != 0) { // Selected a command type. Create the command now cmd = new CustomCommand (); - cmd.Type = (CustomCommandType) (comboType.Active - 1); + cmd.Type = supportedTypes [comboType.Active - 1]; updating = true; comboType.RemoveText (0); updating = false; @@ -142,7 +161,7 @@ namespace MonoDevelop.Ide.Projects.OptionPanels CommandCreated (this, EventArgs.Empty); } } else - cmd.Type = (CustomCommandType) (comboType.Active); + cmd.Type = supportedTypes [comboType.Active]; UpdateControls (); if (cmd.Type == CustomCommandType.Custom) entryName.GrabFocus (); |