/// <summary>
        /// Returns true if the Detail will be shown in the Tree
        /// </summary>
        /// <param name="lDetail"></param>
        /// <returns></returns>
        private bool CalculateShowInTree(IDetailController detail)
        {
            // If it has no role path, won't be shown in the Tree
            ExchangeInfoNavigation lNavInfo = detail.ExchangeInformation as ExchangeInfoNavigation;

            if (lNavInfo != null && lNavInfo.RolePath.Equals(""))
            {
                return(false);
            }

            // If it is a Master Detail and its Master is a Population with Filters, won't be shown in the Tree
            IUMasterDetailController lMasterDetail = detail as IUMasterDetailController;

            if (lMasterDetail != null)
            {
                IUPopulationController lPopulationController = lMasterDetail.Master as IUPopulationController;
                if (lPopulationController != null && lPopulationController.Filters.Count > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            // It is not a Master Detail and its role path is not empty
            return(false);
        }
        /// <summary>
        /// ANalize the Master Detail controller and creates the suitable nodes
        /// </summary>
        /// <param name="masterDetailController"></param>
        /// <param name="showDetailsGroupingNode"></param>
        private void InitializeMasterDetailNode(IUMasterDetailController masterDetailController, bool showDetailsGroupingNode)
        {
            // Keep the Master information.
            QueryContext = masterDetailController.Master.Context;
            // Initialize the DisplaySet information.
            mDisplaySetInfo = new DisplaySetInformation(masterDetailController.Master.DisplaySet.DisplaySetList[0].Name);
            // It has to be considered only the items that the agent is able to access.
            mDisplaySetInfo.DisplaySetItems   = masterDetailController.Master.DisplaySet.DisplaySetList[0].GetVisibleDisplaySetItems(Logic.Agent.ClassName);
            QueryContext.DisplaySetAttributes = mDisplaySetInfo.GetDisplaySetItemsAsString();
            Alias      = CultureManager.TranslateString(masterDetailController.IdXMLDetailAlias, masterDetailController.DetailAlias);
            Action     = masterDetailController.Master.Action;
            Navigation = masterDetailController.Master.Navigation;
            masterDetailController.Master.Action     = null;
            masterDetailController.Master.Navigation = null;
            IUPopulationController lPopController = masterDetailController.Master as IUPopulationController;

            if (lPopController != null)
            {
                foreach (IUFilterController lFilter in lPopController.Filters)
                {
                    Filters.Add(lFilter);
                }
                lPopController.Filters.Clear();
            }

            // Analize every detail properties
            #region Details sub-nodes creation
            int nodeCounter             = 0;
            TreeNodeController lSubNode = null;

            // Process all the Master-Detail details, in order to create the suitable sub-nodes.
            foreach (IDetailController lDetail in masterDetailController.Details)
            {
                bool lShowInTree = CalculateShowInTree(lDetail);
                lSubNode = new TreeNodeController(NodeId, NodeId + "_" + nodeCounter.ToString(), lDetail, null, false, showDetailsGroupingNode, lShowInTree);
                mSubNodes.Add(lSubNode);
                // Suscribe subnode events
                lSubNode.RefreshRequired += new EventHandler <RefreshNodeRequiredEventArgs>(HandleSubNodeRefreshRequired);
                lSubNode.ContextRequired += new EventHandler <ContextRequiredEventArgs>(HandleSubNodeContextRequired);
                nodeCounter++;

                // Special situation. If this Detail won't be shown in the Tree
                //  assign the FinalNodeController. Only for the first one
                if (!lSubNode.ShowInTree && FinalNodeQueryController == null)
                {
                    FinalNodeID = lSubNode.NodeId;
                    FinalNodeQueryController  = lDetail;
                    lSubNode.ShowGroupingNode = false;
                }
            }
            #endregion Details sub-nodes creation

            // Empty the detail list
            masterDetailController.Details.Clear();
        }
        /// <summary>
        /// Calculate if the node representing the Master will require Intermedia nodes
        /// </summary>
        /// <param name="masterDetailController"></param>
        /// <returns></returns>
        private bool CalculateDetailsGroupingNode(IUMasterDetailController masterDetailController)
        {
            // If there is just one detail
            if (masterDetailController.Details.Count == 1)
            {
                return(false);
            }

            // If there is more than 2
            if (masterDetailController.Details.Count > 2)
            {
                return(true);
            }

            // There is only 2
            int lNumNoPath   = 0;
            int lNumNoInTree = 0;

            foreach (IDetailController lDetail in masterDetailController.Details)
            {
                ExchangeInfoNavigation lNavInfo = lDetail.ExchangeInformation as ExchangeInfoNavigation;
                if (lNavInfo != null && lNavInfo.RolePath.Equals(""))
                {
                    lNumNoPath++;
                }
                else
                {
                    IUMasterDetailController lMasterDetail = lDetail as IUMasterDetailController;
                    if (lMasterDetail != null)
                    {
                        // This detail won't de represented in the Tree if the Master is a population with filters
                        IUPopulationController lPopController = lMasterDetail.Master as IUPopulationController;
                        if (lPopController != null && lPopController.Filters.Count > 0)
                        {
                            lNumNoInTree++;
                        }
                    }
                    else
                    {
                        lNumNoInTree++;
                    }
                }
            }

            // Just one can be shown when this node is selected or both must appear in the tree
            if (lNumNoPath + lNumNoInTree != 1)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Initializes the 'PIU_PasajeroAeronaveIT' instance form
        /// </summary>
        /// <param name="exchangeInfo">Exchange information.</param>
        /// <returns>IUPopulationController</returns>
        public IUPopulationController Initialize(ExchangeInfo exchangeInfo)
        {
            // Controller factory.
            Controller = ControllerFactory.PasajeroAeronave.Population_PIU_PasajeroAeronave(exchangeInfo);
            Controller.Scenario = new ScenarioPresentation(this, ScenarioType.Population);

            #region Population PIU_PasajeroAeronave Links

            // Displayset
            Controller.DisplaySet.Population = new DataGridViewPresentation(this.gPopulation, this.toolStripExportExcel, this.toolStripExportWord, this.toolStripRetrieveAll, this.toolStripRefresh, this.toolStripHelp, this.optionsToolStripMenuItem, this.mnuNavigations, exchangeInfo);
            Controller.DisplaySet.NumberOfInstances = new ToolStripStatusLabelNumberInstancesPresentation(this.toolStripStatusLabelCount);
            Controller.DisplaySet.First = null;
            Controller.DisplaySet.Previous = null;
            Controller.DisplaySet.Refresh = null;
            Controller.DisplaySet.Next = null;
            Controller.DisplaySet.ExecuteServiceTrigger = new ToolStripDropDownButtonPresentation(this.toolStripDropDownButtonSave);
            Controller.DisplaySet.PreferencesTrigger = new ToolStripMenuItemPresentation(this.toolStripPreferences);
            Controller.DisplaySet.SaveColumnsWidthTrigger = new ToolStripMenuItemPresentation(this.toolStripSaveColumnWidth);
            // Order Criteria

            // Actions
            Controller.Action.ActionItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripActions_0,this.mnuActions_0);
            Controller.Action.ActionItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripActions_1,this.mnuActions_1);
            Controller.Action.ActionItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripActions_2,this.mnuActions_2);
            Controller.Action.ActionItems[3].Trigger = new ToolStripButtonPresentation(this.toolstripActions_3,this.mnuActions_3);
            Controller.Action.ActionItems[4].Trigger = new ToolStripButtonPresentation(this.toolstripActions_4,this.mnuActions_4);
            Controller.Action.ActionItems[5].Trigger = new ToolStripButtonPresentation(this.toolStripPrint,this.mnuPrint);

            // Navigations
            Controller.Navigation.NavigationItems[0].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_0, this.mnuNavigations_0);
            Controller.Navigation.NavigationItems[1].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_1, this.mnuNavigations_1);
            Controller.Navigation.NavigationItems[2].Trigger = new ToolStripButtonPresentation(this.toolstripNavigations_2, this.mnuNavigations_2);

            // Contextual Menu
            this.gPopulation.ContextMenuStrip = this.contextMenuStrip;
            #endregion Population PIU_PasajeroAeronave Links

            // Save position trigger
            Controller.SavePositionTrigger = new ToolStripMenuItemPresentation(this.toolStripSavePositions);

            // Ok.
            Controller.OkTrigger = new ButtonPresentation(this.bOk);
            // Cancel.
            Controller.CancelTrigger = new ButtonPresentation(this.bCancel);

            // Initialize controller.
            Controller.Initialize();

            return Controller;
        }
        /// <summary>
        /// Initialize pagination state, for detail of this master.
        /// </summary>
        /// <param name="controller">Detail pattern controller.</param>
        /// <returns></returns>
        private bool ClearLastOids(IDetailController controller)
        {
            if (controller != null)
            {
                switch (controller.Context.ContextType)
                {
                case ContextType.Population:
                    IUPopulationController lPopulationController = controller as IUPopulationController;
                    if (lPopulationController != null)
                    {
                        if (lPopulationController.Context != null)
                        {
                            lPopulationController.Context.LastOids.Clear();
                            return(true);
                        }
                    }
                    return(false);

                case ContextType.MasterDetail:
                    IUMasterDetailController masterDetailController = controller as IUMasterDetailController;
                    if (masterDetailController != null)
                    {
                        ClearLastOids(masterDetailController.Master);

                        foreach (IDetailController lDetail in masterDetailController.Details)
                        {
                            if (!ClearLastOids(lDetail as IUMasterDetailController))
                            {
                                ClearLastOids(lDetail);
                            }
                        }
                        return(true);
                    }
                    break;

                default:
                    return(true);
                }
            }

            return(true);
        }
        /// <summary>
        /// Updates the final controller data, the related instances with the received Oid
        /// </summary>
        /// <param name="parentOid"></param>
        /// <returns></returns>
        internal bool UpdateFinalControllerData(Oid parentOid)
        {
            if (FinalNodeQueryController == null)
            {
                return(false);
            }

            // Update the exchange information
            List <Oid>             lOids      = new List <Oid>();
            ExchangeInfo           lExchgInfo = null;
            ExchangeInfoNavigation lInfoNav   = null;

            if (parentOid != null)
            {
                lOids.Add(parentOid);
            }
            lExchgInfo            = FinalNodeQueryController.ExchangeInformation;
            lInfoNav              = new ExchangeInfoNavigation(lExchgInfo as ExchangeInfoNavigation);
            lInfoNav.SelectedOids = lOids;
            FinalNodeQueryController.ExchangeInformation = lInfoNav;

            // Clear the last Oid in the population controller
            IUPopulationController lPopulationController = FinalNodeQueryController as IUPopulationController;

            if (lPopulationController != null)
            {
                lPopulationController.Context.LastOid = null;
                lPopulationController.Context.LastOids.Clear();
            }

            // Refresh data in the controller
            FinalNodeQueryController.UpdateData(true);

            if (lOids.Count == 0)
            {
                return(false);
            }

            return(true);
        }
