protected override void Update(CommandArrayInfo info)
		{
			if (IdeApp.Workspace.IsOpen) {
				info.Add("Default", "Default").Checked = !IsRoslynCompilerSet;
				info.Add("Roslyn", "Roslyn").Checked = IsRoslynCompilerSet;
			}
		}
        public static void GenerateExecutionModeCommands(SolutionEntityItem project, CanExecuteDelegate runCheckDelegate, CommandArrayInfo info)
        {
            CommandExecutionContext ctx = new CommandExecutionContext (project, runCheckDelegate);
            bool supportsParameterization = false;

            foreach (List<IExecutionMode> modes in GetExecutionModeCommands (ctx, false, true)) {
                foreach (IExecutionMode mode in modes) {
                    CommandInfo ci = info.Add (mode.Name, new CommandItem (ctx, mode));
                    if ((mode.ExecutionHandler is ParameterizedExecutionHandler) || ((mode is CustomExecutionMode) && ((CustomExecutionMode)mode).PromptForParameters)) {
                        // It will prompt parameters, so we need command to end with '..'.
                        // However, some commands may end with '...' already and we don't want to break
                        // already-translated strings by altering them
                        if (!ci.Text.EndsWith ("..."))
                            ci.Text += "...";
                        supportsParameterization = true;
                    } else {
                        // The parameters window will be shown if ctrl is pressed
                        ci.Description = GettextCatalog.GetString ("Run With: {0}", ci.Text);
                        if (SupportsParameterization (mode, ctx)) {
                            ci.Description += " - " + GettextCatalog.GetString ("Hold Control key to display the execution parameters dialog.");
                            supportsParameterization = true;
                        }
                    }
                }
                if (info.Count > 0)
                    info.AddSeparator ();
            }
            if (supportsParameterization) {
                info.AddSeparator ();
                info.Add (GettextCatalog.GetString ("Edit Custom Modes..."), new CommandItem (ctx, null));
            }
        }
		public void OnAddSpecialDirectoryUpdate (CommandArrayInfo info)
		{
			var proj = CurrentNode.DataItem as DotNetProject;
			if (proj == null)
				return;

			var asp = proj.GetFlavor<AspNetAppProjectFlavor> ();
			if (asp == null)
				return;

			List<string> dirs = new List<string> (asp.GetSpecialDirectories ());
			dirs.Sort ();
			List<FilePath> fullPaths = new List<FilePath> (dirs.Count);
			foreach (string s in dirs)
				fullPaths.Add (proj.BaseDirectory.Combine (s));
			RemoveDirsNotInProject (fullPaths, proj);

			if (fullPaths.Count == 0)
				return;

			foreach (string dir in dirs) {
				if (!fullPaths.Contains (proj.BaseDirectory.Combine (dir)))
					continue;
				info.Add (dir.Replace("_", "__"), dir);
			}
		}
