Exemple #1
0
        /// <summary>
        /// Attach the Manager model and ManagerView to this presenter.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="presenter">The explorer presenter being used</param>
        public void Attach(object model, object view, ExplorerPresenter presenter)
        {
            this.view      = view as IBubbleChartView;
            this.presenter = presenter;
            this.model     = model as IBubbleChart;

            this.view.OnGraphChanged += OnViewChanged;
            this.view.AddNode        += OnAddNode;
            this.view.DelNode        += OnDelNode;
            this.view.AddArc         += OnAddArc;
            this.view.DelArc         += OnDelArc;

            this.view.RuleList.ContextItemsNeeded += OnNeedVariableNames;
            //view.RuleList.TextHasChangedByUser += OnVariableNamesChanged;
            this.view.ActionList.ContextItemsNeeded += OnNeedEventNames;

            propertiesPresenter.Attach(this.model, this.view.PropertiesView, presenter);
            //view.ActionList.TextHasChangedByUser += OnEventNamesChanged;

            intellisense = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            presenter.CommandHistory.ModelChanged += OnModelChanged;

            RefreshView();
        }
Exemple #2
0
        /// <summary>
        /// Attach the Manager model and ManagerView to this presenter.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="presenter">The explorer presenter being used</param>
        public void Attach(object model, object view, ExplorerPresenter presenter)
        {
            manager                    = model as Manager;
            managerView                = view as IManagerView;
            explorerPresenter          = presenter;
            intellisense               = new IntellisensePresenter(managerView as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            scriptModel = manager.Children.FirstOrDefault();

            // See if manager script has a description attribute on it's class.
            if (scriptModel != null)
            {
                DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute;
                if (descriptionName != null)
                {
                    explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString());
                }
            }

            propertyPresenter.Attach(scriptModel, managerView.GridView, presenter);
            managerView.Editor.Mode = EditorType.ManagerScript;
            managerView.Editor.Text = manager.Code;
            managerView.Editor.ContextItemsNeeded += OnNeedVariableNames;
            managerView.Editor.LeaveEditor        += OnEditorLeave;
            managerView.Editor.AddContextSeparator();
            managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T");
            managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R");
            managerView.Editor.Location            = manager.Location;
            managerView.TabIndex                   = manager.ActiveTabIndex;
            presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged;
        }
Exemple #3
0
        /// <summary>Attach the model and view to this presenter.</summary>
        /// <param name="model">The graph model to work with</param>
        /// <param name="view">The series view to work with</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.series                = model as Series;
            this.seriesView            = view as SeriesView;
            this.explorerPresenter     = explorerPresenter;
            intellisense               = new IntellisensePresenter(seriesView as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            Graph parentGraph = series.FindAncestor <Graph>();

            if (parentGraph != null)
            {
                try
                {
                    GraphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(GraphPresenter);
                    GraphPresenter.Attach(parentGraph, seriesView.GraphView, explorerPresenter);
                }
                catch (Exception err)
                {
                    explorerPresenter.MainPresenter.ShowError(err);
                }
            }

            try
            {
                PopulateView();
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }

            ConnectViewEvents();
        }