示例#7
0
        /// <summary>
        /// Creates the specific IUPopulationController of the 'PIU_NaveNodriza' IU pattern.
        /// </summary>
        /// <param name="exchangeInfo">IUPopulationContext reference.</param>
        /// <returns>Specific IUPopulationController of the 'PIU_NaveNodriza' IU pattern.</returns>
        public static IUPopulationController Population_PIU_NaveNodriza(ExchangeInfo exchangeInfo)
        {
            IUPopulationContext lContext = new IUPopulationContext(exchangeInfo,"NaveNodriza", "PIU_NaveNodriza");
            // Block size.
            lContext.BlockSize = 40;
            IUPopulationController lController = new IUPopulationController("PIU_NaveNodriza", "PIU_NaveNodriza", "Clas_1347649273856884UIPobCl_1_Alias", lContext, null);

            // Action _Auto_.
            lController.Action = NaveNodriza.Action__Auto_(lController);
            // DisplaySet '_Auto_'.
            DisplaySetByBlocksController lDisplaySetByBlocksController = new DisplaySetByBlocksController(NaveNodriza.DisplaySet__Auto_(lController));
            lController.DisplaySet = lDisplaySetByBlocksController;
            // Get user preferences for this scenario.
            lController.SetPreferences(Logic.UserPreferences.GetScenarioPrefs("NaveNodriza:PIU_NaveNodriza") as PopulationPrefs);

            return lController;
        }