Example #4
0
        protected override void Update(CommandArrayInfo info)
        {
            ResolverContextStack ctxt;
            var rr = Resolver.DResolverWrapper.ResolveHoveredCode(out ctxt);

            bool noRes = true;

            if (rr != null && rr.Length > 0)
            {
                res = rr[rr.Length - 1];

                n = DResolver.GetResultMember(res);

                if (n != null)
                {
                    noRes = false;
                    info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.GotoDeclaration), new Action(GotoDeclaration));
                    info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.FindReferences), new Action(FindReferences));

                    if (RenamingRefactoring.CanRename(n))
                    {
                        info.AddSeparator();
                        info.Add(IdeApp.CommandService.GetCommandInfo(EditCommands.Rename), new Action(RenameSymbol));
                    }
                }
            }

            if(noRes)
                info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.ImportSymbol), new Action(ImportSymbol));

            info.Add(IdeApp.CommandService.GetCommandInfo(Commands.OpenDDocumentation), new Action(OpenDDoc));
        }
		protected override void Update (CommandArrayInfo ainfo)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null || doc.FileName == FilePath.Null || doc.ParsedDocument == null)
				return;

			ResolveResult resolveResult;
			AstNode node;
			if (!ResolveAt (doc, out resolveResult, out node)) {
				var location = RefactoringService.GetCorrectResolveLocation (doc, doc.Editor.Caret.Location);
				resolveResult = GetHeuristicResult (doc, location, ref node);
				if (resolveResult == null)
					return;
			}
			var resolveMenu = new CommandInfoSet ();
			resolveMenu.Text = GettextCatalog.GetString ("Resolve");
			
			var possibleNamespaces = GetPossibleNamespaces (doc, node, ref resolveResult);

			foreach (var t in possibleNamespaces.Where (tp => tp.OnlyAddReference)) {
				var reference = t.Reference;
				var info = resolveMenu.CommandInfos.Add (
					t.GetImportText (),
					new System.Action (new AddImport (doc, resolveResult, null, reference, true, node).Run)
					);
				info.Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace;
			
			}


			bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
			if (addUsing) {
				foreach (var t in possibleNamespaces.Where (tp => tp.IsAccessibleWithGlobalUsing)) {
					string ns = t.Namespace;
					var reference = t.Reference;
					var info = resolveMenu.CommandInfos.Add (
						t.GetImportText (),
						new System.Action (new AddImport (doc, resolveResult, ns, reference, true, node).Run)
						);
					info.Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace;
				}
			}
			
			bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
			if (resolveDirect) {
				if (resolveMenu.CommandInfos.Count > 0)
					resolveMenu.CommandInfos.AddSeparator ();
				if (node is ObjectCreateExpression)
					node = ((ObjectCreateExpression)node).Type;
				foreach (var t in possibleNamespaces) {
					string ns = t.Namespace;
					var reference = t.Reference;
					resolveMenu.CommandInfos.Add (t.GetInsertNamespaceText (doc.Editor.GetTextBetween (node.StartLocation, node.EndLocation)), new System.Action (new AddImport (doc, resolveResult, ns, reference, false, node).Run));
				}
			}
			
			if (resolveMenu.CommandInfos.Count > 0)
				ainfo.Insert (0, resolveMenu);
		}
		protected override void Update (CommandArrayInfo info)
		{
			MonoDevelop.Ide.Gui.Document document;
			IList<FixableResult> results;
			if (!GetFixes (out document, out results))
				return;
			PopulateInfos (info, document, results);
		}
		protected void OnUpdateViewToolbar (CommandArrayInfo info)
		{
			foreach (IDockToolbar bar in Toolbars) {
				CommandInfo cmd = new CommandInfo (bar.Title);
				cmd.Checked = bar.Visible;
				cmd.Description = AddinManager.CurrentLocalizer.GetString ("Show toolbar '{0}'", bar.Title);
				info.Add (cmd, bar);
			}
		}
