public void Add(CommandInfo info, object dataItem)
 {
     info.DataItem = dataItem;
     if (info.Text == null) info.Text = defaultInfo.Text;
     if (info.Icon == null) info.Icon = defaultInfo.Icon;
     list.Add (info);
 }
 protected override void Update(CommandInfo info)
 {
     if (Runtime.ProjectService.CurrentOpenCombine != null) {
         CombineEntry entry = Runtime.ProjectService.CurrentSelectedCombineEntry;
         if (entry != null) {
             info.Enabled = Runtime.ProjectService.CurrentBuildOperation.IsCompleted;
             info.Text = string.Format (GettextCatalog.GetString ("Build {0}"), entry.Name);
             if (entry is Combine)
                 info.Description = string.Format (GettextCatalog.GetString ("Build Solution {0}"), entry.Name);
             else if (entry is Project)
                 info.Description = string.Format (GettextCatalog.GetString ("Build Project {0}"), entry.Name);
             else
                 info.Description = info.Text;
         } else {
             info.Enabled = false;
         }
     } else {
         if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
             info.Enabled = Runtime.ProjectService.CurrentBuildOperation.IsCompleted;
             string file = Path.GetFileName (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName);
             info.Text = info.Description = string.Format (GettextCatalog.GetString ("Build {0}"), file);
         } else {
             info.Enabled = false;
         }
     }
 }
 protected override void Update(CommandInfo info)
 {
     if (Runtime.DebuggingService == null)
         info.Visible = false;
     else
         info.Enabled = Runtime.DebuggingService.IsRunning;
 }
        protected override void Update(CommandArrayInfo info)
        {
            int contentCount = WorkbenchSingleton.Workbench.ViewContentCollection.Count;
            if (contentCount == 0) return;

            for (int i = 0; i < contentCount; ++i) {
                IViewContent content = (IViewContent)WorkbenchSingleton.Workbench.ViewContentCollection[i];

                CommandInfo item = null;
                if (content.WorkbenchWindow.ShowNotification) {
                    item = new CommandInfo ("<span foreground=\"blue\">" + content.WorkbenchWindow.Title + "</span>");
                    item.UseMarkup = true;
                } else {
                    item = new CommandInfo (content.WorkbenchWindow.Title);
                }

                item.Checked = (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == content.WorkbenchWindow);
                item.Description = GettextCatalog.GetString ("Activate this window");

                if (i + 1 <= 9)
                    item.AccelKey = "Alt|" + (i+1);

                info.Add (item, content.WorkbenchWindow);
            }
        }
 protected override void Update(CommandArrayInfo info)
 {
     for (int i = 0; i < ToolLoader.Tool.Count; ++i) {
         CommandInfo cmd = new CommandInfo (ToolLoader.Tool[i].ToString());
         cmd.Description = GettextCatalog.GetString ("Start tool") + " " + String.Join(String.Empty, ToolLoader.Tool[i].ToString().Split('&'));
         info.Add (cmd, ToolLoader.Tool[i]);
     }
 }
 protected void OnUpdateViewToolbar(CommandArrayInfo info)
 {
     foreach (IDockToolbar bar in Toolbars) {
         CommandInfo cmd = new CommandInfo (bar.Title);
         cmd.Checked = bar.Visible;
         info.Add (cmd, bar);
     }
 }
        internal CommandInfo GetCommandInfo(object commandId)
        {
            ActionCommand cmd = GetActionCommand (commandId);
            CommandInfo info = new CommandInfo (cmd);

            try {
                int globalPos;
                object cmdTarget = GetFirstCommandTarget (out globalPos);

                while (cmdTarget != null)
                {
                    HandlerTypeInfo typeInfo = GetTypeHandlerInfo (cmdTarget);
                    CommandUpdaterInfo cui = typeInfo.GetCommandUpdater (commandId);

                    if (cui != null) {
                        if (cmd.CommandArray) {
                            info.ArrayInfo = new CommandArrayInfo (info);
                            cui.Run (cmdTarget, info.ArrayInfo);
                            return info;
                        }
                        else {
                            cui.Run (cmdTarget, info);
                            return info;
                        }
                    }

                    if (typeInfo.GetCommandHandler (commandId) != null) {
                        info.Enabled = true;
                        info.Visible = true;
                        return info;
                    }

                    cmdTarget = GetNextCommandTarget (cmdTarget, ref globalPos);
                }

                cmd.UpdateCommandInfo (info);
            }
            catch (Exception ex) {
                if (!commandUpdateErrors.Contains (commandId)) {
                    commandUpdateErrors.Add (commandId);
                    ReportError (commandId, "Error while updating status of command: " + commandId, ex);
                }
                info.Enabled = false;
                info.Visible = true;
            }
            return info;
        }
 protected void OnUpdateSelectTestInTree(CommandInfo info)
 {
     UnitTest test = GetSelectedTest ();
     info.Enabled = test != null;
 }
        public bool DispatchCommand(object commandId, object dataItem)
        {
            ActionCommand cmd = null;
            try {
                cmd = GetActionCommand (commandId);

                int globalPos;
                object cmdTarget = GetFirstCommandTarget (out globalPos);
                CommandInfo info = new CommandInfo (cmd);

                while (cmdTarget != null)
                {
                    HandlerTypeInfo typeInfo = GetTypeHandlerInfo (cmdTarget);

                    CommandUpdaterInfo cui = typeInfo.GetCommandUpdater (commandId);
                    if (cui != null) {
                        if (cmd.CommandArray) {
                            // Make sure that the option is still active
                            CommandArrayInfo ainfo = new CommandArrayInfo (info);
                            cui.Run (cmdTarget, ainfo);
                            bool found = false;
                            foreach (CommandInfo ci in ainfo) {
                                if (Object.Equals (dataItem, ci.DataItem)) {
                                    found = true;
                                    break;
                                }
                            }
                            if (!found) return false;
                        } else {
                            cui.Run (cmdTarget, info);
                            if (!info.Enabled || !info.Visible) return false;
                        }
                    }

                    CommandHandlerInfo chi = typeInfo.GetCommandHandler (commandId);
                    if (chi != null) {
                        if (cmd.CommandArray)
                            chi.Run (cmdTarget, dataItem);
                        else
                            chi.Run (cmdTarget);
                        UpdateToolbars ();
                        return true;
                    }

                    cmdTarget = GetNextCommandTarget (cmdTarget, ref globalPos);
                }

                return cmd.DispatchCommand (dataItem);
            }
            catch (Exception ex) {
                string name = (cmd != null && cmd.Text != null && cmd.Text.Length > 0) ? cmd.Text : commandId.ToString ();
                name = name.Replace ("_","");
                ReportError (commandId, "Error while executing command: " + name, ex);
                return false;
            }
        }
 protected void OnUpdateUnIndentSelection(CommandInfo info)
 {
     info.Enabled = window.ActiveViewContent is ICodeStyleOperations;
 }
 protected void OnUpdateRunTest(CommandInfo info)
 {
     UnitTest test = GetSelectedTest ();
     info.Enabled = test != null && test.SourceCodeLocation != null;
 }
 public void UpdateToggleBreakpoint(CommandInfo info)
 {
     if (Runtime.DebuggingService == null)
         info.Visible = false;
     else
         info.Enabled = DisplayBinding.ContentName != null;
 }
 protected void OnUpdateUndo(CommandInfo info)
 {
     info.Enabled = window.ActiveViewContent is IEditable;
 }
 public void OnUpdateIncludeInDeploy(CommandInfo info)
 {
     Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), false);
     ProjectFile finfo = CurrentNode.DataItem as ProjectFile;
     info.Checked = !project.DeployInformation.IsFileExcluded (finfo.Name);
 }
 protected override void Update(CommandInfo info)
 {
     info.Enabled = WorkbenchSingleton.Workbench.WorkbenchLayout != null && WorkbenchSingleton.Workbench.WorkbenchLayout.CurrentLayout != "Default";
 }
