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 | |
parent | 180a40a993b7a611d031b3636f5cb7dc4e882db7 (diff) |
Split custom commands panel in two panels: build and run.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide')
6 files changed, 76 insertions, 42 deletions
diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml index 20ba22c583..b84fde613c 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/ItemOptionPanels.addin.xml @@ -32,9 +32,6 @@ <Condition id="ItemType" value="Solution"> <Section id = "AuthorInfo" _label = "Author Information" fill="true" class = "MonoDevelop.Ide.Gui.OptionPanels.AuthorInformationPanel" /> </Condition> - <Condition id="ItemType" value="SolutionEntityItem"> - <Section id = "CustomCommands" _label = "Custom Commands" icon="md-custom-commands" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.CustomCommandPanel"/> - </Condition> </Section> <Section id="Build" _label="Build"> <Section id="General" _label="General" icon="md-build-combine"> @@ -45,6 +42,9 @@ <Panel id = "SolutionGeneral" _label = "Build" class = "MonoDevelop.Ide.Projects.OptionPanels.CombineBuildOptions"/> </Condition> </Section> + <Condition id="ItemType" value="SolutionEntityItem"> + <Section id = "CustomCommands" _label = "Custom Commands" icon="md-custom-commands" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.BuildCustomCommandPanel"/> + </Condition> <Condition id="ItemType" value="Project"> <Section id = "ProjectConfigurations" _label = "Configurations" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.SolutionItemConfigurationsPanel"/> <Section id = "Compiler" _label="Compiler" icon="md-compiler-options" /> @@ -67,6 +67,9 @@ <Condition id="ItemType" value="Solution"> <Section id = "StartupOptionsPanel" _label = "Startup Project" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.StartupOptionsPanel"/> </Condition> + <Condition id="ItemType" value="SolutionEntityItem"> + <Section id = "CustomCommands" _label = "Custom Commands" icon="md-custom-commands" fill = "true" class = "MonoDevelop.Ide.Projects.OptionPanels.ExecutionCustomCommandPanel"/> + </Condition> </Section> <Section id="SourceCode" _label="Source Code"> <Section id="DotNetNamingPolicies" _label=".NET Naming Policies"> 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 (); diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Projects.OptionPanels.CustomCommandWidget.cs b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Projects.OptionPanels.CustomCommandWidget.cs index 6655864a3b..3c3513fd9e 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Projects.OptionPanels.CustomCommandWidget.cs +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Projects.OptionPanels.CustomCommandWidget.cs @@ -53,20 +53,8 @@ namespace MonoDevelop.Ide.Projects.OptionPanels this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild this.comboType = global::Gtk.ComboBox.NewText (); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("(Select a project operation)")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Before Build")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Build")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("After Build")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Before Execute")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Execute")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("After Execute")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Before Clean")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Clean")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("After Clean")); - this.comboType.AppendText (global::MonoDevelop.Core.GettextCatalog.GetString ("Custom Command")); this.comboType.CanFocus = true; this.comboType.Name = "comboType"; - this.comboType.Active = 0; this.hbox1.Add (this.comboType); global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.comboType])); w2.Position = 0; diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic b/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic index a01314c48f..af19f01502 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic @@ -7797,18 +7797,7 @@ All solutions</property> <property name="MemberName" /> <property name="CanFocus">True</property> <property name="IsTextCombo">True</property> - <property name="Items" translatable="yes">(Select a project operation) -Before Build -Build -After Build -Before Execute -Execute -After Execute -Before Clean -Clean -After Clean -Custom Command</property> - <property name="Active">0</property> + <property name="Items" /> <signal name="Changed" handler="OnComboTypeChanged" /> </widget> <packing> @@ -12452,7 +12441,6 @@ please quit MonoDevelop before installing them.</property> <property name="Visible">False</property> <property name="CanFocus">True</property> <property name="Label" translatable="yes" /> - <property name="Active">True</property> <property name="DrawIndicator">True</property> <property name="HasLabel">False</property> <property name="UseUnderline">True</property> |