Example #8
0
		protected override void Update (CommandArrayInfo info)
		{
			string group;
			var lastListGroup = new Dictionary <CommandArrayInfo, string>();
			var descFormat = GettextCatalog.GetString ("Show {0}");
			foreach (Pad pad in IdeApp.Workbench.Pads.OrderBy (p => p.Group, StringComparer.InvariantCultureIgnoreCase)) {

				CommandInfo ci = new CommandInfo(pad.Title);
				ci.Icon = pad.Icon;
				ci.UseMarkup = true;
				ci.Description = string.Format (descFormat, pad.Title);

				ActionCommand cmd = IdeApp.CommandService.GetActionCommand ("Pad|" + pad.Id);
				if (cmd != null) ci.AccelKey = cmd.AccelKey; 

				CommandArrayInfo list = info;
				if (pad.Categories != null) {
					for (int j = 0; j < pad.Categories.Length; j++) {
						bool found = false;
						for (int k = list.Count - 1; k >= 0; k--) {
							if (list[k].Text == pad.Categories[j] && list[k] is CommandInfoSet) {
								list = ((CommandInfoSet)list[k]).CommandInfos;
								found = true;
								break;
							}
						}
						if (!found) {
							CommandInfoSet set = new CommandInfoSet();
							set.Text = pad.Categories[j];
							set.Description = string.Format (descFormat, set.Text);
							list.Add (set);
							list = set.CommandInfos;
						}
					}
				}

				int atIndex = 0;
				for (int j = list.Count - 1; j >= 0; j--) {
					if (!(list [j] is CommandInfoSet)) {
						atIndex = j + 1;
						break;
					}
				}

				list.Insert (atIndex, ci, pad);
				lastListGroup.TryGetValue (list, out group);
				if (group != pad.Group) {
					lastListGroup [list] = pad.Group;
					if (atIndex > 0) {
						CommandInfo sep = new CommandInfo ("-");
						sep.IsArraySeparator = true;
						list.Insert (atIndex, sep, null);
					}
				}
			}
		}
        protected override void Update(CommandArrayInfo info)
        {
            if (caps.Update ()) {
                if (caps.resultResolutionAttempt != DResolver.NodeResolutionAttempt.RawSymbolLookup) {
                    var refactoringMenu = new CommandInfoSet { Text = GettextCatalog.GetString ("Refactoring") };

                    if(caps.lastResults.Any(t => t is DSymbol && DRenameRefactoring.CanRenameNode ((t as DSymbol).Definition)))
                        refactoringMenu.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (EditCommands.Rename), new Action (caps.RenameSymbol));

                    if (refactoringMenu.CommandInfos.Count > 0)
                        info.Add (refactoringMenu);

                    info.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.GotoDeclaration), new Action (caps.GotoDeclaration));
                    info.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindReferences), new Action (() => caps.FindReferences (false)));

                    if (caps.lastResults.Any (t => t is DSymbol && (t as DSymbol).Definition.Parent is DClassLike))
                        info.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindAllReferences), new Action (() => caps.FindReferences (true)));

                    if (caps.lastResults.Any (t => {
                        var ds = DResolver.StripMemberSymbols (t);
                        return ds is ClassType || ds is InterfaceType;
                    }))
                        info.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindDerivedClasses), new Action (caps.FindDerivedClasses));
                } else {
                    var importSymbolMenu = new CommandInfoSet { Text = GettextCatalog.GetString ("Resolve") };

                    var alreadyAddedItems = new List<INode> ();
                    foreach (var t in caps.lastResults) {
                        var ds = t as DSymbol;
                        if (ds == null)
                            continue;
                        var m = ds.Definition.NodeRoot as DModule;
                        if (m != null && !alreadyAddedItems.Contains (m)) {
                            alreadyAddedItems.Add (m);
                            importSymbolMenu.CommandInfos.Add (new CommandInfo {
                                Text = "import " + AbstractNode.GetNodePath (m, true) + ";",
                                Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace
                            }, new object[]{ "a", ds.Definition });
                        }
                    }

                    if (importSymbolMenu.CommandInfos.Count > 0) {
                        // To explicitly show the Ctrl+Alt+Space hint.
                        importSymbolMenu.CommandInfos.AddSeparator ();
                        importSymbolMenu.CommandInfos.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.ImportSymbol), new Action (caps.TryImportMissingSymbol));

                        info.Add (importSymbolMenu);
                    }
                }
            }

            if(SortImportsCommandHandler.CanSortImports(caps.lastDoc))
                info.Add (IdeApp.CommandService.GetCommandInfo (RefactoryCommands.SortImports), new Action(()=>SortImportsCommandHandler.SortImports(caps.lastDoc)));
        }
Example #10
0
		protected override void Update (CommandArrayInfo info)
		{
			GitRepository repo = Repository;
			if (repo != null) {
				string currentBranch = repo.GetCurrentBranch ();
				foreach (Branch branch in repo.GetBranches ()) {
					CommandInfo ci = info.Add (branch.Name, branch.Name);
					if (branch.Name == currentBranch)
						ci.Checked = true;
				}
			}
		}
		protected override void Update (CommandArrayInfo ainfo)
		{
			CommandInfo info = ainfo.Add (GettextCatalog.GetString ("_Errors & Warnings"), new Action (delegate {
				MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles = MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings;
			}));
			info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles == MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings;
			
			info = ainfo.Add (GettextCatalog.GetString ("E_rrors only"), new Action (delegate {
				MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles = MonoDevelop.Ide.ShowMessageBubbles.ForErrors;
			}));
			info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles == MonoDevelop.Ide.ShowMessageBubbles.ForErrors;
		}