示例#8
0
        /// <summary>
        /// Creates the specific IUPopulationController of the 'PIU_Pasajero' IU pattern.
        /// </summary>
        /// <param name="exchangeInfo">IUPopulationContext reference.</param>
        /// <returns>Specific IUPopulationController of the 'PIU_Pasajero' IU pattern.</returns>
        public static IUPopulationController Population_PIU_Pasajero(ExchangeInfo exchangeInfo)
        {
            IUPopulationContext lContext = new IUPopulationContext(exchangeInfo,"Pasajero", "PIU_Pasajero");
            // Block size.
            lContext.BlockSize = 40;
            IUPopulationController lController = new IUPopulationController("PIU_Pasajero", "Pasajero", "Clas_1348178542592658UIPobCl_1_Alias", lContext, null);

            // Action _Auto_.
            lController.Action = Pasajero.Action__Auto_(lController);
            // Navigation _Auto_.
            lController.Navigation = Pasajero.Navigation__Auto_(lController);
            // DisplaySet '_Auto_'.
            DisplaySetByBlocksController lDisplaySetByBlocksController = new DisplaySetByBlocksController(Pasajero.DisplaySet__Auto_(lController));
            lController.DisplaySet = lDisplaySetByBlocksController;
            // Get user preferences for this scenario.
            lController.SetPreferences(Logic.UserPreferences.GetScenarioPrefs("Pasajero:PIU_Pasajero") as PopulationPrefs);

            return lController;
        }
