protected override void Run(object dataItem) { IWorkspaceObject ce = IdeApp.ProjectOperations.CurrentSelectedBuildTarget; CustomCommand cmd = (CustomCommand)dataItem; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); Thread t = new Thread( delegate() { using (monitor) { try { cmd.Execute(monitor, ce, IdeApp.Workspace.ActiveConfiguration); } catch (Exception ex) { monitor.ReportError(GettextCatalog.GetString("Command execution failed"), ex); } } } ); t.IsBackground = true; t.Start(); }
public CustomCommandWidget (IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector) { this.Build(); this.cmd = cmd; if (cmd != null) { updating = true; comboType.RemoveText (0); updating = false; } this.entry = entry; UpdateControls (); this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll; StringTagModelDescription tagModel; if (entry is SolutionItem) tagModel = ((SolutionItem)entry).GetStringTagModelDescription (configSelector); else if (entry is WorkspaceItem) tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription (); else tagModel = new StringTagModelDescription (); tagSelectorDirectory.TagModel = tagModel; tagSelectorDirectory.TargetEntry = workingdirEntry; tagSelectorCommand.TagModel = tagModel; tagSelectorCommand.TargetEntry = entryCommand; }
public CustomCommandWidget(IWorkspaceObject entry, CustomCommand cmd, ConfigurationSelector configSelector, CustomCommandType[] supportedTypes) { this.Build(); this.supportedTypes = supportedTypes; this.cmd = cmd; 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 (); this.WidgetFlags |= Gtk.WidgetFlags.NoShowAll; StringTagModelDescription tagModel; if (entry is SolutionItem) tagModel = ((SolutionItem)entry).GetStringTagModelDescription (configSelector); else if (entry is WorkspaceItem) tagModel = ((WorkspaceItem)entry).GetStringTagModelDescription (); else tagModel = new StringTagModelDescription (); tagSelectorDirectory.TagModel = tagModel; tagSelectorDirectory.TargetEntry = workingdirEntry; tagSelectorCommand.TagModel = tagModel; tagSelectorCommand.TargetEntry = entryCommand; }
void AddCommandSlot (CustomCommand cmd) { CustomCommandWidget widget = new CustomCommandWidget (entry, cmd, configSelector, supportedTypes); vboxCommands.PackStart (widget, false, false, 0); widget.CommandCreated += OnCommandCreated; widget.CommandRemoved += OnCommandRemoved; widget.Show (); lastSlot = widget; }
protected override void Run(object dataItem) { IWorkspaceObject ce = IdeApp.ProjectOperations.CurrentSelectedBuildTarget; CustomCommand cmd = (CustomCommand)dataItem; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); Thread t = new Thread( delegate() { using (monitor) { cmd.Execute(monitor, ce, IdeApp.Workspace.ActiveConfiguration); } } ); t.IsBackground = true; t.Start(); }
public void CustomCommands() { DotNetProject p = new DotNetAssemblyProject("C#"); p.Name = "SomeProject"; DotNetProjectConfiguration c = (DotNetProjectConfiguration)p.CreateConfiguration("First"); CustomCommand cmd = new CustomCommand(); cmd.Command = "aa bb cc"; Assert.AreEqual("aa", cmd.GetCommandFile(p, c.Selector)); Assert.AreEqual("bb cc", cmd.GetCommandArgs(p, c.Selector)); cmd.Command = "\"aa bb\" cc dd"; Assert.AreEqual("aa bb", cmd.GetCommandFile(p, c.Selector)); Assert.AreEqual("cc dd", cmd.GetCommandArgs(p, c.Selector)); cmd.Command = "\"aa ${ProjectName}\" cc ${ProjectName}"; Assert.AreEqual("aa SomeProject", cmd.GetCommandFile(p, c.Selector)); Assert.AreEqual("cc SomeProject", cmd.GetCommandArgs(p, c.Selector)); cmd.WorkingDir = NormalizePath("/some/${ProjectName}/place"); Assert.AreEqual(Path.GetFullPath(NormalizePath("/some/SomeProject/place")), (string)cmd.GetCommandWorkingDir(p, c.Selector)); }
public CustomCommand Clone () { CustomCommand cmd = new CustomCommand (); cmd.command = command; cmd.workingdir = workingdir; cmd.name = name; cmd.externalConsole = externalConsole; cmd.pauseExternalConsole = pauseExternalConsole; cmd.type = type; return cmd; }
public void CustomCommands () { DotNetProject p = Services.ProjectService.CreateDotNetProject ("C#"); p.Name = "SomeProject"; DotNetProjectConfiguration c = (DotNetProjectConfiguration) p.CreateConfiguration ("First"); CustomCommand cmd = new CustomCommand (); cmd.Command = "aa bb cc"; Assert.AreEqual ("aa", cmd.GetCommandFile (p, c.Selector)); Assert.AreEqual ("bb cc", cmd.GetCommandArgs (p, c.Selector)); cmd.Command = "\"aa bb\" cc dd"; Assert.AreEqual ("aa bb", cmd.GetCommandFile (p, c.Selector)); Assert.AreEqual ("cc dd", cmd.GetCommandArgs (p, c.Selector)); cmd.Command = "\"aa ${ProjectName}\" cc ${ProjectName}"; Assert.AreEqual ("aa SomeProject", cmd.GetCommandFile (p, c.Selector)); Assert.AreEqual ("cc SomeProject", cmd.GetCommandArgs (p, c.Selector)); cmd.WorkingDir = NormalizePath ("/some/${ProjectName}/place"); Assert.AreEqual (Path.GetFullPath (NormalizePath ("/some/SomeProject/place")), (string)cmd.GetCommandWorkingDir (p, c.Selector)); }
public bool Equals (CustomCommand cmd) { if (command != cmd.command || workingdir != cmd.workingdir || externalConsole != cmd.externalConsole || pauseExternalConsole != cmd.pauseExternalConsole || type != cmd.type) return false; if (environmentVariables.Count != cmd.environmentVariables.Count) return false; foreach (var e in environmentVariables) { string val; if (!cmd.environmentVariables.TryGetValue (e.Key, out val) || e.Value != val) return false; } return true; }
public CustomCommand Clone () { CustomCommand cmd = new CustomCommand (); cmd.command = command; cmd.workingdir = workingdir; cmd.name = name; cmd.externalConsole = externalConsole; cmd.pauseExternalConsole = pauseExternalConsole; cmd.type = type; foreach (var variable in environmentVariables) { cmd.environmentVariables.Add (variable.Key, variable.Value); } return cmd; }
protected virtual void OnComboTypeChanged(object sender, System.EventArgs e) { if (!updating) { if (cmd == null) { if (comboType.Active != 0) { // Selected a command type. Create the command now cmd = new CustomCommand (); cmd.Type = (CustomCommandType) (comboType.Active - 1); updating = true; comboType.RemoveText (0); updating = false; if (CommandCreated != null) CommandCreated (this, EventArgs.Empty); } } else cmd.Type = (CustomCommandType) (comboType.Active); UpdateControls (); if (cmd.Type == CustomCommandType.Custom) entryName.GrabFocus (); else entryCommand.GrabFocus (); } }
void ResolveCustomCommand (Project project, CustomCommand cmd, out string dir, out string exe, out string args) { dir = exe = args = null; string [,] customtags = new string [,] { {"ProjectDir", "$(srcdir)"}, {"TargetName", "$(notdir $(ASSEMBLY))"}, {"TargetDir", "$(BUILD_DIR)"}, {"CombineDir", "$(top_srcdir)"} }; int i = cmd.Command.IndexOf (' '); if (i == -1) { exe = cmd.Command; args = string.Empty; } else { exe = cmd.Command.Substring (0, i); args = StringParserService.Parse (cmd.Command.Substring (i + 1), customtags); } dir = (string.IsNullOrEmpty (cmd.WorkingDir) ? "$(srcdir)" : StringParserService.Parse (cmd.WorkingDir, customtags)); }