/// <summary>
    /// Updates the text and visibility of each command with this attribute.
    /// </summary>
    /// <param name="target">Target node handler.</param>
    /// <param name="cinfo">Command info.</param>
    protected override void CommandUpdate(object target, CommandInfo cinfo)
    {
      if (cinfo != null)
      {
        cinfo.Visible = true;
        StyleCopNodeCommandHandler.CancelStypeCopRun = false;

        base.CommandUpdate(target, cinfo);

        if (IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
        {
          // Set the default StyleCop run text.
          if (string.IsNullOrEmpty(cinfo.Text))
          {
            cinfo.Text = StaticStringResources.StyleCopRunText;
          }
        }
        else
        {
          if (IdeApp.ProjectOperations.IsStyleCopRunning())
          {
            cinfo.Text = StaticStringResources.StyleCopCancelText;
            StyleCopNodeCommandHandler.CancelStypeCopRun = true;
          }
        }
      }
    }
Exemplo n.º 2
0
		public void UpdateCommandInfo (CommandInfo ci)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null || doc.FileName == FilePath.Null)
				return;
			ci.Enabled = doc.ParsedDocument != null && doc.ParsedDocument.GetAst<SemanticModel> () != null;
		}
		public void RenameCommand_Update(CommandInfo ci)
		{
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return;

			var editor = doc.GetContent<ITextBuffer>();
			if (editor == null)
				return;

			var dom = doc.Dom;

			ResolveResult result;
			INode item;
			CurrentRefactoryOperationsHandler.GetItem(dom, doc, editor, out result, out item);

			var options = new RefactoringOptions()
			{
				Document = doc,
				Dom = dom,
				ResolveResult = result,
				SelectedItem = item is InstantiatedType ? ((InstantiatedType)item).UninstantiatedType : item
			};

			// If not a valid operation, allow command to be handled by others
			if (!new RenameRefactoring().IsValid(options))
				ci.Bypass = true;
		}
		public void OnUpdateExclude (CommandInfo cinfo)
		{
			bool anyChecked = false;
			bool allChecked = true;
			bool anyEnabled = false;
			bool allEnabled = true;
			
			foreach (ITreeNavigator node in CurrentNodes) {
				ProjectFile file = (ProjectFile) node.DataItem;
				if (file.Project != null) {
					MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
					if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) {
						anyEnabled = true;
						if (!data.IsFileExcluded (file.FilePath)) {
							anyChecked = true;
						} else {
							allChecked = false;
						}
					} else {
						allEnabled = false;
					}
				}
			}
				
			cinfo.Visible = anyEnabled;
			cinfo.Enabled = anyEnabled && allEnabled;
			cinfo.Checked = anyChecked;
			cinfo.CheckedInconsistent = anyChecked && !allChecked;
		}
Exemplo n.º 5
0
		protected override void Update (CommandInfo info)
		{
			if (IdeApp.Workspace.IsOpen)
				info.Enabled = IdeApp.ProjectOperations.CurrentSelectedSolution != null && IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted;
			else
				info.Enabled = (IdeApp.Workbench.ActiveDocument != null && IdeApp.Workbench.ActiveDocument.IsBuildTarget);
		}
		public void Insert (int index, CommandInfo info, object dataItem)
		{
			info.DataItem = dataItem;
			if (info.Text == null) info.Text = defaultInfo.Text;
			if (info.Icon.IsNull) info.Icon = defaultInfo.Icon;
			list.Insert (index, info);
		}
Exemplo n.º 7
0
        protected override void Update(CommandInfo info)
        {
            Console.WriteLine (info);

            var doc = IdeApp.Workbench.ActiveDocument;
            info.Enabled = doc != null && doc.GetContent<ITextEditorDataProvider> () != null;
        }
Exemplo n.º 8
0
		protected override void Update (CommandInfo info)
		{
			info.Enabled = IdeApp.Workbench.ActiveDocument != null && 
				IdeApp.Workbench.ActiveDocument.Editor != null &&
				IdeApp.Workbench.ActiveDocument.Editor.Document.MimeType == "text/x-csharp";
			base.Update (info);
		}