示例#9
0
        /// <summary>
        /// Creates the specific IUPopulationController of the '_Auto_' IU pattern.
        /// </summary>
        /// <param name="exchangeInfo">IUPopulationContext reference.</param>
        /// <returns>Specific IUPopulationController of the '_Auto_' IU pattern.</returns>
        public static IUPopulationController Population__Auto_(ExchangeInfo exchangeInfo)
        {
            IUPopulationContext lContext = new IUPopulationContext(exchangeInfo,"Revision", "_Auto_");
            // Block size.
            lContext.BlockSize = 40;
            IUPopulationController lController = new IUPopulationController("_Auto_", "Revision", "Clas_1348178542592347UIPobCl_Auto_Alias", lContext, null);

            // Action _Auto_.
            lController.Action = Revision.Action__Auto_(lController);
            // Navigation _Auto_.
            lController.Navigation = Revision.Navigation__Auto_(lController);
            // DisplaySet '_Auto_'.
            DisplaySetByBlocksController lDisplaySetByBlocksController = new DisplaySetByBlocksController(Revision.DisplaySet__Auto_(lController));
            lDisplaySetByBlocksController.DisplaySetList.Add(Revision.DisplaySet__Auto_(lController).CurrentDisplaySet);
            lController.DisplaySet = lDisplaySetByBlocksController;
            // Get user preferences for this scenario.
            lController.SetPreferences(Logic.UserPreferences.GetScenarioPrefs("Revision:_Auto_") as PopulationPrefs);

            return lController;
        }