예제 #1
0
        /// <summary>Attach the model (report) and the view (IReportView)</summary>
        public void Attach(object Model, object View, ExplorerPresenter explorerPresenter)
        {
            this.report = Model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view = View as IReportView;

            this.view.VariableList.Lines = report.VariableNames;
            this.view.EventList.Lines = report.EventNames;
            this.view.VariableList.ContextItemsNeeded += OnNeedVariableNames;
            this.view.EventList.ContextItemsNeeded += OnNeedEventNames;
            this.view.VariableList.TextHasChangedByUser += OnVariableNamesChanged;
            this.view.EventList.TextHasChangedByUser += OnEventNamesChanged;
            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;
            dataStore = Apsim.Child(simulations, typeof(DataStore)) as DataStore;
            this.view.VariableList.SetSyntaxHighlighter("Report");

            dataStorePresenter = new DataStorePresenter();
            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            this.view.DataStoreView.TableList.SelectedValue = this.report.Name;

            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;
            if (simulation != null)
            {
                if (simulation.Parent is Experiment)
                    dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                else
                    dataStorePresenter.SimulationFilter = simulation;
                dataStorePresenter.PopulateGrid();
            }
        }
예제 #2
0
        /// <summary>
        /// Attach inherited class additional presenters is needed
        /// </summary>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            //UI Results
            try
            {
                ActivityLedgerGridView ledgerView = new ActivityLedgerGridView(clemPresenter.View as ViewBase);
                ReportView             rv         = new ReportView(clemPresenter.View as ViewBase);
                ViewBase reportView = new ViewBase(rv, "ApsimNG.Resources.Glade.DataStoreView.glade");

                Model report = clemPresenter.Model as Model;

                Simulations simulations = report.FindAncestor <Simulations>();
                if (simulations != null)
                {
                    dataStore = simulations.FindChild <IDataStore>();
                }

                DataStorePresenter          dataStorePresenter    = new DataStorePresenter();
                ActivityLedgerGridPresenter activityGridPresenter = new ActivityLedgerGridPresenter();
                Simulation simulation = report.FindAncestor <Simulation>();
                Zone       paddock    = report.FindAncestor <Zone>();

                if (paddock != null)
                {
                    dataStorePresenter.ZoneFilter = paddock;
                }

                if (simulation != null)
                {
                    if (simulation.Parent is Experiment)
                    {
                        dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                    }
                    else
                    {
                        dataStorePresenter.SimulationFilter = simulation;
                    }
                }

                dataStorePresenter.Attach(dataStore, reportView, clemPresenter.ExplorerPresenter);
                activityGridPresenter.CreateHtml     = (clemPresenter.Model as ReportActivitiesPerformed).CreateHTML;
                activityGridPresenter.ModelReport    = report as Report;
                activityGridPresenter.ModelName      = report.Name;
                activityGridPresenter.SimulationName = simulation.Name;
                activityGridPresenter.ZoneName       = paddock.Name;
                activityGridPresenter.Attach(dataStore, ledgerView, clemPresenter.ExplorerPresenter);
                dataStorePresenter.tableDropDown.SelectedValue = report.Name;

                (clemPresenter.View as CLEMView).AddTabView("Display", ledgerView);
                clemPresenter.PresenterList.Add("Display", activityGridPresenter);

                (clemPresenter.View as CLEMView).AddTabView("Data", reportView);
                clemPresenter.PresenterList.Add("Data", dataStorePresenter);
            }
            catch (Exception err)
            {
                this.explorerPresenter.MainPresenter.ShowError(err);
            }
        }