Example #12
0
		protected override void Update (CommandArrayInfo info)
		{
			IWorkspaceObject wob = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem;
			GitRepository repo = VersionControlService.GetRepository (wob) as GitRepository;
			if (repo != null) {
				string currentBranch = repo.GetCurrentBranch ();
				foreach (string branch in repo.GetBranches ()) {
					CommandInfo ci = info.Add (branch, branch);
					if (branch == currentBranch)
						ci.Checked = true;
				}
			}
		}
		protected override void Update (CommandArrayInfo info)
		{
			foreach (ExternalTools.ExternalTool externalTool in ExternalTools.ExternalToolService.Tools) {
				//Create CommandInfo object
				CommandInfo commandInfo = new CommandInfo ();
				commandInfo.Text = externalTool.MenuCommand;
				commandInfo.Description = GettextCatalog.GetString ("Start tool") + " " + string.Join (string.Empty, externalTool.MenuCommand.Split('&'));

				//Add menu item
				info.Add (commandInfo, externalTool);

			}
		}
		protected override void Update (CommandArrayInfo ainfo)
		{
			ainfo.Add (NavigationBar.HideStatusBox ? GettextCatalog.GetString ("_Show Caret Panel") : GettextCatalog.GetString ("_Hide Caret Panel"), new System.Action (delegate {
				IdeApp.Workbench.StatusBar.ClearCaretState ();
				NavigationBar.HideStatusBox = !NavigationBar.HideStatusBox;
			}));
			
			if (!NavigationBar.HideStatusBox) {
				ainfo.Add (StatusBox.ShowRealColumns ? GettextCatalog.GetString ("_Show logical caret position") : GettextCatalog.GetString ("_Show visual caret position") , new System.Action (delegate {
					StatusBox.ShowRealColumns = !StatusBox.ShowRealColumns;
				}));
			}
		}
		protected override void Update (CommandArrayInfo info)
		{
			if (DbFactoryService.DbFactoryCount > 0) {
				foreach (IDbFactory fac in DbFactoryService.DbFactories) {
					CommandInfo cmd = new CommandInfo (fac.Name);
					cmd.Icon = "md-db-database";
					info.Add (cmd, fac);
				}
			} else {
				CommandInfo cmd = new CommandInfo (AddinCatalog.GetString ("No database providers detected."));
				cmd.Enabled = false;
				info.Add (cmd, null);
			}
		}		
		protected override void Update (CommandArrayInfo ainfo)
		{
			CommandInfo info = ainfo.Add (GettextCatalog.GetString ("E_rrors"), new Action (delegate {
				IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrors;
				IdeApp.Preferences.DefaultHideMessageBubbles.Value = false;
			}));
			info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles.Value == ShowMessageBubbles.ForErrors;

			info = ainfo.Add (GettextCatalog.GetString ("_Errors and Warnings"), new Action (delegate {
				IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrorsAndWarnings;
				IdeApp.Preferences.DefaultHideMessageBubbles.Value = false;
			}));
			info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrorsAndWarnings;
		}
		protected override void Update (CommandArrayInfo info)
		{
			var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject ();
			if (proj == null || !MonoDroidFramework.HasAndroidJavaSdks)
				return;
			
			var conf = (MonoDroidProjectConfiguration) proj.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
			var projSetting = proj.GetDeviceTarget (conf);
			
			foreach (var st in MonoDroidFramework.DeviceManager.Devices) {
				var i = info.Add (st.ID, st);
				if (projSetting != null && projSetting.Equals (st))
					i.Checked  = true;
			}
		}
        protected override void Update(CommandArrayInfo info)
        {
            var project = IdeApp.ProjectOperations.CurrentSelectedProject as DnxProject;
            if (project == null) {
                info.Bypass = true;
                return;
            }

            foreach (DnxFramework framework in project.GetFrameworks ()) {
                CommandInfo item = info.Add (framework.FriendlyName, framework);
                if (framework.Name == project.CurrentFramework) {
                    item.Checked = true;
                }
            }
        }
		public void OnAddSpecialDirectoryUpdate (CommandArrayInfo info)
		{
			AspNetAppProject proj = CurrentNode.DataItem as AspNetAppProject;
			if (proj == null)
				return;
			
			List<string> dirs = new List<string> (proj.GetSpecialDirectories ());
			dirs.Sort ();
			List<FilePath> fullPaths = new List<FilePath> (dirs.Count);
			foreach (string s in dirs)
				fullPaths.Add (proj.BaseDirectory.Combine (s));
			RemoveDirsNotInProject (fullPaths, proj);
			
			foreach (string dir in dirs) {
				CommandInfo cmd = info.Add (dir.Replace("_", "__"), dir);
				cmd.Enabled = fullPaths.Contains (proj.BaseDirectory.Combine (dir));
			}
		}
		protected override void Update (CommandArrayInfo info)
		{
			for (int i = 0; i < IdeApp.Workbench.Pads.Count; i++) {
				Pad pad = IdeApp.Workbench.Pads[i];

				CommandInfo ci = new CommandInfo(pad.Title);
				ci.Icon = pad.Icon;
				ci.UseMarkup = true;
				ci.Description = GettextCatalog.GetString ("Show {0}", pad.Title);
				ci.Checked = pad.Visible;

				ActionCommand cmd = IdeApp.CommandService.GetActionCommand ("Pad|" + pad.Id);
				if (cmd != null) ci.AccelKey = cmd.AccelKey; 

				CommandArrayInfo list = info;
				if (pad.Categories != null) {
					for (int j = 0; j < pad.Categories.Length; j++) {
						bool found = false;
						for (int k = list.Count - 1; k >= 0; k--) {
							if (list[k].Text == pad.Categories[j] && list[k] is CommandInfoSet) {
								list = ((CommandInfoSet)list[k]).CommandInfos;
								found = true;
								break;
							}
						}
						if (!found) {
							CommandInfoSet set = new CommandInfoSet();
							set.Text = pad.Categories[j];
							set.Description = GettextCatalog.GetString ("Show {0}", set.Text);
							list.Add (set);
							list = set.CommandInfos;
						}
					}
				}
				for (int j = list.Count - 1; j >= 0; j--) {
					if (!(list[j] is CommandInfoSet)) {
						list.Insert (j + 1, ci, pad);
						pad = null;
						break;
					}
				}
				if (pad != null) list.Insert (0, ci, pad); 
			}
		}
		protected override void Update (CommandArrayInfo info)
		{
			int currentIndex;
			IList<NavigationHistoryItem> points = NavigationHistoryService.GetNavigationList (15, out currentIndex);
			
			if (points.Count < 1) {
				Document doc = IdeApp.Workbench.ActiveDocument;
				if (doc != null) {
					CommandInfo item = info.Add (doc.Window.Title, null);
					item.Checked = true;
				}
				return;
			}
			
			for (int i = points.Count - 1; i >= 0; i--) {
				CommandInfo item = info.Add (points[i].DisplayName, points[i]);
				item.Checked = (i == currentIndex);
			}
		}
