Beispiel #1
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;
        }
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                // Create the grid to display data in
                gridView = new GridView(clemPresenter.view as ViewBase);
                GridPresenter gridPresenter = new GridPresenter();

                // Generate the table using the model
                pivot = clemPresenter.clemModel as ReportPivot;
                gridView.DataSource = pivot.GenerateTable();
                gridPresenter.Attach(null, gridView, clemPresenter.explorerPresenter);

                // Attach the view to display data

                clem = clemPresenter.view as CLEMView;
                clem.AddTabView("Data", gridView);
                clemPresenter.presenterList.Add("Data", this);

                //clem.TabSelected += Refresh;
            }
            catch (Exception err)
            {
                clemPresenter.explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Beispiel #3
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                // Create the grid to display data in
                gridView = new GridView(clemPresenter.View as ViewBase);
                GridPresenter gridPresenter = new GridPresenter();

                // Create the SQL display
                sqlView = new TextInputView(clemPresenter.View as ViewBase);

                // Generate the table using the model
                pivot = clemPresenter.ClemModel as ReportPivot;
                gridPresenter.Attach(null, gridView, clemPresenter.ExplorerPresenter);

                // Attach the views to display data
                clem = clemPresenter.View as CLEMView;

                clem.AddTabView("Data", gridView);
                clemPresenter.PresenterList.Add("Data", this);

                clem.AddTabView("SQL", sqlView);
                clemPresenter.PresenterList.Add("SQL", this);
            }
            catch (Exception err)
            {
                clemPresenter.ExplorerPresenter.MainPresenter.ShowError(err);
            }
        }
        /// <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);
        }
Beispiel #5
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;
        }
Beispiel #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)
        {
            explorerPresenter = parentPresenter;
            view       = v as IDualGridView;
            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;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            propertyPresenter = new PropertyPresenter();
            explorerPresenter.ApsimXFile.Links.Resolve(propertyPresenter);
            propertyPresenter.Attach(model, view.Grid1, parentPresenter);
            gridPresenter = new GridPresenter();
            gridPresenter.Attach(model, view.Grid2, parentPresenter);
        }
Beispiel #7
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                clem  = clemPresenter.View as CLEMView;
                query = clemPresenter.ClemModel as ReportQuery;

                var store = query.FindInScope <IDataStore>();

                // Create the Data presenter
                gridView = new GridView(clemPresenter.View as ViewBase);

                var gridPresenter = new GridPresenter();
                gridPresenter.Attach(null, gridView, clemPresenter.ExplorerPresenter);

                // Attach the tab
                clem.AddTabView("Data", gridView);
                clemPresenter.PresenterList.Add("Data", this);
            }
            catch (Exception err)
            {
                clemPresenter.ExplorerPresenter.MainPresenter.ShowError(err);
            }
        }