예제 #3
0
        /// <summary>
        /// Attach the model (report) and the view (IReportView)
        /// </summary>
        /// <param name="model">The report model object</param>
        /// <param name="view">The view object</param>
        /// <param name="explorerPresenter">The explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.report            = model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view                    = view as IReportView;
            this.intellisense            = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected   += OnIntellisenseItemSelected;
            this.view.VariableList.Mode  = EditorType.Report;
            this.view.EventList.Mode     = EditorType.Report;
            this.view.VariableList.Lines = report.VariableNames;
            this.view.EventList.Lines    = report.EventNames;
            this.view.GroupByEdit.Value  = report.GroupByVariableName;
            this.view.VariableList.ContextItemsNeeded     += OnNeedVariableNames;
            this.view.EventList.ContextItemsNeeded        += OnNeedEventNames;
            this.view.GroupByEdit.IntellisenseItemsNeeded += OnNeedVariableNames;
            this.view.VariableList.TextHasChangedByUser   += OnVariableNamesChanged;
            this.view.EventList.TextHasChangedByUser      += OnEventNamesChanged;
            this.view.GroupByEdit.Changed += OnGroupByChanged;
            this.view.SplitterChanged     += OnSplitterChanged;
            this.view.SplitterPosition     = Configuration.Settings.ReportSplitterPosition;
            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;
            this.view.TabChanged += OnChangeTab;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;

            if (simulations != null)
            {
                dataStore = Apsim.Child(simulations, typeof(IDataStore)) as IDataStore;
            }

            //// TBI this.view.VariableList.SetSyntaxHighlighter("Report");

            dataStorePresenter = new DataStorePresenter();
            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;
            Experiment experiment = Apsim.Parent(report, typeof(Experiment)) as Experiment;
            Zone       paddock    = Apsim.Parent(report, typeof(Zone)) as Zone;

            // Only show data which is in scope of this report.
            // E.g. data from this zone and either experiment (if applicable) or simulation.
            if (paddock != null)
            {
                dataStorePresenter.ZoneFilter = paddock;
            }
            if (experiment != null)
            {
                dataStorePresenter.ExperimentFilter = experiment;
            }
            else if (simulation != null)
            {
                dataStorePresenter.SimulationFilter = simulation;
            }

            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            this.view.TabIndex = this.report.ActiveTabIndex;
        }
예제 #4
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                bool   parentOfReport = false;
                Report report         = clemPresenter.Model as Report;
                if (report is null)
                {
                    report         = clemPresenter.Model.FindChild <Report>();
                    parentOfReport = true;
                }

                rv = new ReportView(clemPresenter.View as ViewBase);
                ViewBase reportView = new ViewBase(rv, "ApsimNG.Resources.Glade.DataStoreView.glade");

                dataStorePresenter = new DataStorePresenter(new string[] { (parentOfReport)? (clemPresenter.Model as IModel).Name:report.Name });

                Simulations simulations = report.FindAncestor <Simulations>();
                if (simulations != null)
                {
                    dataStore = simulations.FindChild <IDataStore>();
                }

                Simulation simulation = report.FindAncestor <Simulation>();
                Experiment experiment = report.FindAncestor <Experiment>();
                Zone       paddock    = report.FindAncestor <Zone>();

                IModel zoneAnscestor = report.FindAncestor <Zone>();

                // Only show data which is in scope of this report.
                // E.g. data from this zone and either experiment (if applicable) or simulation.
                if (paddock != null)
                {
                    dataStorePresenter.ZoneFilter = paddock;
                }
                if (zoneAnscestor is null & experiment != null)
                {
                    // allows the inner reports of the base simulation to be displayed
                    // when an experiment is being undertaken
                    // otherwise reports are considered child of experiment and will only display experiment results.
                    dataStorePresenter.ExperimentFilter = experiment;
                }
                else if (simulation != null)
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }

                dataStorePresenter.Attach(dataStore, reportView, clemPresenter.ExplorerPresenter);

                // Attach the view to display data
                clem = clemPresenter.View as CLEMView;
                clem.AddTabView("Data", reportView);
                clemPresenter.PresenterList.Add("Data", this);
            }
예제 #5
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                Report report = clemPresenter.model as Report;

                ReportView rv         = new ReportView(clemPresenter.view as ViewBase);
                ViewBase   reportView = new ViewBase(rv, "ApsimNG.Resources.Glade.DataStoreView.glade");

                DataStorePresenter dataStorePresenter = new DataStorePresenter(new string[] { report.Name });

                Simulations simulations = report.FindAncestor <Simulations>();
                if (simulations != null)
                {
                    dataStore = simulations.FindChild <IDataStore>();
                }

                Simulation simulation = report.FindAncestor <Simulation>();
                Experiment experiment = report.FindAncestor <Experiment>();
                Zone       paddock    = report.FindAncestor <Zone>();

                // Only show data which is in scope of this report.
                // E.g. data from this zone and either experiment (if applicable) or simulation.
                if (paddock != null)
                {
                    dataStorePresenter.ZoneFilter = paddock;
                }

                if (experiment != null)
                {
                    dataStorePresenter.ExperimentFilter = experiment;
                }
                else if (simulation != null)
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }

                dataStorePresenter.Attach(dataStore, reportView, clemPresenter.explorerPresenter);

                // Attach the view to display data
                clem = clemPresenter.view as CLEMView;
                clem.AddTabView("Data", reportView);
                clemPresenter.presenterList.Add("Data", this);

                //clem.TabSelected += Refresh;
            }
            catch (Exception err)
            {
                clemPresenter.explorerPresenter.MainPresenter.ShowError(err);
            }
        }
