Пример #1
0
        internal static CustomExecutionMode ShowParamtersDialog(CommandExecutionContext ctx, IExecutionMode mode, CustomExecutionMode currentMode)
        {
            CustomExecutionMode cmode = null;

            DispatchService.GuiSyncDispatch(delegate
            {
                CustomExecutionModeDialog dlg = new CustomExecutionModeDialog();
                try
                {
                    dlg.Initialize(ctx, mode, currentMode);
                    if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                    {
                        cmode         = dlg.GetConfigurationData();
                        cmode.Project = ctx.Project;
                        if (dlg.Save)
                        {
                            SaveCustomCommand(ctx.Project, cmode);
                        }
                    }
                }
                finally
                {
                    dlg.Destroy();
                }
            });
            return(cmode);
        }
Пример #2
0
        internal static void SaveCustomCommand(SolutionItem project, CustomExecutionMode cmode)
        {
            CustomExecutionModes modes = GetCustomExecutionModeList(project, cmode.Scope);
            bool found = false;

            if (!string.IsNullOrEmpty(cmode.Id))
            {
                for (int n = 0; n < modes.Data.Count; n++)
                {
                    if (modes.Data[n].Id == cmode.Id)
                    {
                        modes.Data[n] = cmode;
                        found         = true;
                        break;
                    }
                }
            }
            if (!found)
            {
                cmode.Id = Guid.NewGuid().ToString();
                modes.Data.Add(cmode);
            }

            if (cmode.Scope == CustomModeScope.Global)
            {
                SaveGlobalCustomExecutionModes();
            }
            else
            {
                IdeApp.Workspace.SavePreferences();
            }
        }
Пример #3
0
        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));
        }
        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();
            }
        }
Пример #5
0
        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));
        }
Пример #6
0
        internal static void RemoveCustomCommand(SolutionItem project, CustomExecutionMode cmode)
        {
            CustomExecutionModes modes = GetCustomExecutionModeList(project, cmode.Scope);

            modes.Data.Remove(cmode);
            if (cmode.Scope == CustomModeScope.Global)
            {
                SaveGlobalCustomExecutionModes();
            }
            else
            {
                IdeApp.Workspace.SavePreferences();
            }
        }
Пример #7
0
 public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
 {
     if (Mode is CustomExecutionMode)
     {
         return(((CustomExecutionMode)Mode).Execute(command, console, true, true));
     }
     else
     {
         CustomExecutionMode cmode = new CustomExecutionMode();
         cmode.Mode                = Mode;
         cmode.Project             = Context.Project;
         cmode.PromptForParameters = true;
         return(cmode.ExecutionHandler.Execute(command, console));
     }
 }
Пример #8
0
        public void Initialize(CommandExecutionContext ctx, IExecutionMode modeToExecute, CustomExecutionMode data)
        {
            this.ctx = ctx;

            this.data = data;
            if (this.data == null)
            {
                this.data = new CustomExecutionMode();
            }

            if (modeToExecute != null)
            {
                // The user is running the project and the selected mode requires arguments
                comboTargetMode.Load(ctx, true, false);
                comboTargetMode.SelectedMode = modeToExecute;
                mode           = modeToExecute;
                editMode       = false;
                buttonOk.Label = Gtk.Stock.Execute;
            }
            else if (data != null)
            {
                // Editing an existing custom mode
                comboTargetMode.Load(ctx, true, false);
                mode = comboTargetMode.SelectedMode = data.Mode;
                checkSave.Visible   = false;
                checkPrompt.Visible = boxName.Visible = true;
                checkPrompt.Active  = data.PromptForParameters;
                entryModeName.Text  = data.Name;
                comboStore.Active   = (int)data.Scope;
            }
            else
            {
                // Creating a new mode
                comboTargetMode.Load(ctx, true, false);
                comboTargetMode.SelectedMode = null;
                checkSave.Visible            = false;
                boxName.Visible     = true;
                checkPrompt.Visible = true;
                buttonOk.Sensitive  = false;                // Until name is intered
            }
            LoadEditors();
            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 void Initialize (CommandExecutionContext ctx, IExecutionMode modeToExecute, CustomExecutionMode data)
		{
			this.ctx = ctx;
			
			this.data = data;
			if (this.data == null)
				this.data = new CustomExecutionMode ();
			
			if (modeToExecute != null) {
				// The user is running the project and the selected mode requires arguments
				comboTargetMode.Load (ctx, true, false);
				comboTargetMode.SelectedMode = modeToExecute;
				mode = modeToExecute;
				editMode = false;
				buttonOk.Label = Gtk.Stock.Execute;
			}
			else if (data != null) {
				// Editing an existing custom mode
				comboTargetMode.Load (ctx, true, false);
				mode = comboTargetMode.SelectedMode = data.Mode;
				checkSave.Visible = false;
				checkPrompt.Visible = boxName.Visible = true;
				checkPrompt.Active = data.PromptForParameters;
				entryModeName.Text = data.Name;
				comboStore.Active = (int) data.Scope;
			}
			else {
				// Creating a new mode
				comboTargetMode.Load (ctx, true, false);
				comboTargetMode.SelectedMode = null;
				checkSave.Visible = false;
				boxName.Visible = true;
				checkPrompt.Visible = true;
				buttonOk.Sensitive = false; // Until name is intered
			}
			LoadEditors ();
			nameChanged = false;
		}
Пример #11
0
        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));
            }
        }