Exemplo n.º 9
0
 public CommandResult(Command cmd, CommandInfo ci, CommandTargetRoute route, string match, string matchedString, int rank)
     : base(match, matchedString, rank)
 {
     this.ci = ci;
     command = cmd;
     this.route = route;
 }
Exemplo n.º 10
0
 protected override void Update (CommandInfo info)
 {
     MonoDevelop.Core.LoggingService.LogError ("*********UPDATE");
     info.Enabled = true;
     //MonoDevelop.Ide.Gui.Document doc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument;
     //info.Enabled = doc != null && doc.GetContent<MonoDevelop.Ide.Gui.Content.IEditableTextBuffer> () != null;
  }
Exemplo n.º 11
0
		protected override void Update (CommandInfo info)
		{
			//if no open window or only one
			if (IdeApp.Workbench.Documents.Count < 2) {
				info.Enabled = false;
			}
		}
        protected override void Update(CommandInfo info)
        {
            Document doc = IdeApp.Workbench.ActiveDocument;
            var editor = doc.GetContent<ITextEditorDataProvider> ();
            info.Enabled = false;
            if (doc != null
                && editor != null
                && doc.Project is MonoDroidProject)
            {
                var data = editor.GetTextEditorData ();

                var loc = new DocumentLocation (data.Caret.Line, data.Caret.Column);

                ResolveResult result;
                AstNode node;
                if (!doc.TryResolveAt (loc, out result, out node)) {
                    return;
                }

                var memberResolve = result as MemberResolveResult;
                if (memberResolve == null) {
                    return;
                }

                info.Enabled = ResourceHelper.IsResourcesMemberField(memberResolve);
            }
        }
        protected override void Update(CommandInfo info)
        {
            try
            {
                /* Pregunta si algun projecto se encuentra abierto para habilitar la opcion */
                if(IdeApp.Workspace.IsOpen)
                {
                    /* Obtiene el proyecto actualmente seleccionado */
                    //MonoDevelop.Projects.Project startupProject = (MonoDevelop.Projects.Project)IdeApp.Workspace.GetAllSolutions()[0].StartupItem;
                    MonoDevelop.Projects.Project currentProject = IdeApp.ProjectOperations.CurrentSelectedProject;

                    /* Si el tipo de proyecto es un proyecto web, habilitamos la opcion en el menu Project */
                    if(currentProject != null && currentProject.ProjectType == "AspNetApp")
                        info.Enabled = true;
                    else
                        info.Enabled = false;
                }
                else
                    info.Enabled = false;
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        protected override void Update(CommandInfo info)
        {
            //info.Enabled = IsSupportedFile;
            info.Text = _presenter.IsConnected ? "Disconnect" : "Connect";

            Console.WriteLine (info.Command.Id);
        }
		void ICommandMenuItem.SetUpdateInfo (CommandInfo cmdInfo, object initialTarget)
		{
			isArrayItem = true;
			arrayDataItem = cmdInfo.DataItem;
			this.initialTarget = initialTarget;
			Update (cmdInfo);
		}
Exemplo n.º 16
0
		void Update (CommandInfo cmdInfo)
		{
			updating = true;
			if (Active != cmdInfo.Checked)
				Active = cmdInfo.Checked;
			updating = false;
			
			//same as CommandToolButton
			//only update each if changed, else we grab focus from tooltips during the command scane
			if (lastDesc != cmdInfo.Description) {
				string toolTip;
				if (string.IsNullOrEmpty (cmdInfo.AccelKey)) {
					toolTip = cmdInfo.Description;
				} else {
					toolTip = cmdInfo.Description + " (" + KeyBindingManager.BindingToDisplayLabel (cmdInfo.AccelKey, false) + ")";
				}
				TooltipText = toolTip;
				lastDesc = cmdInfo.Description;
			}
			
			if (Label != cmdInfo.Text)
				Label = cmdInfo.Text;
			if (cmdInfo.Icon != stockId) {
				stockId = cmdInfo.Icon;
				this.IconWidget = new Gtk.Image (cmdInfo.Icon, Gtk.IconSize.Menu);
			}
			if (cmdInfo.Enabled != Sensitive)
				Sensitive = cmdInfo.Enabled;
			if (cmdInfo.Visible != Visible)
				Visible = cmdInfo.Visible;
			if (cmdInfo.Icon.IsNull)
				IsImportant = true;
		}
     protected void UpdateCheckoutFile(CommandInfo commandInfo)
     {
         if (VersionControlService.IsGloballyDisabled)
         {
             commandInfo.Visible = false;
             return;
         }
         foreach (var item in GetItems(false))
         {
             if (item.IsDirectory)
             {
                 commandInfo.Visible = false;
                 return;
             }
 
             var repo = item.Repository as TFSRepository;
             if (repo == null)
             {
                 commandInfo.Visible = false;
                 return;
             }
             if (!item.VersionInfo.IsVersioned || item.VersionInfo.HasLocalChanges || item.VersionInfo.Status.HasFlag(VersionStatus.Locked))
             {
                 commandInfo.Visible = false;
                 return;
             }
         }
     }
Exemplo n.º 18
0
		void Update (CommandInfo cmdInfo)
		{
			if (lastDesc != cmdInfo.Description) {
				string toolTip;
				if (string.IsNullOrEmpty (cmdInfo.AccelKey)) {
					toolTip = cmdInfo.Description;
				} else {
					toolTip = cmdInfo.Description + " (" + KeyBindingManager.BindingToDisplayLabel (cmdInfo.AccelKey, false) + ")";
				}
				TooltipText = toolTip;
				lastDesc = cmdInfo.Description;
			}
			
			if (Label != cmdInfo.Text)
				Label = cmdInfo.Text;
			if (cmdInfo.Icon != stockId) {
				stockId = cmdInfo.Icon;
				this.IconWidget = new Gtk.Image (cmdInfo.Icon, Gtk.IconSize.Menu);
			}
			if (cmdInfo.Enabled != Sensitive)
				Sensitive = cmdInfo.Enabled;
			if (cmdInfo.Visible != Visible)
				Visible = cmdInfo.Visible;
			if (cmdInfo.Icon.IsNull)
				IsImportant = true;
		}
		public void Add (CommandInfo info, object dataItem)
		{
			info.DataItem = dataItem;
			if (info.Text == null) info.Text = defaultInfo.Text;
			if (info.Icon.IsNull) info.Icon = defaultInfo.Icon;
			list.Add (info);
		}
Exemplo n.º 20
0
		protected override void Update (CommandInfo info)
		{
			MonoDevelop.Ide.Gui.Document document;
			IList<FixableResult> results;
			info.Enabled = FixOperationsHandler.GetFixes (out document, out results)
			    && results.Any (r => FixOperationsHandler.GetActions (document, r).Any ());
		}
        protected override void Update(CommandInfo info)
        {
            DotNetProject project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject;
            bool isDotNetProject = project != null;

            info.Enabled = isDotNetProject;
            info.Bypass = !isDotNetProject;
        }
Exemplo n.º 22
0
		protected override void Update (CommandInfo info)
		{
			base.Update (info);

			var doc = IdeApp.Workbench.ActiveDocument;

			info.Enabled = doc != null && doc.Editor != null && !string.IsNullOrWhiteSpace (doc.Editor.SelectedText);
		}
Exemplo n.º 23
0
		protected override void Update (CommandInfo info)
		{
			IWorkspaceObject wob = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem;
			GitRepository repo = null;
			if (wob != null)
				repo = VersionControlService.GetRepository (wob) as GitRepository;
			info.Visible = repo != null;
		}
Exemplo n.º 24
0
		protected override void Update (CommandInfo info)
		{
			info.Enabled = NSWorkspace.SharedWorkspace.RunningApplications.Any (a =>
				!a.Hidden &&
				a.ActivationPolicy == NSApplicationActivationPolicy.Regular &&
				a.ProcessIdentifier != NSRunningApplication.CurrentApplication.ProcessIdentifier
			);
		}
Exemplo n.º 25
0
		protected override void Update (CommandInfo info)
		{
			base.Update (info);

			var doc = IdeApp.Workbench.ActiveDocument;

			info.Enabled = doc != null;
		}
		public void UpdateOpenServicesGalleryCommand (CommandInfo info)
		{
			if (this.CurrentNode != null) {
				info.Visible = info.Enabled = this.Project.GetConnectedServicesBinding ().HasSupportedServices;
			} else {
				info.Visible = info.Enabled = false;
			}
		}
Exemplo n.º 27
0
		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);
			}
		}
