public ConfigurationSelectionForm(ConfigurationSelectionInput input, bool enableDebugging)
        {
            this.EnableDebugging = enableDebugging;
            this.InitializeComponent();

            // verify all properties in input
            if (input == null ||
                input.Context == null ||
                input.Groups == null ||
                input.InterpreterNames == null ||
                input.Target == null)
            {
                throw new ArgumentNullException();
            }

            this.m_Input = input;

            this.ConfigurationSelectionResult = new ConfigurationSelectionOutput();

            this.chbPostJobs.Checked = Properties.Settings.Default.bPostTojobManager;
            this.chbOpenDashboard.Checked = Properties.Settings.Default.bOpenDashboard;
            this.chbVerbose.Checked = Properties.Settings.Default.bVerboseLogging;

            this.InitForm();
        }
Exemplo n.º 2
0
        public ConfigurationSelectionForm(Func <ConfigurationSelectionInput> input, bool enableDebugging, bool projectSaved)
        {
            this.EnableDebugging = enableDebugging;
            this.projectSaved    = projectSaved;
            this.InitializeComponent();

            this.m_Input     = input();
            this.m_inputFunc = input;

            // verify all properties in input
            if (m_Input == null ||
                m_Input.Context == null ||
                m_Input.Groups == null ||
                m_Input.InterpreterNames == null)
            {
                throw new ArgumentNullException();
            }

            this.ConfigurationSelectionResult = new ConfigurationSelectionOutput();

            this.chbPostJobs.Checked = Properties.Settings.Default.bPostTojobManager;
            this.chbVerbose.Checked  = Properties.Settings.Default.bVerboseLogging;

            this.InitForm();
            this.MouseMove += ConfigurationSelectionForm_MouseMove;
        }
        public ConfigurationSelection ShowConfigurationSelectionForm(IMgaModel context)
        {
            if (context == null)
            {
                throw new ArgumentNullException();
            }

            ConfigurationSelection results = new ConfigurationSelection()
            {
                Context = context
            };

            var configurationGroups = this.GetConfigurationGroups(context);
            ConfigurationSelectionInput configurationSelectionInput = new ConfigurationSelectionInput();

            AnalysisModelProcessor analysisModelProcessor = null;

            this.ExecuteInTransaction(context, () =>
            {
                analysisModelProcessor = AnalysisModelProcessor.GetAnalysisModelProcessor(context);
                configurationSelectionInput.Context = GMELightObject.GetGMELightFromMgaObject(context);
                configurationSelectionInput.Groups = configurationGroups.Select(x => x.ConvertToLight()).ToArray();
                configurationSelectionInput.IsDesignSpace = configurationGroups.Any(x => x.Owner == null) == false;

                configurationSelectionInput.OperationModeInformation = string.Format("{0} - {1}",
                    SplitCamelCase(analysisModelProcessor.GetInvokedObject().MetaBase.Name),
                    SplitCamelCase(analysisModelProcessor.OriginalSystemUnderTest.Referred.DesignEntity.Kind));

                configurationSelectionInput.OutputDirectory = analysisModelProcessor.GetResultsDirectory();

                configurationSelectionInput.Target = GMELightObject.GetGMELightFromMgaObject(analysisModelProcessor.OriginalSystemUnderTest.Impl);
            });

            var interpreters = analysisModelProcessor.GetWorkflow();
            configurationSelectionInput.InterpreterNames = interpreters.Select(x => x.Name).ToArray();

            using (ConfigurationSelectionForm selectionForm = new ConfigurationSelectionForm(configurationSelectionInput))
            {
                System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.DialogResult.None;
                if (this.IsInteractive)
                {
                    dialogResult = selectionForm.ShowDialog();
                    this.Logger.GMEConsoleLoggingLevel = selectionForm.ConfigurationSelectionResult.VerboseLogging ?
                        CyPhyGUIs.GMELogger.MessageType_enum.Debug :
                        CyPhyGUIs.SmartLogger.MessageType_enum.Info;
                }
                else
                {
                    selectionForm.SaveSettingsAndResults();
                    dialogResult = System.Windows.Forms.DialogResult.OK;
                }

                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    var selectionResult = selectionForm.ConfigurationSelectionResult;
                    results.KeepTemporaryModels = selectionResult.KeepTemporaryModels;
                    results.OpenDashboard = selectionResult.OpenDashboard;
                    results.PostToJobManager = selectionResult.PostToJobManager;
                    results.SelectedConfigurations = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs"));

                    this.ExecuteInTransaction(context, () =>
                    {
                        foreach (var selectedId in selectionResult.SelectedConfigurations.Select(x => x.GMEId))
                        {
                            var selectedGmeObject = context.Project.GetObjectByID(selectedId);
                            if (selectedGmeObject == null)
                            {
                                throw new NullReferenceException("Selected configuration was not found in the project tree.");
                            }

                            results.SelectedConfigurations.Append(selectedGmeObject as MgaFCO);
                        }
                    });
                }
                else
                {
                    throw new ExecutionCanceledByUserException("Main form was canceled.");
                }
            }

            return results;
        }