Example #22
0
		protected override void Update (CommandArrayInfo info)
		{
			var repo = Repository;
			if (repo == null)
				return;

			IWorkspaceObject wob = IdeApp.ProjectOperations.CurrentSelectedItem as IWorkspaceObject;
			if (wob == null)
				return;
			if (((wob is WorkspaceItem) && ((WorkspaceItem)wob).ParentWorkspace == null) ||
			    (wob.BaseDirectory.CanonicalPath == repo.RootPath.CanonicalPath))
			{
				string currentBranch = repo.GetCurrentBranch ();
				foreach (Branch branch in repo.GetBranches ()) {
					CommandInfo ci = info.Add (branch.Name, branch.Name);
					if (branch.Name == currentBranch)
						ci.Checked = true;
				}
			}
		}
		protected override void Update (CommandArrayInfo ainfo)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null || doc.FileName == FilePath.Null || doc.ParsedDocument == null)
				return;

			ResolveResult resolveResult;
			AstNode node;
			if (!ResolveAt (doc, out resolveResult, out node))
				return;

			var resolveMenu = new CommandInfoSet ();
			resolveMenu.Text = GettextCatalog.GetString ("Resolve");
			
			var possibleNamespaces = GetPossibleNamespaces (doc, node, resolveResult);

			bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
			if (addUsing) {
				foreach (string ns in possibleNamespaces) {
					var info = resolveMenu.CommandInfos.Add (
						string.Format ("using {0};", ns),
						new System.Action (new AddImport (doc, resolveResult, ns, true).Run)
					);
					info.Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace;
				}
			}
			
			bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
			if (resolveDirect) {
				if (resolveMenu.CommandInfos.Count > 0)
					resolveMenu.CommandInfos.AddSeparator ();
				if (node is ObjectCreateExpression)
					node = ((ObjectCreateExpression)node).Type;
				foreach (string ns in possibleNamespaces) {
					resolveMenu.CommandInfos.Add (string.Format ("{0}", ns + "." + doc.Editor.GetTextBetween (node.StartLocation, node.EndLocation)), new System.Action (new AddImport (doc, resolveResult, ns, false).Run));
				}
			}
			
			if (resolveMenu.CommandInfos.Count > 0)
				ainfo.Insert (0, resolveMenu);
		}