Exemple #4
0
        /// <summary>Attach the model and view to this presenter and populate the view.</summary>
        /// <param name="model">The data store model to work with.</param>
        /// <param name="view">Data store view to work with.</param>
        /// <param name="explorerPresenter">Parent explorer presenter.</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            dataStore = model as IDataStore;
            this.view = view as IDataStoreView;
            this.explorerPresenter     = explorerPresenter;
            intellisense               = new IntellisensePresenter(this.view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            this.view.TableList.IsEditable = false;
            this.view.Grid.ReadOnly        = true;
            this.view.Grid.NumericFormat   = "N3";
            if (dataStore != null)
            {
                this.view.TableList.Values = dataStore.Reader.TableNames.ToArray();
                if (Utility.Configuration.Settings.MaximumRowsOnReportGrid > 0)
                {
                    this.view.MaximumNumberRecords.Value = Utility.Configuration.Settings.MaximumRowsOnReportGrid.ToString();
                }
            }
            this.view.FileName.Value = dataStore.FileName;

            this.view.TableList.Changed    += this.OnTableSelected;
            this.view.ColumnFilter.Changed += OnColumnFilterChanged;
            this.view.ColumnFilter.IntellisenseItemsNeeded += OnIntellisenseNeeded;
            this.view.RowFilter.Changed            += OnColumnFilterChanged;
            this.view.MaximumNumberRecords.Changed += OnMaximumNumberRecordsChanged;
            this.view.FileNameChanged += OnFileNameChanged;
            PopulateGrid();
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public override void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            base.Attach(model, view, explorerPresenter);
            grid.ContextItemsNeeded += GetContextItems;
            grid.CanGrow             = false;
            this.model   = model as Model;
            intellisense = new IntellisensePresenter(grid as ViewBase);

            // The grid does not have control-space intellisense (for now).
            intellisense.ItemSelected += OnIntellisenseItemSelected;
            // if the model is Testable, run the test method.
            ITestable testModel = model as ITestable;

            if (testModel != null)
            {
                testModel.Test(false, true);
                grid.ReadOnly = true;
            }

            grid.NumericFormat = "G6";
            FindAllProperties(this.model);
            if (grid.DataSource == null)
            {
                PopulateGrid(this.model);
            }
            else
            {
                FormatTestGrid();
            }

            grid.CellsChanged += OnCellValueChanged;
            grid.ButtonClick  += OnFileBrowseClick;
            this.presenter.CommandHistory.ModelChanged += OnModelChanged;
        }
Exemple #6
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            if (model is ITestable t)
            {
                t.Test(false, true);
            }

            presenter                = parentPresenter;
            view                     = v as IDualGridView;
            tableModel               = model as IModelAsTable;
            tables                   = tableModel.Tables;
            view.Grid1.DataSource    = tables[0];
            view.Grid2.DataSource    = tables.Count > 1 ? tables[1] : null;
            view.Grid1.CellsChanged += OnCellValueChanged1;
            view.Grid2.CellsChanged += OnCellValueChanged2;

            bool readOnly = !tableModel.GetType().GetProperty("Tables").CanWrite;

            view.Grid1.ReadOnly = readOnly;
            view.Grid2.ReadOnly = readOnly;

            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            gridPresenter1 = new GridPresenter();
            gridPresenter1.Attach(model, view.Grid1, parentPresenter);
            gridPresenter2 = new GridPresenter();
            gridPresenter2.Attach(model, view.Grid2, parentPresenter);

            intellisense = new IntellisensePresenter(view.Grid2 as ViewBase);
            intellisense.ItemSelected     += OnIntellisenseItemSelected;
            view.Grid2.ContextItemsNeeded += OnIntellisenseItemsNeeded;
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            explorerPresenter = parentPresenter;
            view         = v as IPropertyAndGridView;
            intellisense = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;
            tableModel = model as IModelAsTable;
            if (tableModel.Tables.Count != 1)
            {
                throw new Exception("PropertyAndTablePresenter must have a single data table.");
            }
            table = tableModel.Tables[0];
            view.Grid2.DataSource          = table;
            view.Grid2.CellsChanged       += OnCellValueChanged2;
            view.Grid2.NumericFormat       = null;
            view.Grid2.ContextItemsNeeded += OnContextItemsNeeded;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            if (Configuration.Settings.UseNewPropertyPresenter)
            {
                propertyPresenter = new SimplePropertyPresenter();
            }
            else
            {
                propertyPresenter = new PropertyPresenter();
            }
            explorerPresenter.ApsimXFile.Links.Resolve(propertyPresenter);
            propertyPresenter.Attach(model, view.PropertiesView, parentPresenter);
            gridPresenter = new GridPresenter();
            gridPresenter.Attach(model, view.Grid2, parentPresenter);
        }
