public void Fill() { treeState.Save(); store.Clear(); foreach (CustomExecutionMode mode in ExecutionModeCommandService.GetCustomModes(ctx)) { if (mode.Mode == null) { continue; } string scope = ""; switch (mode.Scope) { case CustomModeScope.Project: scope = GettextCatalog.GetString("Current project"); break; case CustomModeScope.Solution: scope = GettextCatalog.GetString("Current solution"); break; case CustomModeScope.Global: scope = GettextCatalog.GetString("All solutions"); break; } store.AppendValues(mode, mode.Name, mode.Mode.Name, scope, mode.Id); } treeState.Load(); UpdateButtons(); }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console, bool allowPrompt, bool forcePrompt) { if ((PromptForParameters || forcePrompt) && allowPrompt) { var ctx = new CommandExecutionContext(Project, command); CustomExecutionMode customMode = ExecutionModeCommandService.ShowParamtersDialog(ctx, Mode, this); if (customMode == null) { return(new CancelledProcessAsyncOperation()); } return(customMode.Execute(command, console, false, false)); } foreach (var cc in GetCachedCustomizers()) { cc.Item1.Customize(command, cc.Item2); } var cmode = Mode.ExecutionHandler as ParameterizedExecutionHandler; if (cmode != null) { CommandExecutionContext ctx = new CommandExecutionContext(Project, command); return(cmode.Execute(command, console, ctx, Data)); } return(Mode.ExecutionHandler.Execute(command, console)); }
static bool SupportsParameterization(IExecutionMode mode, CommandExecutionContext ctx) { if (ExecutionModeCommandService.GetExecutionCommandCustomizers(ctx).Any()) { return(true); } return(mode.ExecutionHandler is ParameterizedExecutionHandler); }
protected virtual void OnButtonRemoveClicked(object sender, System.EventArgs e) { CustomExecutionMode mode = GetSelectedMode(); if (mode != null && MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to delete the custom execution mode '{0}'?", mode.Name), AlertButton.Delete)) { ExecutionModeCommandService.RemoveCustomCommand(ctx.Project, mode); Fill(); } }
void LoadEditors() { Dictionary <object, object> oldData = new Dictionary <object, object> (); foreach (KeyValuePair <object, IExecutionConfigurationEditor> editor in currentEditors) { object data = editor.Value.Save(); oldData [editor.Key] = data; } foreach (Gtk.Widget w in notebook.Children) { notebook.Remove(w); w.Destroy(); } if (mode == null) { return; } currentEditors.Clear(); foreach (ExecutionCommandCustomizer customizer in ExecutionModeCommandService.GetExecutionCommandCustomizers(ctx)) { IExecutionConfigurationEditor e = customizer.CreateEditor(); currentEditors.Add(customizer, e); object cdata; if (!oldData.TryGetValue(customizer, out cdata)) { cdata = data.GetCommandData(customizer.Id); } Gtk.Widget w = e.Load(ctx, cdata); w.Show(); notebook.AppendPage(w, new Gtk.Label(GettextCatalog.GetString(customizer.Name))); } ParameterizedExecutionHandler handler = mode.ExecutionHandler as ParameterizedExecutionHandler; if (handler != null) { IExecutionConfigurationEditor e = handler.CreateEditor(); currentEditors.Add(mode, e); object cdata; if (!oldData.TryGetValue(mode, out cdata)) { cdata = data.Data; } Gtk.Widget w = e.Load(ctx, data.Data); w.Show(); notebook.AppendPage(w, new Gtk.Label(mode.Name)); } notebook.ShowTabs = notebook.ShowBorder = currentEditors.Count > 1; hseparator.Visible = !notebook.ShowTabs; }
internal IProcessAsyncOperation InternalExecute(CommandExecutionContext ctx, IExecutionMode mode, ExecutionCommand command, IConsole console) { CustomExecutionMode cmode = ExecutionModeCommandService.ShowParamtersDialog(ctx, mode, null); if (cmode == null) { return(new CancelledProcessAsyncOperation()); } return(cmode.Execute(command, console, false, false)); }
protected virtual void OnButtonAddClicked(object sender, System.EventArgs e) { var dlg = new CustomExecutionModeDialog(); try { dlg.Initialize(ctx, null, null); if (MessageService.RunCustomDialog(dlg, this) == (int)Gtk.ResponseType.Ok) { ExecutionModeCommandService.SaveCustomCommand(ctx.Project, dlg.GetConfigurationData()); Fill(); } } finally { dlg.Destroy(); } }
public static void ExecuteCommand(SolutionItem item, object data) { if (data is string) { if ((string)data == "selector") { using (var dlg = new ExecutionModeSelectorDialog()) { dlg.Load(item); var cmd = dlg.Run(); if (cmd?.Id == "run") { // Store the configuration for quick reuse var ec = new ExecutionConfiguration(dlg.SelectedConfiguration, dlg.SelectedExecutionModeSet, dlg.SelectedExecutionMode); var list = ExecutionModeCommandService.GetExecutionConfigurations(item).ToList(); list.Remove(ec); list.Insert(0, ec); while (list.Count > 10) { list.RemoveAt(list.Count - 1); } ExecutionModeCommandService.SetExecutionConfigurations(item, list.ToArray()); // Run the configuration IdeApp.ProjectOperations.Execute(item, dlg.SelectedExecutionMode.ExecutionHandler, IdeApp.Workspace.ActiveConfiguration, dlg.SelectedConfiguration); } return; } } else if ((string)data == "custom") { using (var dlg = new RunWithCustomParametersDialog((Project)item)) { var cmd = dlg.Run(IdeServices.DesktopService.GetFocusedTopLevelWindow()); if (cmd?.Id == "run") { // Run the configuration IdeApp.ProjectOperations.Execute(item, dlg.SelectedExecutionMode.ExecutionHandler, IdeApp.Workspace.ActiveConfiguration, dlg.SelectedConfiguration); } return; } } } var c = (ExecutionConfiguration)data; IdeApp.ProjectOperations.Execute(item, c.Mode.ExecutionHandler, IdeApp.Workspace.ActiveConfiguration, c.RunConfiguration); }
IList <Tuple <ExecutionCommandCustomizer, object> > GetCachedCustomizers() { if (cachedCustomizers != null) { return(cachedCustomizers); } if (commandData == null) { return(cachedCustomizers = new Tuple <ExecutionCommandCustomizer, object> [0]); } return(cachedCustomizers = commandData .Select(cmdData => Tuple.Create( ExecutionModeCommandService.GetExecutionCommandCustomizer(cmdData.Key), cmdData.Value)) .Where(cc => cc != null) .ToList()); }
void SuggestName() { if (mode == null) { return; } string baseName = mode.Name; int count = 1; for (int n = 1; n < 100; n++) { if (baseName.EndsWith(GetNamePosfix(n))) { count = n + 1; baseName = baseName.Substring(0, baseName.Length - GetNamePosfix(n).Length); } } string name = baseName + GetNamePosfix(count); bool found; do { found = false; foreach (IExecutionMode m in ExecutionModeCommandService.GetExecutionModes(ctx)) { if (m.Name == name) { found = true; break; } } if (found) { name = baseName + GetNamePosfix(count++); } } while (found); entryModeName.Text = name; nameChanged = false; }
protected virtual void OnButtonEditClicked(object sender, System.EventArgs e) { CustomExecutionMode mode = GetSelectedMode(); var dlg = new CustomExecutionModeDialog(); try { dlg.Initialize(ctx, null, mode); if (MessageService.RunCustomDialog(dlg, this) == (int)Gtk.ResponseType.Ok) { CustomExecutionMode newMode = dlg.GetConfigurationData(); ExecutionModeCommandService.SaveCustomCommand(ctx.Project, newMode); if (newMode.Scope != mode.Scope) { ExecutionModeCommandService.RemoveCustomCommand(ctx.Project, mode); } Fill(); } } finally { dlg.Destroy(); } }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console, bool allowPrompt, bool forcePrompt) { if ((PromptForParameters || forcePrompt) && allowPrompt) { CommandExecutionContext ctx = new CommandExecutionContext(Project, command); CustomExecutionMode customMode = ExecutionModeCommandService.ShowParamtersDialog(ctx, Mode, this); if (customMode == null) { return(new CancelledProcessAsyncOperation()); } else { return(customMode.Execute(command, console, false, false)); } } if (commandData != null) { foreach (KeyValuePair <string, object> cmdData in commandData) { ExecutionCommandCustomizer cc = ExecutionModeCommandService.GetExecutionCommandCustomizer(cmdData.Key); if (cc != null) { cc.Customize(command, cmdData.Value); } } } ParameterizedExecutionHandler cmode = Mode.ExecutionHandler as ParameterizedExecutionHandler; if (cmode != null) { CommandExecutionContext ctx = new CommandExecutionContext(Project, command); return(cmode.Execute(command, console, ctx, Data)); } else { return(Mode.ExecutionHandler.Execute(command, console)); } }
internal bool Resolve(IRunTarget item) { if (RunConfiguration != null && Mode != null) { return(true); } RunConfiguration = item.GetRunConfigurations().FirstOrDefault(co => co.Id == runConfigurationId); if (RunConfiguration == null) { return(false); } var ctx = new CommandExecutionContext(item, h => item.CanExecute(new MonoDevelop.Projects.ExecutionContext(h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, RunConfiguration)); IExecutionModeSet modeSet; IExecutionMode mode; if (!ExecutionModeCommandService.GetExecutionMode(ctx, executionModeId, out modeSet, out mode)) { return(false); } ModeSet = modeSet; Mode = mode; return(true); }