示例#1
0
        public static IEnumerable <IExecutionMode> GetExecutionModes(CommandExecutionContext ctx)
        {
            foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes())
            {
                foreach (IExecutionMode mode in mset.ExecutionModes)
                {
                    if (ctx.CanExecute(mode.ExecutionHandler))
                    {
                        yield return(mode);
                    }
                }
            }

            foreach (CustomExecutionMode mode in GetCustomModes(ctx))
            {
                if (ctx.CanExecute(mode))
                {
                    yield return(mode);
                }
            }
        }
示例#2
0
 internal static IEnumerable <CustomExecutionMode> GetCustomModes(CommandExecutionContext ctx)
 {
     if (ctx.Project != null)
     {
         CustomExecutionModes modes = ctx.Project.UserProperties.GetValue <CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext());
         if (modes != null)
         {
             foreach (CustomExecutionMode mode in modes.Data)
             {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute(mode.ExecutionHandler))
                 {
                     mode.Scope = CustomModeScope.Project;
                     yield return(mode);
                 }
             }
         }
         modes = ctx.Project.ParentSolution.UserProperties.GetValue <CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext());
         if (modes != null)
         {
             foreach (CustomExecutionMode mode in modes.Data)
             {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute(mode.ExecutionHandler))
                 {
                     mode.Scope = CustomModeScope.Solution;
                     yield return(mode);
                 }
             }
         }
     }
     foreach (CustomExecutionMode mode in GetGlobalCustomExecutionModes().Data)
     {
         if (ctx.CanExecute(mode.ExecutionHandler))
         {
             mode.Scope = CustomModeScope.Global;
             yield return(mode);
         }
     }
 }
        void LoadModes()
        {
            storeModes.Clear();
            var  currentMode  = SelectedExecutionMode;
            bool nodeSelected = false;
            var  ctx          = new CommandExecutionContext(item, h => item.CanExecute(new ExecutionContext(h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, SelectedConfiguration));

            foreach (var modeSet in Runtime.ProcessService.GetExecutionModes())
            {
                TreeNavigator setNode = null;
                foreach (var mode in modeSet.ExecutionModes)
                {
                    if (ctx.CanExecute(mode.ExecutionHandler))
                    {
                        if (setNode == null)
                        {
                            setNode = storeModes.AddNode();
                            setNode.SetValue(modeNameField, modeSet.Name);
                            setNode.SetValue(modeField, mode);
                            setNode.SetValue(modeSetField, modeSet);
                            if (mode.Id == currentMode?.Id)
                            {
                                treeModes.SelectRow(setNode.CurrentPosition);
                                nodeSelected = true;
                            }
                        }
                        var node = storeModes.AddNode(setNode.CurrentPosition);
                        node.SetValue(modeNameField, mode.Name);
                        node.SetValue(modeField, mode);
                        node.SetValue(modeSetField, modeSet);
                        if (!nodeSelected && mode.Id == currentMode?.Id)
                        {
                            treeModes.SelectRow(node.CurrentPosition);
                            nodeSelected = true;
                        }
                    }
                }
                // If the mode only has one child, remove it, we don't need to show it
                if (setNode != null && setNode.MoveToChild())
                {
                    var pos = setNode.Clone();
                    if (!setNode.MoveNext())
                    {
                        pos.Remove();
                    }
                }
            }
            if (!nodeSelected && storeModes.GetFirstNode()?.CurrentPosition != null)
            {
                treeModes.SelectRow(storeModes.GetFirstNode().CurrentPosition);
            }
        }
示例#4
0
        List <ExecutionConfiguration> GetExecutionConfigurations()
        {
            var ctx = new CommandExecutionContext(project, h => project.CanExecute(new ExecutionContext(h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, runConfig));
            var res = new List <ExecutionConfiguration> ();

            foreach (var modeSet in Runtime.ProcessService.GetExecutionModes())
            {
                foreach (var mode in modeSet.ExecutionModes)
                {
                    if (ctx.CanExecute(mode.ExecutionHandler))
                    {
                        res.Add(new ExecutionConfiguration(runConfig, modeSet, mode));
                    }
                }
            }
            return(res);
        }
 internal static bool GetExecutionMode(CommandExecutionContext ctx, string id, out IExecutionModeSet modeSet, out IExecutionMode mode)
 {
     foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes())
     {
         foreach (IExecutionMode m in mset.ExecutionModes)
         {
             if (m.Id == id && ctx.CanExecute(m.ExecutionHandler))
             {
                 modeSet = mset;
                 mode    = m;
                 return(true);
             }
         }
     }
     modeSet = null;
     mode    = null;
     return(false);
 }
示例#6
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);
        }
		List<ExecutionConfiguration> GetExecutionConfigurations ()
		{
			var ctx = new CommandExecutionContext (project, h => project.CanExecute (new ExecutionContext (h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, runConfig));
			var res = new List<ExecutionConfiguration> ();
			foreach (var modeSet in Runtime.ProcessService.GetExecutionModes ()) {
				foreach (var mode in modeSet.ExecutionModes) {
					if (ctx.CanExecute (mode.ExecutionHandler))
						res.Add (new ExecutionConfiguration (runConfig, modeSet, mode));
				}
			}
			return res;
		}
        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 IEnumerable<CustomExecutionMode> GetCustomModes(CommandExecutionContext ctx)
 {
     if (ctx.Project != null) {
         CustomExecutionModes modes = ctx.Project.UserProperties.GetValue<CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext ());
         if (modes != null) {
             foreach (CustomExecutionMode mode in modes.Data) {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute (mode.ExecutionHandler)) {
                     mode.Scope = CustomModeScope.Project;
                     yield return mode;
                 }
             }
         }
         modes = ctx.Project.ParentSolution.UserProperties.GetValue<CustomExecutionModes> ("MonoDevelop.Ide.CustomExecutionModes", GetDataContext ());
         if (modes != null) {
             foreach (CustomExecutionMode mode in modes.Data) {
                 mode.Project = ctx.Project;
                 if (ctx.CanExecute (mode.ExecutionHandler)) {
                     mode.Scope = CustomModeScope.Solution;
                     yield return mode;
                 }
             }
         }
     }
     foreach (CustomExecutionMode mode in GetGlobalCustomExecutionModes ().Data) {
         if (ctx.CanExecute (mode.ExecutionHandler)) {
             mode.Scope = CustomModeScope.Global;
             yield return mode;
         }
     }
 }
        public static IEnumerable<IExecutionMode> GetExecutionModes(CommandExecutionContext ctx)
        {
            foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes ()) {
                foreach (IExecutionMode mode in mset.ExecutionModes) {
                    if (ctx.CanExecute (mode.ExecutionHandler))
                        yield return mode;
                }
            }

            foreach (CustomExecutionMode mode in GetCustomModes (ctx)) {
                if (ctx.CanExecute (mode))
                    yield return mode;
            }
        }
		internal static bool GetExecutionMode (CommandExecutionContext ctx, string id, out IExecutionModeSet modeSet, out IExecutionMode mode)
		{
			foreach (IExecutionModeSet mset in Runtime.ProcessService.GetExecutionModes ()) {
				foreach (IExecutionMode m in mset.ExecutionModes) {
					if (m.Id == id && ctx.CanExecute (m.ExecutionHandler)) {
						modeSet = mset;
						mode = m;
						return true;
					}
				}
			}
			modeSet = null;
			mode = null;
			return false;
		}
		void LoadModes ()
		{
			storeModes.Clear ();
			var currentMode = SelectedExecutionMode;
			bool nodeSelected = false;
			var ctx = new CommandExecutionContext (item, h => item.CanExecute (new ExecutionContext (h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, SelectedConfiguration));
			foreach (var modeSet in Runtime.ProcessService.GetExecutionModes ()) {
				TreeNavigator setNode = null;
				foreach (var mode in modeSet.ExecutionModes) {
					if (ctx.CanExecute (mode.ExecutionHandler)) {
						if (setNode == null) {
							setNode = storeModes.AddNode ();
							setNode.SetValue (modeNameField, modeSet.Name);
							setNode.SetValue (modeField, mode);
							setNode.SetValue (modeSetField, modeSet);
							if (mode.Id == currentMode?.Id) {
								treeModes.SelectRow (setNode.CurrentPosition);
								nodeSelected = true;
							}
						}
						var node = storeModes.AddNode (setNode.CurrentPosition);
						node.SetValue (modeNameField, mode.Name);
						node.SetValue (modeField, mode);
						node.SetValue (modeSetField, modeSet);
						if (!nodeSelected && mode.Id == currentMode?.Id) {
							treeModes.SelectRow (node.CurrentPosition);
							nodeSelected = true;
						}
					}
				}
				// If the mode only has one child, remove it, we don't need to show it
				if (setNode != null && setNode.MoveToChild ()) {
					var pos = setNode.Clone ();
					if (!setNode.MoveNext ())
						pos.Remove ();
				}
			}
			if (!nodeSelected && storeModes.GetFirstNode ()?.CurrentPosition != null)
				treeModes.SelectRow (storeModes.GetFirstNode ().CurrentPosition);
		}