Exemplo n.º 28
0
 protected override void Update(CommandInfo info)
 {
     Document activeDocument = IdeApp.Workbench.ActiveDocument;
     if (activeDocument != null && activeDocument.Content is SourceEditorDisplayBindingWrapper)
     {
         string selectedText = ((SourceEditor) ((SourceEditorDisplayBindingWrapper)activeDocument.Content).Editor).Buffer.GetSelectedText();
         info.Enabled = (selectedText != null && selectedText.Length > 0);
     }
 }
 protected override void Update(CommandInfo info)
 {
     if (IsDotNetProjectSelected () || IsDotNetSolutionSelected()) {
         info.Bypass = false;
     } else {
         info.Enabled = false;
         info.Bypass = true;
     }
 }
Exemplo n.º 30
0
		public TitleMenuItem (MonoDevelop.Components.Commands.CommandManager manager, CommandEntry entry, CommandInfo commandArrayInfo = null, CommandSource commandSource = CommandSource.MainMenu, object initialCommandTarget = null, Menu menu = null)
		{
			this.manager = manager;
			this.initialCommandTarget = initialCommandTarget;
			this.commandSource = commandSource;
			this.commandArrayInfo = commandArrayInfo;

			this.menu = menu;
			menuEntry = entry;
			menuEntrySet = entry as CommandEntrySet;
			menuLinkEntry = entry as LinkCommandEntry;

			if (commandArrayInfo != null) {
				Header = commandArrayInfo.Text;

				var commandArrayInfoSet = commandArrayInfo as CommandInfoSet;
				if (commandArrayInfoSet != null) {
					foreach (var item in commandArrayInfoSet.CommandInfos) {
						if (item.IsArraySeparator)
							Items.Add (new Separator { UseLayoutRounding = true, });
						else
							Items.Add (new TitleMenuItem (manager, entry, item, commandSource, initialCommandTarget, menu));
					}
				}
			}

			if (menuEntrySet != null) {
				Header = menuEntrySet.Name;

				foreach (CommandEntry item in menuEntrySet) {
					if (item.CommandId == MonoDevelop.Components.Commands.Command.Separator) {
						Items.Add (new Separator { UseLayoutRounding = true, });
					} else
						Items.Add (new TitleMenuItem (manager, item, menu: menu));
				}
			} else if (menuLinkEntry != null) {
				Header = menuLinkEntry.Text;
				Click += OnMenuLinkClicked;
			} else if (entry != null) {
				actionCommand = manager.GetCommand (menuEntry.CommandId) as ActionCommand;
				if (actionCommand == null)
					return;

				IsCheckable = actionCommand.ActionType == ActionType.Check;

				// FIXME: Use proper keybinding text.
				if (actionCommand.KeyBinding != null)
					InputGestureText = actionCommand.KeyBinding.ToString ();
				
				if (!actionCommand.Icon.IsNull)
					Icon = new Image { Source = actionCommand.Icon.GetImageSource (Xwt.IconSize.Small) };
				Click += OnMenuClicked;
			}

			Height = SystemParameters.CaptionHeight;
			UseLayoutRounding = true;
		}
Exemplo n.º 31
0
        protected override void Update(MonoDevelop.Components.Commands.CommandInfo info)
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableIPhoneProject();

            info.Visible = proj != null;
            if (info.Visible)
            {
                var conf = (IPhoneProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                info.Enabled = conf != null && IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted;
            }
        }
Exemplo n.º 32
0
        protected override void Update(MonoDevelop.Components.Commands.CommandInfo info)
        {
            var proj = GetActiveExecutableIPhoneProject();

            info.Visible = proj != null;
            if (info.Visible && IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted)
            {
                var conf = (IPhoneProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
                info.Enabled = conf != null && conf.Platform == IPhoneProject.PLAT_IPHONE;
            }
            else
            {
                info.Enabled = false;
            }
        }
Exemplo n.º 33
0
        protected override void Update(MonoDevelop.Components.Commands.CommandInfo info)
        {
            var proj = GetActiveExecutableMonoDroidProject();

            info.Visible = info.Enabled = proj != null;
        }