Example #24
0
		protected override void Update (CommandArrayInfo info)
		{
			return;
			//FIXME: figure out how to poll the device list sanely
			/*
			var proj = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject ();
			if (proj == null || !MonoDroidFramework.HasAndroidJavaSdks)
				return;
			
			var conf = (MonoDroidProjectConfiguration) proj.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
			var projSetting = proj.GetDeviceTarget (conf);
			
			var def = info.Add ("Default", null);
			if (projSetting == null)
				def.Checked  = true;
			
			foreach (var st in MonoDroidFramework.DeviceManager.Devices) {
				var i = info.Add (st.ToString (), st);
				if (projSetting != null && projSetting.Equals (st))
					i.Checked  = true;
			}*/
		}
		protected override void Update (CommandArrayInfo ainfo)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null || doc.FileName == FilePath.Null || doc.ParsedDocument == null)
				return;
			var caretOffset = doc.Editor.Caret.Offset;
			
			DomRegion region;
			var resolveResult = doc.GetLanguageItem (caretOffset, out region);
			if (resolveResult == null)
				return;

			var resolveMenu = new CommandInfoSet ();
			resolveMenu.Text = GettextCatalog.GetString ("Resolve");
			
			var possibleNamespaces = GetPossibleNamespaces (doc, resolveResult);

			bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
			if (addUsing) {
				foreach (string ns in possibleNamespaces) {
					var info = resolveMenu.CommandInfos.Add (GettextCatalog.GetString ("Import Namespace {0}", ns), new System.Action (new AddImport (doc, resolveResult, ns, true).Run));
					info.Icon = MonoDevelop.Ide.Gui.Stock.AddNamespace;
				}
			}
			
			bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
			if (resolveDirect) {
				if (resolveMenu.CommandInfos.Count > 0)
					resolveMenu.CommandInfos.AddSeparator ();
				
				foreach (string ns in possibleNamespaces) {
					resolveMenu.CommandInfos.Add (GettextCatalog.GetString ("Use {0}", ns + "." + doc.Editor.GetTextBetween (region.Begin, region.End)), new System.Action (new AddImport (doc, resolveResult, ns, false).Run));
				}
			}
			
			if (resolveMenu.CommandInfos.Count > 0)
				ainfo.Insert (0, resolveMenu);
		}
Example #26
0
		protected override void Update (CommandArrayInfo info)
		{
			var proj = IdeApp.ProjectOperations.CurrentSelectedProject as IPhoneProject;
			if (proj == null)
				return;
			
			var workspaceConfig = IdeApp.Workspace.ActiveConfigurationId;
			var conf = proj.GetConfiguration (new SolutionConfigurationSelector (workspaceConfig)) as IPhoneProjectConfiguration;
			if (conf == null || conf.Platform != IPhoneProject.PLAT_SIM)
				return;
			
			var projSetting = proj.GetSimulatorTarget (conf);
			
			var def = info.Add ("Default", null);
			if (projSetting == null)
				def.Checked  = true;
			
			foreach (var st in IPhoneFramework.GetSimulatorTargets (IPhoneSdkVersion.Parse (conf.MtouchMinimumOSVersion), proj.SupportedDevices)) {
				var i = info.Add (st.ToString (), st);
				if (projSetting != null && projSetting.Equals (st))
					i.Checked  = true;
			}
		}
		protected override void Update (CommandArrayInfo ainfo)
		{
			MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.ActiveDocument;
			if (doc != null) {
				SourceEditorView view = IdeApp.Workbench.ActiveDocument.GetContent <SourceEditorView>();
				if (view != null) {
					DocumentLocation location = view.TextEditor.Caret.Location;
					if (location.IsEmpty)
						return;
					LineSegment line = view.Document.GetLine (location.Line);
					if (line == null || line.Markers == null)
						return;
					foreach (TextMarker marker in line.Markers) {
						UrlMarker urlMarker = marker as UrlMarker;
						if (urlMarker != null) {
							if (urlMarker.StartColumn <= location.Column && location.Column < urlMarker.EndColumn) {
								ainfo.Add (urlMarker.UrlType == UrlType.Email ? GettextCatalog.GetString ("_Write an e-mail to...") : GettextCatalog.GetString ("_Open URL..."), urlMarker);
								ainfo.AddSeparator ();
							}
						}
					}
				}
			}
		}
		protected override void Update (CommandArrayInfo info)
		{
			if (ProfilingService.ProfilerCount > 0) {
				foreach (IProfiler prof in ProfilingService.Profilers) {
					CommandInfo cmd = new CommandInfo (GettextCatalog.GetString (prof.Name));
					cmd.UseMarkup = true;
					cmd.Icon = prof.IconString;
					if (prof.IsSupported) {
						if (IdeApp.Workspace.IsOpen)
							cmd.Enabled = IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted;
						else
							cmd.Enabled = (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.IsBuildTarget);
					} else {
						cmd.Enabled = false;
					}
					
					info.Add (cmd, prof);
				}
			} else {
				CommandInfo cmd = new CommandInfo (GettextCatalog.GetString ("No profilers detected."));
				cmd.Enabled = false;
				info.Add (cmd, null);
			}
		}		