예제 #6
0
        /// <summary>
        /// Attach the model (report) and the view (IReportView)
        /// </summary>
        /// <param name="model">The report model object</param>
        /// <param name="view">The view object</param>
        /// <param name="explorerPresenter">The explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.report            = model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view                                           = view as IReportView;
            this.intellisense                                   = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected                          += OnIntellisenseItemSelected;
            this.view.VariableList.ScriptMode                   = false;
            this.view.EventList.ScriptMode                      = false;
            this.view.VariableList.Lines                        = report.VariableNames;
            this.view.EventList.Lines                           = report.EventNames;
            this.view.VariableList.ContextItemsNeeded          += OnNeedVariableNames;
            this.view.EventList.ContextItemsNeeded             += OnNeedEventNames;
            this.view.VariableList.TextHasChangedByUser        += OnVariableNamesChanged;
            this.view.EventList.TextHasChangedByUser           += OnEventNamesChanged;
            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;

            if (simulations != null)
            {
                dataStore = Apsim.Child(simulations, typeof(IStorageReader)) as IStorageReader;
            }

            //// TBI this.view.VariableList.SetSyntaxHighlighter("Report");

            dataStorePresenter = new DataStorePresenter();
            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;

            if (simulation != null)
            {
                if (simulation.Parent is Experiment)
                {
                    dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                }
                else
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }
            }

            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            this.view.DataStoreView.TableList.SelectedValue = this.report.Name;
            this.view.TabIndex = this.report.ActiveTabIndex;
        }
        /// <summary>Attach the model (report) and the view (IReportView)</summary>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.report            = model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view = view as IReportActivityLedgerView;

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;

            if (simulations != null)
            {
                dataStore = Apsim.Child(simulations, typeof(IDataStore)) as IDataStore;
            }

            dataStorePresenter    = new DataStorePresenter();
            activityGridPresenter = new ActivityLedgerGridPresenter();
            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;
            Zone       paddock    = Apsim.Parent(report, typeof(Zone)) as Zone;

            if (paddock != null)
            {
                dataStorePresenter.ZoneFilter = paddock;
            }
            if (simulation != null)
            {
                if (simulation.Parent is Experiment)
                {
                    dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                }
                else
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }
            }

            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            activityGridPresenter.ModelName      = this.report.Name;
            activityGridPresenter.SimulationName = simulation.Name;
            activityGridPresenter.ZoneName       = paddock.Name;
            activityGridPresenter.Attach(dataStore, this.view.DisplayView, explorerPresenter);
            dataStorePresenter.tableDropDown.SelectedValue = this.report.Name;
        }
예제 #8
0
        /// <summary>Attach the model (report) and the view (IReportView)</summary>
        public void Attach(object Model, object View, ExplorerPresenter explorerPresenter)
        {
            this.report            = Model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view = View as IReportView;

            this.view.VariableList.Lines = report.VariableNames;
            this.view.EventList.Lines    = report.EventNames;
            this.view.VariableList.ContextItemsNeeded          += OnNeedVariableNames;
            this.view.EventList.ContextItemsNeeded             += OnNeedEventNames;
            this.view.VariableList.TextHasChangedByUser        += OnVariableNamesChanged;
            this.view.EventList.TextHasChangedByUser           += OnEventNamesChanged;
            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;

            if (simulations != null)
            {
                dataStore = Apsim.Child(simulations, typeof(IStorageReader)) as IStorageReader;
            }
            this.view.VariableList.SetSyntaxHighlighter("Report");

            dataStorePresenter = new DataStorePresenter();
            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            this.view.DataStoreView.TableList.SelectedValue = this.report.Name;

            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;

            if (simulation != null)
            {
                if (simulation.Parent is Experiment)
                {
                    dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                }
                else
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }
                dataStorePresenter.PopulateGrid();
            }
        }
        /// <summary>Attach the model (report) and the view (IReportView)</summary>
        public void Attach(object Model, object View, ExplorerPresenter explorerPresenter)
        {
            this.report            = Model as Report;
            this.explorerPresenter = explorerPresenter;
            this.view = View as IReportActivityLedgerView;

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations;

            if (simulations != null)
            {
                dataStore = Apsim.Child(simulations, typeof(IStorageReader)) as IStorageReader;
            }
            /// TBI this.view.VariableList.SetSyntaxHighlighter("Report");

            dataStorePresenter    = new DataStorePresenter();
            activityGridPresenter = new ActivityLedgerGridPresenter();
            Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation;

            if (simulation != null)
            {
                if (simulation.Parent is Experiment)
                {
                    dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment;
                }
                else
                {
                    dataStorePresenter.SimulationFilter = simulation;
                }
            }

            dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter);
            activityGridPresenter.ModelName = this.report.Name;
            activityGridPresenter.Attach(dataStore, this.view.DisplayView, explorerPresenter);
            this.view.DataStoreView.TableList.SelectedValue = this.report.Name;
        }