Exemple #8
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;
        }
Exemple #9
0
        /// <summary>
        /// Attach model to view.
        /// </summary>
        /// <param name="model">The 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.operations            = model as Operations;
            this.view                  = view as IEditorView;
            this.explorerPresenter     = explorerPresenter;
            this.intellisense          = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            this.PopulateEditorView();
            this.view.ContextItemsNeeded   += this.OnContextItemsNeeded;
            this.view.TextHasChangedByUser += this.OnTextHasChangedByUser;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Exemple #10
0
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.factor           = model as Factor;
            this.factorView       = view as IEditorView;
            this.presenter        = explorerPresenter;
            intellisense          = new IntellisensePresenter(factorView as ViewBase);
            this.factorView.Lines = this.factor.Specifications?.ToArray() ?? new string[0];

            this.factorView.TextHasChangedByUser       += this.OnTextHasChangedByUser;
            this.factorView.ContextItemsNeeded         += this.OnContextItemsNeeded;
            this.presenter.CommandHistory.ModelChanged += this.OnModelChanged;
            intellisense.ItemSelected += OnIntellisenseItemSelected;
        }
Exemple #11
0
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.factor     = model as Factor;
            this.factorView = view as IFactorView;
            this.presenter  = explorerPresenter;
            intellisense    = new IntellisensePresenter(factorView as ViewBase);
            this.factorView.Specification.Value = factor.Specification;

            this.factorView.Specification.Changed += this.OnTextHasChangedByUser;
            this.factorView.Specification.IntellisenseItemsNeeded += this.OnContextItemsNeeded;
            this.presenter.CommandHistory.ModelChanged            += this.OnModelChanged;
            intellisense.ItemSelected += OnIntellisenseItemSelected;
        }