Пример #12
0
        public CustomExecutionMode GetConfigurationData()
        {
            CustomExecutionMode cmode = new CustomExecutionMode();

            cmode.Mode = mode;
            foreach (KeyValuePair <object, IExecutionConfigurationEditor> editor in currentEditors)
            {
                if (editor.Key is IExecutionMode)
                {
                    cmode.Data = editor.Value.Save();
                }
                else
                {
                    ExecutionCommandCustomizer customizer = (ExecutionCommandCustomizer)editor.Key;
                    cmode.SetCommandData(customizer.Id, editor.Value.Save());
                }
            }
            cmode.Name  = entryModeName.Text;
            cmode.Scope = (CustomModeScope)comboStore.Active;
            cmode.PromptForParameters = checkPrompt.Active;
            cmode.Id = data.Id;
            return(cmode);
        }
 internal static CustomExecutionMode ShowParamtersDialog(CommandExecutionContext ctx, IExecutionMode mode, CustomExecutionMode currentMode)
 {
     return(Runtime.RunInMainThread(delegate {
         CustomExecutionMode cmode = null;
         CustomExecutionModeDialog dlg = new CustomExecutionModeDialog();
         try {
             dlg.Initialize(ctx, mode, currentMode);
             if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
             {
                 cmode = dlg.GetConfigurationData();
                 cmode.Project = ctx.Project;
                 if (dlg.Save)
                 {
                     SaveCustomCommand(ctx.Project, cmode);
                 }
             }
             return cmode;
         } finally {
             dlg.Destroy();
             dlg.Dispose();
         }
     }).Result);
 }
        internal static CustomExecutionMode ShowParamtersDialog(CommandExecutionContext ctx, IExecutionMode mode, CustomExecutionMode currentMode)
        {
            CustomExecutionMode cmode = null;

            DispatchService.GuiSyncDispatch (delegate {
                CustomExecutionModeDialog dlg = new CustomExecutionModeDialog ();
                try {
                    dlg.Initialize (ctx, mode, currentMode);
                    if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
                        cmode = dlg.GetConfigurationData ();
                        cmode.Project = ctx.Project;
                        if (dlg.Save)
                            SaveCustomCommand (ctx.Project, cmode);
                    }
                } finally {
                    dlg.Destroy ();
                }
            });
            return cmode;
        }
		public CustomExecutionMode GetConfigurationData ()
		{
			CustomExecutionMode cmode = new CustomExecutionMode ();
			cmode.Mode = mode;
			foreach (KeyValuePair<object,IExecutionConfigurationEditor> editor in currentEditors) {
				if (editor.Key is IExecutionMode)
					cmode.Data = editor.Value.Save ();
				else {
					ExecutionCommandCustomizer customizer = (ExecutionCommandCustomizer) editor.Key;
					cmode.SetCommandData (customizer.Id, editor.Value.Save ());
				}
			}
			cmode.Name = entryModeName.Text;
			cmode.Scope = (CustomModeScope) comboStore.Active;
			cmode.PromptForParameters = checkPrompt.Active;
			cmode.Id = data.Id;
			return cmode;
		}
        internal static List<List<IExecutionMode>> GetExecutionModeCommands(CommandExecutionContext ctx, bool includeDefault, bool includeDefaultCustomizer)
        {
            List<List<IExecutionMode>> itemGroups = new List<List<IExecutionMode>> ();

            List<CustomExecutionMode> customModes = new List<CustomExecutionMode> (GetCustomModes (ctx));

            foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes ()) {
                List<IExecutionMode> items = new List<IExecutionMode> ();
                HashSet<string> setModes = new HashSet<string> ();
                foreach (IExecutionMode mode in mset.ExecutionModes) {
                    if (!ctx.CanExecute (mode.ExecutionHandler))
                        continue;
                    setModes.Add (mode.Id);
                    if (mode.Id != "Default" || includeDefault)
                        items.Add (mode);
                    if (mode.Id == "Default" && includeDefaultCustomizer && SupportsParameterization (mode, ctx)) {
                        CustomExecutionMode cmode = new CustomExecutionMode ();
                        cmode.Mode = mode;
                        cmode.Project = ctx.Project;
                        cmode.PromptForParameters = true;
                        cmode.Name = GettextCatalog.GetString ("Custom Parameters...");
                        items.Add (cmode);
                    }
                }
                List<CustomExecutionMode> toRemove = new List<CustomExecutionMode> ();
                foreach (CustomExecutionMode cmode in customModes) {
                    if (setModes.Contains (cmode.Mode.Id)) {
                        if (ctx.CanExecute (cmode.Mode.ExecutionHandler))
                            items.Add (cmode);
                        toRemove.Add (cmode);
                    }
                }
                foreach (CustomExecutionMode cmode in toRemove)
                    customModes.Remove (cmode);

                if (items.Count > 0)
                    itemGroups.Add (items);
            }

            if (customModes.Count > 0) {
                List<IExecutionMode> items = new List<IExecutionMode> ();
                foreach (CustomExecutionMode cmode in customModes) {
                    if (ctx.CanExecute (cmode.ExecutionHandler))
                        items.Add (cmode);
                }
                if (items.Count > 0)
                    itemGroups.Add (items);
            }
            return itemGroups;
        }
 internal static void RemoveCustomCommand(SolutionEntityItem project, CustomExecutionMode cmode)
 {
     CustomExecutionModes modes = GetCustomExecutionModeList (project, cmode.Scope);
     modes.Data.Remove (cmode);
     if (cmode.Scope == CustomModeScope.Global)
         SaveGlobalCustomExecutionModes ();
     else
         IdeApp.Workspace.SavePreferences ();
 }