Example #29
0
		protected override void Update (CommandArrayInfo info)
		{
			var projects = DesktopService.RecentFiles.GetProjects ();
			if (projects.Count == 0)
				return;
				
			int i = 0;
			foreach (var ri in projects) {
				//getting the icon requires probing the file, so handle IO errors
				IconId icon;
				try {
					if (!File.Exists (ri.FileName))
						continue;
					icon = IdeApp.Services.ProjectService.FileFormats.GetFileFormats
						(ri.FileName, typeof(Solution)).Length > 0? "md-solution": "md-workspace";
				}
				catch (UnauthorizedAccessException exAccess) {
					LoggingService.LogWarning ("Error building recent solutions list (Permissions)", exAccess);
					continue;					
				}
				catch (IOException ex) {
					LoggingService.LogWarning ("Error building recent solutions list", ex);
					continue;
				}
				
				string acceleratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : "";
				string str = GettextCatalog.GetString ("Load solution {0}", ri.ToString ());
				if (IdeApp.Workspace.IsOpen)
					str += " - " + GettextCatalog.GetString ("Hold Control to open in current workspace.");
				
				var cmd = new CommandInfo (acceleratorKeyPrefix + ri.DisplayName.Replace ("_", "__")) {
					Icon = icon,
					Description = str,
				};
				
				info.Add (cmd, ri.FileName);
				i++;
			}
		}
Example #30
0
		protected override void Update (CommandArrayInfo info)
		{
			var files = DesktopService.RecentFiles.GetFiles ();
			if (files.Count == 0)
				return;
			
			int i = 0;
			foreach (var ri in files) {
				string acceleratorKeyPrefix = i < 10 ? "_" + ((i + 1) % 10).ToString() + " " : "";
				var cmd = new CommandInfo (acceleratorKeyPrefix + ri.DisplayName.Replace ("_", "__")) {
					Description = GettextCatalog.GetString ("Open {0}", ri.FileName)
				};
				Gdk.Pixbuf icon = DesktopService.GetPixbufForFile (ri.FileName, IconSize.Menu);
				#pragma warning disable 618
				if (icon != null)
					cmd.Icon = ImageService.GetStockId (icon, IconSize.Menu);
				#pragma warning restore 618
				info.Add (cmd, ri.FileName);
				i++;
			}
		}
Example #31
0
 protected virtual Task UpdateAsync(CommandArrayInfo info, CancellationToken cancelToken)
 {
     return(null);
 }
Example #32
0
 internal void InternalUpdate(CommandArrayInfo info)
 {
     Update(info);
 }
Example #33
0
 protected virtual void Update(CommandArrayInfo info)
 {
 }
Example #34
0
 public CommandInfoSet()
 {
     commandInfos = new CommandArrayInfo(this);
 }
 void ICommandArrayUpdateHandler.CommandUpdate(object target, CommandArrayInfo cinfo)
 {
     CommandUpdate(target, cinfo);
 }
 /// <summary>
 /// Updates the status of the command
 /// </summary>
 /// <param name='target'>
 /// Object that implements the command handler
 /// </param>
 /// <param name='cinfo'>
 /// Command info to be updated
 /// </param>
 /// <remarks>
 /// The default implementation of this method calls the update handler implemented
 /// in the target object. A custom implementation of this method can call
 /// base.CommandUpdate at any point to get the result of the default implementation.
 /// </remarks>
 protected virtual void CommandUpdate(object target, CommandArrayInfo cinfo)
 {
     nextArray.CommandUpdate(target, cinfo);
 }