Exemple #12
0
        /// <summary>
        /// Attach the Manager model and ManagerView to this presenter.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="presenter">The explorer presenter being used</param>
        public void Attach(object model, object view, ExplorerPresenter presenter)
        {
            manager                    = model as Manager;
            managerView                = view as IManagerView;
            explorerPresenter          = presenter;
            intellisense               = new IntellisensePresenter(managerView as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            scriptModel = manager.Children.FirstOrDefault();

            // See if manager script has a description attribute on it's class.
            if (scriptModel != null)
            {
                DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(scriptModel.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute;
                if (descriptionName != null)
                {
                    explorerPresenter.ShowDescriptionInRightHandPanel(descriptionName.ToString());
                }
            }

            if (Configuration.Settings.UseNewPropertyPresenter)
            {
                propertyPresenter = new SimplePropertyPresenter();
            }
            else
            {
                propertyPresenter = new PropertyPresenter();
            }
            try
            {
                propertyPresenter.Attach(scriptModel, managerView.PropertyEditor, presenter);
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
            managerView.Editor.Mode = EditorType.ManagerScript;
            managerView.Editor.Text = manager.Code;
#if NETFRAMEWORK
            // In gtk3 builds, the gtksourceview completion infrastructure
            // handles all of the completion functionality internally.
            managerView.Editor.ContextItemsNeeded += OnNeedVariableNames;
#endif
            managerView.Editor.LeaveEditor += OnEditorLeave;
            managerView.Editor.AddContextSeparator();
            managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T");
            managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R");
            managerView.Editor.Location            = manager.Location;
            managerView.TabIndex                   = manager.ActiveTabIndex;
            presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged;
        }
        /// <summary>Attach the cultivar model to the cultivar view</summary>
        /// <param name="model">The mode</param>
        /// <param name="view">The view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.cultivar          = model as Cultivar;
            this.view              = view as IEditorView;
            this.explorerPresenter = explorerPresenter;

            this.view.Lines            = this.cultivar.Command;
            intellisense               = new IntellisensePresenter(this.view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            this.view.LeaveEditor        += this.OnCommandsChanged;
            this.view.ContextItemsNeeded += this.OnContextItemsNeeded;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Exemple #14
0
        /// <summary>Attach the cultivar model to the cultivar view</summary>
        /// <param name="model">The mode</param>
        /// <param name="view">The view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.cultivar          = model as Cultivar;
            this.view              = view as IEditorView;
            this.explorerPresenter = explorerPresenter;

            this.view.Lines            = this.cultivar.Commands;
            intellisense               = new IntellisensePresenter(this.view as ViewBase);
            intellisense.ItemSelected += (sender, e) => this.view.InsertCompletionOption(e.ItemSelected, e.TriggerWord);

            this.view.LeaveEditor        += this.OnCommandsChanged;
            this.view.ContextItemsNeeded += this.OnContextItemsNeeded;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }
Exemple #15
0
        /// <summary>Attach the model and view to this presenter and populate the view.</summary>
        /// <param name="model">The data store model to work with.</param>
        /// <param name="v">Data store view to work with.</param>
        /// <param name="explorerPresenter">Parent explorer presenter.</param>
        public override void Attach(object model, object v, ExplorerPresenter explorerPresenter)
        {
            dataStore = model as IDataStore;
            view      = v as ViewBase;
            this.explorerPresenter = explorerPresenter;

            intellisense = new IntellisensePresenter(this.view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            checkpointDropDown  = view.GetControl <DropDownView>("checkpointDropDown");
            tableDropDown       = view.GetControl <DropDownView>("tableDropDown");
            columnFilterEditBox = view.GetControl <EditView>("columnFilterEditBox");
            rowFilterEditBox    = view.GetControl <EditView>("rowFilterEditBox");
            grid = view.GetControl <GridView>("grid");
            maxNumRecordsEditBox = view.GetControl <EditView>("maxNumRecordsEditBox");

            base.Attach(model, grid, explorerPresenter);

            tableDropDown.IsEditable = false;
            grid.ReadOnly            = true;
            grid.NumericFormat       = "N3";
            if (dataStore != null)
            {
                tableDropDown.Values = dataStore.Reader.TableAndViewNames.ToArray();
                if (tablesFilter != null && tablesFilter.Length > 0)
                {
                    tableDropDown.Values = tableDropDown.Values.Intersect(tablesFilter).ToArray();
                }
                checkpointDropDown.Values = dataStore.Reader.CheckpointNames.ToArray();
                if (checkpointDropDown.Values.Length > 0)
                {
                    checkpointDropDown.SelectedValue = checkpointDropDown.Values[0];
                }
                if (Utility.Configuration.Settings.MaximumRowsOnReportGrid > 0)
                {
                    maxNumRecordsEditBox.Text = Utility.Configuration.Settings.MaximumRowsOnReportGrid.ToString();
                }
                tableDropDown.SelectedIndex = -1;
            }

            tableDropDown.Changed     += this.OnTableSelected;
            columnFilterEditBox.Leave += OnColumnFilterChanged;
            columnFilterEditBox.IntellisenseItemsNeeded += OnIntellisenseNeeded;
            rowFilterEditBox.Leave     += OnColumnFilterChanged;
            maxNumRecordsEditBox.Leave += OnMaximumNumberRecordsChanged;
            checkpointDropDown.Changed += OnCheckpointDropDownChanged;
            PopulateGrid();
        }
        /// <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;
        }
Exemple #17
0
        /// <summary>Attach the model and view to this presenter and populate the view.</summary>
        /// <param name="model">The data store model to work with.</param>
        /// <param name="v">Data store view to work with.</param>
        /// <param name="explorerPresenter">Parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter explorerPresenter)
        {
            dataStore = model as IDataStore;
            var view = v as ViewBase;

            this.explorerPresenter = explorerPresenter;

            intellisense = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            checkpointDropDown  = view.GetControl <DropDownView>("checkpointDropDown");
            tableDropDown       = view.GetControl <DropDownView>("tableDropDown");
            columnFilterEditBox = view.GetControl <EditView>("columnFilterEditBox");
            rowFilterEditBox    = view.GetControl <EditView>("rowFilterEditBox");
            sheetContainer      = view.GetControl <ContainerView>("grid");
            statusLabel         = view.GetControl <LabelView>("statusLabel");

            tableDropDown.IsEditable = false;
            if (dataStore != null)
            {
                tableDropDown.Values = dataStore.Reader.TableAndViewNames.ToArray();
                if (tablesFilter != null && tablesFilter.Length > 0)
                {
                    tableDropDown.Values = tableDropDown.Values.Intersect(tablesFilter).ToArray();
                }
                checkpointDropDown.Values = dataStore.Reader.CheckpointNames.ToArray();
                if (checkpointDropDown.Values.Length > 0)
                {
                    checkpointDropDown.SelectedValue = checkpointDropDown.Values[0];
                }
                if (Utility.Configuration.Settings.MaximumRowsOnReportGrid > 0)
                {
                    statusLabel.Text = Utility.Configuration.Settings.MaximumRowsOnReportGrid.ToString();
                }
                tableDropDown.SelectedIndex = 0;
            }

            tableDropDown.Changed     += this.OnTableSelected;
            columnFilterEditBox.Leave += OnColumnFilterChanged;
            columnFilterEditBox.IntellisenseItemsNeeded += OnIntellisenseNeeded;
            rowFilterEditBox.Leave     += OnColumnFilterChanged;
            checkpointDropDown.Changed += OnCheckpointDropDownChanged;
            PopulateGrid();
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to</param>
        /// <param name="view">The view to connect to</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.grid = view as IGridView;
            this.grid.ContextItemsNeeded += GetContextItems;
            this.model             = model as Model;
            this.explorerPresenter = explorerPresenter;
            this.intellisense      = new IntellisensePresenter(grid as ViewBase);

            // The grid does not have control-space intellisense (for now).
            intellisense.ItemSelected += (sender, e) => grid.InsertText(e.ItemSelected);
            // if the model is Testable, run the test method.
            ITestable testModel = model as ITestable;

            if (testModel != null)
            {
                testModel.Test(false, true);
                this.grid.ReadOnly = true;
            }

            string[] split;

            this.grid.NumericFormat = "G6";
            this.FindAllProperties(this.model);
            if (this.grid.DataSource == null)
            {
                this.PopulateGrid(this.model);
            }
            else
            {
                this.grid.ResizeControls();
                this.FormatTestGrid();
            }

            this.grid.CellsChanged += this.OnCellValueChanged;
            this.grid.ButtonClick  += this.OnFileBrowseClick;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
            if (model != null)
            {
                split = this.model.GetType().ToString().Split('.');
                this.grid.ModelName = split[split.Length - 1];
                this.grid.LoadImage();
            }
        }
Exemple #19
0
        /// <summary>
        /// Attach the Manager model and ManagerView to this presenter.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The explorer presenter being used</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.manager               = model as Manager;
            this.managerView           = view as IManagerView;
            this.explorerPresenter     = explorerPresenter;
            this.intellisense          = new IntellisensePresenter(managerView as ViewBase);
            intellisense.ItemSelected += (sender, e) => managerView.Editor.InsertCompletionOption(e.ItemSelected, e.TriggerWord);

            this.propertyPresenter.Attach(this.manager.Script, this.managerView.GridView, this.explorerPresenter);
            this.managerView.Editor.ScriptMode          = true;
            this.managerView.Editor.Text                = this.manager.Code;
            this.managerView.Editor.ContextItemsNeeded += this.OnNeedVariableNames;
            this.managerView.Editor.LeaveEditor        += this.OnEditorLeave;
            this.managerView.Editor.AddContextSeparator();
            this.managerView.Editor.AddContextActionWithAccel("Test compile", this.OnDoCompile, "Ctrl+T");
            this.managerView.Editor.AddContextActionWithAccel("Reformat", this.OnDoReformat, "Ctrl+R");
            this.managerView.Editor.Location = manager.Location;
            this.managerView.TabIndex        = manager.ActiveTabIndex;
            this.explorerPresenter.CommandHistory.ModelChanged += this.CommandHistory_ModelChanged;
        }
Exemple #20
0
        /// <summary>
        /// Attach the Manager model and ManagerView to this presenter.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="presenter">The explorer presenter being used</param>
        public void Attach(object model, object view, ExplorerPresenter presenter)
        {
            manager                    = model as Manager;
            managerView                = view as IManagerView;
            explorerPresenter          = presenter;
            intellisense               = new IntellisensePresenter(managerView as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            scriptModel = manager.Children.FirstOrDefault();
            propertyPresenter.Attach(scriptModel, managerView.GridView, presenter);
            managerView.Editor.Mode = EditorType.ManagerScript;
            managerView.Editor.Text = manager.Code;
            managerView.Editor.ContextItemsNeeded += OnNeedVariableNames;
            managerView.Editor.LeaveEditor        += OnEditorLeave;
            managerView.Editor.AddContextSeparator();
            managerView.Editor.AddContextActionWithAccel("Test compile", OnDoCompile, "Ctrl+T");
            managerView.Editor.AddContextActionWithAccel("Reformat", OnDoReformat, "Ctrl+R");
            managerView.Editor.Location            = manager.Location;
            managerView.TabIndex                   = manager.ActiveTabIndex;
            presenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged;
        }
Exemple #21
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            presenter                = parentPresenter;
            view                     = v as IDualGridView;
            tableModel               = model as IModelAsTable;
            tables                   = tableModel.Tables;
            view.Grid1.DataSource    = tables[0];
            view.Grid2.DataSource    = tables[1];
            view.Grid1.CellsChanged += OnCellValueChanged1;
            view.Grid2.CellsChanged += OnCellValueChanged2;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            gridPresenter1 = new GridPresenter();
            gridPresenter1.Attach(model, view.Grid1, parentPresenter);
            gridPresenter2 = new GridPresenter();
            gridPresenter2.Attach(model, view.Grid2, parentPresenter);

            intellisense = new IntellisensePresenter(view.Grid2 as ViewBase);
            intellisense.ItemSelected     += OnIntellisenseItemSelected;
            view.Grid2.ContextItemsNeeded += OnIntellisenseItemsNeeded;
        }
        /// <summary>Attach the model and view to this presenter.</summary>
        /// <param name="model">The graph model to work with</param>
        /// <param name="view">The series view to work with</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.series                = model as Series;
            this.seriesView            = view as SeriesView;
            this.explorerPresenter     = explorerPresenter;
            intellisense               = new IntellisensePresenter(seriesView as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;

            Graph parentGraph = Apsim.Parent(series, typeof(Graph)) as Graph;

            if (parentGraph != null)
            {
                graphPresenter = new GraphPresenter();
                explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                graphPresenter.Attach(parentGraph, seriesView.GraphView, explorerPresenter);
            }

            PopulateView();

            ConnectViewEvents();
        }
        /// <summary>
        /// Attach model to view.
        /// </summary>
        /// <param name="model">The 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.operations            = model as Operations;
            this.view                  = view as EditorView;
            this.explorerPresenter     = explorerPresenter;
            this.intellisense          = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += (sender, e) =>
            {
                if (e.TriggerWord == string.Empty)
                {
                    this.view.InsertAtCaret(e.ItemSelected);
                }
                else
                {
                    int position = this.view.Text.Substring(0, this.view.Offset).LastIndexOf(e.TriggerWord);
                    this.view.InsertCompletionOption(e.ItemSelected, e.TriggerWord);
                }
            };

            this.PopulateEditorView();
            this.view.ContextItemsNeeded   += this.OnContextItemsNeeded;
            this.view.TextHasChangedByUser += this.OnTextHasChangedByUser;
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
        }