Пример #18
0
        internal static List <List <IExecutionMode> > GetExecutionModeCommands(CommandExecutionContext ctx, bool includeDefault, bool includeDefaultCustomizer)
        {
            List <List <IExecutionMode> > itemGroups = new List <List <IExecutionMode> > ();

            List <CustomExecutionMode> customModes = new List <CustomExecutionMode> (GetCustomModes(ctx));

            foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes())
            {
                List <IExecutionMode> items    = new List <IExecutionMode> ();
                HashSet <string>      setModes = new HashSet <string> ();
                foreach (IExecutionMode mode in mset.ExecutionModes)
                {
                    if (!ctx.CanExecute(mode.ExecutionHandler))
                    {
                        continue;
                    }
                    setModes.Add(mode.Id);
                    if (mode.Id != "Default" || includeDefault)
                    {
                        items.Add(mode);
                    }
                    if (mode.Id == "Default" && includeDefaultCustomizer && SupportsParameterization(mode, ctx))
                    {
                        CustomExecutionMode cmode = new CustomExecutionMode();
                        cmode.Mode                = mode;
                        cmode.Project             = ctx.Project;
                        cmode.PromptForParameters = true;
                        cmode.Name                = GettextCatalog.GetString("Custom Parameters...");
                        items.Add(cmode);
                    }
                }
                List <CustomExecutionMode> toRemove = new List <CustomExecutionMode> ();
                foreach (CustomExecutionMode cmode in customModes)
                {
                    if (setModes.Contains(cmode.Mode.Id))
                    {
                        if (ctx.CanExecute(cmode.Mode.ExecutionHandler))
                        {
                            items.Add(cmode);
                        }
                        toRemove.Add(cmode);
                    }
                }
                foreach (CustomExecutionMode cmode in toRemove)
                {
                    customModes.Remove(cmode);
                }

                if (items.Count > 0)
                {
                    itemGroups.Add(items);
                }
            }

            if (customModes.Count > 0)
            {
                List <IExecutionMode> items = new List <IExecutionMode> ();
                foreach (CustomExecutionMode cmode in customModes)
                {
                    if (ctx.CanExecute(cmode.ExecutionHandler))
                    {
                        items.Add(cmode);
                    }
                }
                if (items.Count > 0)
                {
                    itemGroups.Add(items);
                }
            }
            return(itemGroups);
        }
 public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
 {
     if (Mode is CustomExecutionMode)
         return ((CustomExecutionMode)Mode).Execute (command, console, true, true);
     else {
         CustomExecutionMode cmode = new CustomExecutionMode ();
         cmode.Mode = Mode;
         cmode.Project = Context.Project;
         cmode.PromptForParameters = true;
         return cmode.ExecutionHandler.Execute (command, console);
     }
 }
        internal static void SaveCustomCommand(SolutionEntityItem project, CustomExecutionMode cmode)
        {
            CustomExecutionModes modes = GetCustomExecutionModeList (project, cmode.Scope);
            bool found = false;
            if (!string.IsNullOrEmpty (cmode.Id)) {
                for (int n=0; n<modes.Data.Count; n++) {
                    if (modes.Data[n].Id == cmode.Id) {
                        modes.Data[n] = cmode;
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                cmode.Id = Guid.NewGuid ().ToString ();
                modes.Data.Add (cmode);
            }

            if (cmode.Scope == CustomModeScope.Global)
                SaveGlobalCustomExecutionModes ();
            else
                IdeApp.Workspace.SavePreferences ();
        }