示例#16
0
 protected override void Update(CommandInfo info)
 {
     info.Visible = Runtime.ProjectService.CurrentSelectedProject is MonoProject;
 }
 protected override void Update(CommandInfo info)
 {
     if (Runtime.DebuggingService == null)
         info.Visible = false;
 }
 protected void UpdatePasteToCurrentItem(CommandInfo info)
 {
     if (copyObject != null) {
         TreeNodeNavigator node = (TreeNodeNavigator) GetSelectedNode ();
         if (node != null) {
             NodeBuilder[] chain = node.NodeBuilderChain;
             NodePosition pos = node.CurrentPosition;
             foreach (NodeBuilder b in chain) {
                 NodeCommandHandler handler = b.CommandHandler;
                 handler.SetCurrentNode (node);
                 if (handler.CanDropNode (copyObject, currentTransferOperation)) {
                     info.Enabled = true;
                     return;
                 }
                 node.MoveToPosition (pos);
             }
         }
     }
     info.Enabled = false;
 }
 protected void UpdateCutCurrentItem(CommandInfo info)
 {
     info.Enabled = CanTransferCurrentItem (DragOperation.Move);
 }
 protected void BuildTreeOptionsMenu(CommandArrayInfo info)
 {
     ITreeNavigator tnav = GetSelectedNode ();
     ITreeOptions currentOptions = tnav.Options;
     foreach (TreePadOption op in options) {
         CommandInfo ci = new CommandInfo (op.Label);
         ci.Checked = currentOptions [op.Id];
         info.Add (ci, op.Id);
     }
 }
 public void Run(object cmdTarget, CommandInfo info)
 {
     if (isArray)
         throw new InvalidOperationException ("Invalid signature for command update handler: " + Method.DeclaringType + "." + Method.Name + "()");
     Method.Invoke (cmdTarget, new object[] {info} );
 }
 public void OnUpdateIncludeInBuild(CommandInfo info)
 {
     ProjectFile file = CurrentNode.DataItem as ProjectFile;
     info.Checked = (file.BuildAction == BuildAction.Compile);
 }
 protected void OnUpdateRunTest(CommandInfo info)
 {
     UnitTest test = CurrentNode.DataItem as UnitTest;
     info.Enabled = test.SourceCodeLocation != null;
 }
 void Update(CommandInfo cmdInfo)
 {
     if (lastDesc != cmdInfo.Description) {
         SetTooltip (tips, cmdInfo.Description, cmdInfo.Description);
         lastDesc = cmdInfo.Description;
     }
     if (Label != cmdInfo.Text)
         Label = cmdInfo.Text;
     if (cmdInfo.Icon != StockId)
         StockId = cmdInfo.Icon;
     if (cmdInfo.Enabled != Sensitive)
         Sensitive = cmdInfo.Enabled;
     if (cmdInfo.Visible != Visible)
         Visible = cmdInfo.Visible;
 }
 protected override void Update(CommandInfo info)
 {
     info.Enabled = Runtime.DebuggingService != null &&
                     Runtime.ProjectService.CurrentRunOperation.IsCompleted;
 }
 protected void OnUpdateReloadFile(CommandInfo info)
 {
     info.Enabled = window.ViewContent.ContentName != null && !window.ViewContent.IsViewOnly;
 }
 protected override void Update(CommandArrayInfo info)
 {
     IWorkbench wb = WorkbenchSingleton.Workbench;
     if (wb.WorkbenchLayout != null) {
         PadContentCollection pads = wb.WorkbenchLayout.PadContentCollection;
         foreach (IPadContent padContent in pads) {
             CommandInfo cmd = new CommandInfo (padContent.Title);
             cmd.UseMarkup = true;
             cmd.Checked = WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible (padContent);
             info.Add (cmd, padContent);
         }
     }
 }
        protected void OnUpdateSaveFile(CommandInfo info)
        {
            if (window.ViewContent.IsViewOnly) {
                info.Enabled = false;
                return;
            }

            IViewContent content = window.ActiveViewContent as IViewContent;
            if (content != null)
                info.Enabled = content.IsDirty;
            else
                info.Enabled = false;
        }
 protected override void Update(CommandArrayInfo info)
 {
     IWorkbench wb = WorkbenchSingleton.Workbench;
     if (wb.WorkbenchLayout != null) {
         string[] layouts = wb.WorkbenchLayout.Layouts;
         Array.Sort (layouts);
         foreach (string layout in layouts) {
             CommandInfo cmd = new CommandInfo (layout);
             cmd.Checked = (layout == wb.WorkbenchLayout.CurrentLayout);
             info.Add (cmd, layout);
         }
     }
 }
 protected void OnUpdateSelectAll(CommandInfo info)
 {
     IEditable editable = window.ActiveViewContent as IEditable;
     info.Enabled = editable != null && editable.ClipboardHandler.EnableSelectAll;
 }