Ejemplo n.º 1
0
        void SelectActiveRuntime(RuntimeModel preferedRuntimeModel)
        {
            ignoreRuntimeChangedCount++;

            try {
                if (ToolbarView.RuntimeModel.Any ()) {
                    if (startupProjects.Length > 1) {
                        var multiProjectTarget = new MultiProjectExecutionTarget ();
                        var multipleRuntime = new RuntimeModel (this, multiProjectTarget, false, null);
                        foreach (var startupProject in startupProjects) {
                            var runtimeModel = SelectActiveRuntime (startupProject.Item1, preferedRuntimeModel);
                            if (runtimeModel == null) {
                                LoggingService.LogError ($"No runtimeModel for {startupProject.Item1.Name}");
                                continue;
                            }
                            multiProjectTarget.SetExecutionTarget (startupProject.Item1, runtimeModel.ExecutionTarget);
                            multipleRuntime.AddChild (runtimeModel);
                        }
                        ToolbarView.ActiveRuntime = multipleRuntime;
                        IdeApp.Workspace.ActiveExecutionTarget = multipleRuntime.ExecutionTarget;
                    } else if (startupProjects.Length == 1) {
                        var runtimeModel = SelectActiveRuntime (startupProjects.First ().Item1, preferedRuntimeModel);
                        ToolbarView.ActiveRuntime = runtimeModel;
                        IdeApp.Workspace.ActiveExecutionTarget = runtimeModel?.ExecutionTarget;
                        UpdateBuildConfiguration ();
                    } else {
                        ToolbarView.ActiveRuntime = null;
                        IdeApp.Workspace.ActiveExecutionTarget = null;
                    }
                }
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
Ejemplo n.º 2
0
 public RuntimeModel(MainToolbarController controller, ExecutionTarget target, RuntimeModel parent) : this(controller, target)
 {
     if (parent == null)
     {
         HasParent = false;
     }
     else
     {
         HasParent          = true;
         parent.HasChildren = true;
         parent.AddChild(this);
     }
 }
Ejemplo n.º 3
0
        void FillRuntimesForProject(List<RuntimeModel> list, SolutionItem project, ref int runtimes)
        {
            ExecutionTarget previous = null;

            foreach (var target in configurationMergers [project].GetTargetsForConfiguration (IdeApp.Workspace.ActiveConfigurationId, configurationMergers.Count < 2)) {
                if (target is ExecutionTargetGroup) {
                    var devices = (ExecutionTargetGroup)target;

                    if (previous != null)
                        list.Add (new RuntimeModel (this, displayText: null));//Seperator

                    list.Add (new RuntimeModel (this, target, true, project));
                    foreach (var device in devices) {
                        if (device is ExecutionTargetGroup) {
                            var versions = (ExecutionTargetGroup)device;

                            if (versions.Count > 1) {
                                var parent = new RuntimeModel (this, device, true, project) {
                                    IsIndented = true,
                                };
                                list.Add (parent);

                                foreach (var version in versions) {
                                    parent.AddChild (new RuntimeModel (this, version, false, project));
                                    runtimes++;
                                }
                            } else {
                                list.Add (new RuntimeModel (this, versions [0], true, project) {
                                    IsIndented = true,
                                });
                                runtimes++;
                            }
                        } else {
                            list.Add (new RuntimeModel (this, device, true, project) {
                                IsIndented = true,
                            });
                            runtimes++;
                        }
                    }
                } else {
                    if (previous is ExecutionTargetGroup) {
                        list.Add (new RuntimeModel (this, displayText: null));//Seperator
                    }

                    list.Add (new RuntimeModel (this, target, true, project));
                    runtimes++;
                }

                previous = target;
            }
        }
Ejemplo n.º 4
0
        void FillRuntimes()
        {
            ignoreRuntimeChangedCount++;
            try {
                ToolbarView.RuntimeModel = Enumerable.Empty <IRuntimeModel> ();
                if (!IdeApp.Workspace.IsOpen || currentSolution == null)
                {
                    return;
                }
                var list     = new List <RuntimeModel> ();
                int runtimes = 0;
                if (currentSolution.StartupConfiguration is MultiItemSolutionRunConfiguration)
                {
                    bool anyValid = false;
                    foreach (var startConf in ((MultiItemSolutionRunConfiguration)currentSolution.StartupConfiguration).Items)
                    {
                        if (startConf?.SolutionItem == null)
                        {
                            continue;
                        }

                        // Check that the current startup project is enabled for the current configuration
                        var solConf = currentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                        if (solConf == null || !solConf.BuildEnabledForItem(startConf.SolutionItem))
                        {
                            continue;
                        }
                        anyValid = true;
                        var projectList = new List <RuntimeModel> ();
                        FillRuntimesForProject(projectList, startConf.SolutionItem, ref runtimes);
                        var parent = new RuntimeModel(this, startConf.SolutionItem.Name);
                        parent.HasChildren = true;
                        list.Add(parent);
                        foreach (var p in projectList)
                        {
                            parent.AddChild(p);
                        }
                    }
                    if (!anyValid)
                    {
                        return;
                    }
                }
                else
                {
                    var startConf = currentSolution.StartupConfiguration as SingleItemSolutionRunConfiguration;
                    if (startConf == null || startConf.Item == null)
                    {
                        return;
                    }

                    // Check that the current startup project is enabled for the current configuration
                    var solConf = currentSolution.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                    if (solConf == null || !solConf.BuildEnabledForItem(startConf.Item))
                    {
                        return;
                    }
                    FillRuntimesForProject(list, startConf.Item, ref runtimes);
                }


                var cmds = IdeApp.CommandService.CreateCommandEntrySet(TargetsMenuPath);
                if (cmds.Count > 0)
                {
                    bool needsSeparator = runtimes > 0;
                    foreach (CommandEntry ce in cmds)
                    {
                        if (ce.CommandId == Command.Separator)
                        {
                            needsSeparator = true;
                            continue;
                        }
                        var cmd = ce.GetCommand(IdeApp.CommandService) as ActionCommand;
                        if (cmd != null)
                        {
                            var ci = IdeApp.CommandService.GetCommandInfo(cmd.Id, new CommandTargetRoute(lastCommandTarget));
                            if (ci.Visible)
                            {
                                if (needsSeparator)
                                {
                                    list.Add(new RuntimeModel(this, displayText: null));
                                    needsSeparator = false;
                                }
                                list.Add(new RuntimeModel(this, cmd));
                                runtimes++;
                            }
                        }
                    }
                }

                ToolbarView.PlatformSensitivity = runtimes > 1;
                ToolbarView.RuntimeModel        = list;
            } finally {
                ignoreRuntimeChangedCount--;
            }
        }
Ejemplo n.º 5
0
			public RuntimeModel (MainToolbarController controller, ExecutionTarget target, RuntimeModel parent) : this (controller, target)
			{
				if (parent == null)
					HasParent = false;
				else {
					HasParent = true;
					parent.HasChildren = true;
					parent.AddChild (this);
				}
			}
Ejemplo n.º 6
0
		void SelectActiveRuntime (RuntimeModel preferedRuntimeModel)
		{
			ignoreRuntimeChangedCount++;

			try {
				if (ToolbarView.RuntimeModel.Any ()) {
					if (startupProjects.Length > 1) {
						var multiProjectTarget = new MultiProjectExecutionTarget ();
						var multipleRuntime = new RuntimeModel (this, multiProjectTarget, false, null);
						foreach (var startupProject in startupProjects) {
							var runtimeModel = SelectActiveRuntime (startupProject.Item1, preferedRuntimeModel);
							multiProjectTarget.SetExecutionTarget (startupProject.Item1, runtimeModel.ExecutionTarget);
							multipleRuntime.AddChild (runtimeModel);
						}
						ToolbarView.ActiveRuntime = multipleRuntime;
						IdeApp.Workspace.ActiveExecutionTarget = multipleRuntime.ExecutionTarget;
					} else if (startupProjects.Length == 1) {
						var runtimeModel = SelectActiveRuntime (startupProjects.First ().Item1, preferedRuntimeModel);
						ToolbarView.ActiveRuntime = runtimeModel;
						IdeApp.Workspace.ActiveExecutionTarget = runtimeModel?.ExecutionTarget;
						UpdateBuildConfiguration ();
					} else {
						ToolbarView.ActiveRuntime = null;
						IdeApp.Workspace.ActiveExecutionTarget = null;
					}
				}
			} finally {
				ignoreRuntimeChangedCount--;
			}
		}
Ejemplo n.º 7
0
		void FillRuntimesForProject (List<RuntimeModel> list, SolutionItem project, ref int runtimes)
		{
			ExecutionTarget previous = null;

			foreach (var target in configurationMergers [project].GetTargetsForConfiguration (IdeApp.Workspace.ActiveConfigurationId, configurationMergers.Count < 2)) {
				if (target is ExecutionTargetGroup) {
					var devices = (ExecutionTargetGroup)target;

					if (previous != null)
						list.Add (new RuntimeModel (this, displayText: null));//Seperator

					foreach (var device in devices) {
						if (device is ExecutionTargetGroup) {
							var versions = (ExecutionTargetGroup)device;

							if (versions.Count > 1) {
								var parent = new RuntimeModel (this, device, true, project) {
									IsIndented = true,
								};
								list.Add (parent);

								foreach (var version in versions) {
									parent.AddChild (new RuntimeModel (this, version, false, project));
									runtimes++;
								}
							} else {
								list.Add (new RuntimeModel (this, versions [0], true, project) {
									IsIndented = true,
								});
								runtimes++;
							}
						} else {
							list.Add (new RuntimeModel (this, device, true, project) {
								IsIndented = true,
							});
							runtimes++;
						}
					}
				} else {
					if (previous is ExecutionTargetGroup) {
						list.Add (new RuntimeModel (this, displayText: null));//Seperator
					}

					list.Add (new RuntimeModel (this, target, true, project));
					runtimes++;
				}

				previous = target;
			}
		}
Ejemplo n.º 8
0
		void FillRuntimes ()
		{
			ignoreRuntimeChangedCount++;
			try {
				ToolbarView.RuntimeModel = Enumerable.Empty<IRuntimeModel> ();
				if (!IdeApp.Workspace.IsOpen || currentSolution == null)
					return;
				var list = new List<RuntimeModel> ();
				int runtimes = 0;
				if (currentSolution.StartupConfiguration is MultiItemSolutionRunConfiguration) {
					bool anyValid = false;
					foreach (var startConf in ((MultiItemSolutionRunConfiguration)currentSolution.StartupConfiguration).Items) {
						if (startConf?.SolutionItem == null)
							continue;

						// Check that the current startup project is enabled for the current configuration
						var solConf = currentSolution.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
						if (solConf == null || !solConf.BuildEnabledForItem (startConf.SolutionItem))
							continue;
						anyValid = true;
						var projectList = new List<RuntimeModel> ();
						FillRuntimesForProject (projectList, startConf.SolutionItem, ref runtimes);
						var parent = new RuntimeModel (this, startConf.SolutionItem.Name);
						parent.HasChildren = true;
						list.Add (parent);
						foreach (var p in projectList) {
							parent.AddChild (p);
						}
					}
					if (!anyValid)
						return;
				} else {
					var startConf = currentSolution.StartupConfiguration as SingleItemSolutionRunConfiguration;
					if (startConf == null || startConf.Item == null)
						return;

					// Check that the current startup project is enabled for the current configuration
					var solConf = currentSolution.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
					if (solConf == null || !solConf.BuildEnabledForItem (startConf.Item))
						return;
					FillRuntimesForProject (list, startConf.Item, ref runtimes);
				}


				var cmds = IdeApp.CommandService.CreateCommandEntrySet (TargetsMenuPath);
				if (cmds.Count > 0) {
					bool needsSeparator = runtimes > 0;
					foreach (CommandEntry ce in cmds) {
						if (ce.CommandId == Command.Separator) {
							needsSeparator = true;
							continue;
						}
						var cmd = ce.GetCommand (IdeApp.CommandService) as ActionCommand;
						if (cmd != null) {
							var ci = IdeApp.CommandService.GetCommandInfo (cmd.Id, new CommandTargetRoute (lastCommandTarget));
							if (ci.Visible) {
								if (needsSeparator) {
									list.Add (new RuntimeModel (this, displayText: null));
									needsSeparator = false;
								}
								list.Add (new RuntimeModel (this, cmd));
								runtimes++;
							}
						}
					}
				}

				ToolbarView.PlatformSensitivity = runtimes > 1;
				ToolbarView.RuntimeModel = list;
			} finally {
				ignoreRuntimeChangedCount--;
			}
		}