예제 #1
0
        public static IExecutionHandler GetExecutionModeForCommand(object data)
        {
            CommandItem item = (CommandItem)data;

            if (item.Mode == null)
            {
                using (var dlg = new CustomExecutionModeManagerDialog(item.Context))
                    MessageService.ShowCustomDialog(dlg);
                return(null);
            }

            if (item.Mode.ExecutionHandler is ParameterizedExecutionHandler)
            {
                ParameterizedExecutionHandler        cmode = (ParameterizedExecutionHandler)item.Mode.ExecutionHandler;
                ParameterizedExecutionHandlerWrapper pw    = new ParameterizedExecutionHandlerWrapper();
                pw.Handler    = cmode;
                pw.Context    = item.Context;
                pw.ParentMode = item.Mode;
                return(pw);
            }

            // If control key is pressed, show the parameters dialog
            Gdk.ModifierType mtype;
            if (Gtk.Global.GetCurrentEventState(out mtype) && (mtype & Gdk.ModifierType.ControlMask) != 0)
            {
                RunWithPromptHandler cmode = new RunWithPromptHandler();
                cmode.Context = item.Context;
                cmode.Mode    = item.Mode;
                return(cmode);
            }

            return(item.Mode.ExecutionHandler);
        }
예제 #2
0
        void LoadEditors()
        {
            Dictionary <object, object> oldData = new Dictionary <object, object> ();

            foreach (KeyValuePair <object, IExecutionConfigurationEditor> editor in currentEditors)
            {
                object data = editor.Value.Save();
                oldData [editor.Key] = data;
            }

            foreach (Gtk.Widget w in notebook.Children)
            {
                notebook.Remove(w);
                w.Destroy();
            }

            if (mode == null)
            {
                return;
            }

            currentEditors.Clear();

            foreach (ExecutionCommandCustomizer customizer in ExecutionModeCommandService.GetExecutionCommandCustomizers(ctx))
            {
                IExecutionConfigurationEditor e = customizer.CreateEditor();
                currentEditors.Add(customizer, e);
                object cdata;
                if (!oldData.TryGetValue(customizer, out cdata))
                {
                    cdata = data.GetCommandData(customizer.Id);
                }
                Gtk.Widget w = e.Load(ctx, cdata);
                w.Show();
                notebook.AppendPage(w, new Gtk.Label(GettextCatalog.GetString(customizer.Name)));
            }

            ParameterizedExecutionHandler handler = mode.ExecutionHandler as ParameterizedExecutionHandler;

            if (handler != null)
            {
                IExecutionConfigurationEditor e = handler.CreateEditor();
                currentEditors.Add(mode, e);
                object cdata;
                if (!oldData.TryGetValue(mode, out cdata))
                {
                    cdata = data.Data;
                }
                Gtk.Widget w = e.Load(ctx, data.Data);
                w.Show();
                notebook.AppendPage(w, new Gtk.Label(mode.Name));
            }
            notebook.ShowTabs  = notebook.ShowBorder = currentEditors.Count > 1;
            hseparator.Visible = !notebook.ShowTabs;
        }
예제 #3
0
        public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console, bool allowPrompt, bool forcePrompt)
        {
            if ((PromptForParameters || forcePrompt) && allowPrompt)
            {
                CommandExecutionContext ctx        = new CommandExecutionContext(Project, command);
                CustomExecutionMode     customMode = ExecutionModeCommandService.ShowParamtersDialog(ctx, Mode, this);
                if (customMode == null)
                {
                    return(new CancelledProcessAsyncOperation());
                }
                else
                {
                    return(customMode.Execute(command, console, false, false));
                }
            }
            if (commandData != null)
            {
                foreach (KeyValuePair <string, object> cmdData in commandData)
                {
                    ExecutionCommandCustomizer cc = ExecutionModeCommandService.GetExecutionCommandCustomizer(cmdData.Key);
                    if (cc != null)
                    {
                        cc.Customize(command, cmdData.Value);
                    }
                }
            }
            ParameterizedExecutionHandler cmode = Mode.ExecutionHandler as ParameterizedExecutionHandler;

            if (cmode != null)
            {
                CommandExecutionContext ctx = new CommandExecutionContext(Project, command);
                return(cmode.Execute(command, console, ctx, Data));
            }
            else
            {
                return(Mode.ExecutionHandler.Execute(command, console));
            }
        }