<commit_before><?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * openwms.org, the Open Warehouse Management System.
 *
 * This file is part of openwms.org.
 *
 * openwms.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * openwms.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software. If not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="org.openwms.web.flex.client.business.*"
	xmlns:control="org.openwms.web.flex.client.control.*" xmlns:event="org.openwms.web.flex.client.event.*" xmlns:view="org.openwms.web.flex.client.view.*" layout="absolute"
	backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" creationComplete="init()">

	<!-- Styles -->
	<mx:Style source="/assets/css/main.css" />
	<mx:Style source="/assets/css/styles.css" />
	
	<!-- Scripts -->
	<mx:Script>
		<![CDATA[
			import mx.events.ModuleEvent;
            import mx.events.MenuEvent;
			import mx.modules.IModuleInfo;
			import mx.modules.ModuleManager;
            import mx.managers.PopUpManager;
            import mx.managers.DragManager;
            import mx.messaging.channels.AMFChannel;
            import mx.messaging.ChannelSet;
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.collections.XMLListCollection;
			import mx.controls.Alert;
            import flash.events.Event;
            import org.openwms.web.flex.client.IApplicationModule;
			import org.openwms.web.flex.client.model.ModelLocator;
            import org.openwms.web.flex.client.control.MainController;
            import org.openwms.web.flex.client.service.ModuleLocator;
			import org.openwms.web.flex.client.event.SwitchScreenEvent;
			import org.openwms.web.flex.client.event.ApplicationEvent;
            import org.openwms.web.flex.client.event.ModulesEvent;
            import org.openwms.web.flex.client.event.EventBroker;
            import org.openwms.web.flex.client.command.LoadModulesCommand;
			import org.openwms.common.domain.Module;
			import org.openwms.common.domain.MenuItem;
            import org.granite.rpc.remoting.mxml.SecureRemoteObject;
            import org.granite.events.SecurityEvent;

			[Bindable]
			private var modelLocator:ModelLocator = ModelLocator.getInstance();
            [Bindable]
            private var moduleLocator:ModuleLocator = ModuleLocator.getInstance();
            [Bindable]
            private var broker:EventBroker = EventBroker.getInstance();
			[Bindable]
            private var srv:SecureRemoteObject = null;
            [Bindable]
            protected var mainController = new MainController(); 
            [Bindable]
            public var menuBarCollection:XMLListCollection;
            [Bindable]
            var menuItems:ArrayCollection;
            
            // Manager classes are loaded to the application domain
            private var moduleManager:ModuleManager; 
            private var popUpManager:PopUpManager;
            private var dragManager:DragManager;
            private var mInfo:IModuleInfo
            
			public function init():void {
                srv = new SecureRemoteObject("userService");
                //srv.login();
                registerEventListeners();
                detectModules();
                //configService.send();
			}
			
            public function onSecurityEvent(event:SecurityEvent):void {
                trace("onSecurityEvent: " + event);
                switch (event.type) {
                case SecurityEvent.INVALID_CREDENTIALS:
                    loginView.loginMessageText = "Invalid username or password";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.NOT_LOGGED_IN:
                    srv.logout();
                    loginView.loginMessageText = "";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.SESSION_EXPIRED:
                    srv.logout();
                    loginView.loginMessageText = "Session expired";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.ACCESS_DENIED:
                    Alert.show("You don't have required rights to execute this action");
                    break;
                }
            }

			private function onMenuChange(event:MenuEvent):void {
				trace("Switching to view:"+event.item.@action);
				new SwitchScreenEvent(event.item.@action).dispatch();
			}
			
            public function login(username:String, password:String):void {
                srv.setCredentials(username, password);
                srv.login();
            }

            public function logout():void {
                srv.logout();
                loginView.authenticated = false;
                loginView.loginMessageText = "";
            }
            
            private function registerEventListeners():void {
                var broker:EventBroker = EventBroker.getInstance();
                broker.addEventListener(ApplicationEvent.MODULE_CONFIG_CHANGED, moduleConfigChanged);
                // When all modules are loaded from DB then notify application to start modules automatically ...
                broker.addEventListener(ModulesEvent.MODULES_LOADED, loadAllModules);
            }
            
            /**
             * In the case the Module confifuration has changed, a re-organize of menus and
             * views becomes necessary.
             */ 
            private function moduleConfigChanged(event:ApplicationEvent):void {
                // Modules were loaded, hence update viewStack, menuBar and popUps...
                if (event.data != null && event.data is IApplicationModule) 
                {
                    var appModule:IApplicationModule = (event.data as IApplicationModule);
                    trace("Configuration changed for Module:"+appModule.getModuleName());
                    // Resolve MenuItems to populate application menu...
                    menuItems = appModule.getMainMenuItems();
                    //mainMenuBar.dataProvider.removeAll();
                    for each (var m:Object in menuItems) {
                        trace("m:"+m);
                    }
                    mainMenuBar.dataProvider = menuItems ;
                }
            }
            
            /**
             * This method rebuilds the viewStack of the application, and should be called,
             * in case application modules are loaded or unloaded.
             */
            private function refreshViewStack()
            {
                
            }
            
            /**
             * This method rebuilds the main application menu and should be called
             * in case an application module is loaded or unloaded.
             * The main menu, could be an MenuBar or any other kind of menu.
             */
            private function refreshMainMenu()
            {
                
            }
            <commit_msg>Started to modularize the app<commit_after><?xml version="1.0" encoding="utf-8"?>
<!--
/*
 * openwms.org, the Open Warehouse Management System.
 *
 * This file is part of openwms.org.
 *
 * openwms.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * openwms.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software. If not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:business="org.openwms.web.flex.client.business.*"
	xmlns:control="org.openwms.web.flex.client.control.*" xmlns:event="org.openwms.web.flex.client.event.*" xmlns:view="org.openwms.web.flex.client.view.*" layout="absolute"
	backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]" creationComplete="init()">

	<!-- Styles -->
	<mx:Style source="/assets/css/main.css" />
	<mx:Style source="/assets/css/styles.css" />
	
	<!-- Scripts -->
	<mx:Script>
		<![CDATA[
			import mx.events.ModuleEvent;
            import mx.events.MenuEvent;
			import mx.modules.IModuleInfo;
			import mx.modules.ModuleManager;
            import mx.managers.PopUpManager;
            import mx.managers.DragManager;
            import mx.messaging.channels.AMFChannel;
            import mx.messaging.ChannelSet;
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.collections.XMLListCollection;
			import mx.controls.Alert;
            import flash.events.Event;
            import org.openwms.web.flex.client.IApplicationModule;
			import org.openwms.web.flex.client.model.ModelLocator;
            import org.openwms.web.flex.client.control.MainController;
            import org.openwms.web.flex.client.service.ModuleLocator;
			import org.openwms.web.flex.client.event.SwitchScreenEvent;
			import org.openwms.web.flex.client.event.ApplicationEvent;
            import org.openwms.web.flex.client.event.ModulesEvent;
            import org.openwms.web.flex.client.event.EventBroker;
            import org.openwms.web.flex.client.command.LoadModulesCommand;
			import org.openwms.common.domain.Module;
			import org.openwms.common.domain.MenuItem;
            import org.granite.rpc.remoting.mxml.SecureRemoteObject;
            import org.granite.events.SecurityEvent;
            import org.openwms.web.flex.client.command.*;
            import org.openwms.web.flex.client.event.UserEvent;
            import org.openwms.web.flex.client.event.SwitchScreenEvent;
            import org.openwms.web.flex.client.event.LoadLocationGroupsEvent;
            import org.openwms.web.flex.client.event.LocationEvent;
            import org.openwms.web.flex.client.event.ApplicationEvent;

			[Bindable]
			private var modelLocator:ModelLocator = ModelLocator.getInstance();
            [Bindable]
            private var moduleLocator:ModuleLocator = ModuleLocator.getInstance();
            [Bindable]
            private var broker:EventBroker = EventBroker.getInstance();
			[Bindable]
            private var srv:SecureRemoteObject = null;
            [Bindable]
            protected var mainController:MainController = new MainController(); 
            [Bindable]
            public var menuBarCollection:XMLListCollection;
            [Bindable]
            protected var menuItems:ArrayCollection;
            
            // Manager classes are loaded to the application domain
            private var moduleManager:ModuleManager; 
            private var popUpManager:PopUpManager;
            private var dragManager:DragManager;
            private var mInfo:IModuleInfo
            
			public function init():void {
                srv = new SecureRemoteObject("userService");
                //srv.login();
                registerEventListeners();
                bindCommands();
                detectModules();
                //configService.send();
			}
			
			private function bindCommands():void
			{
                mainController.addCommand(UserEvent.LOAD_ALL_USERS, LoadUsersCommand);
                mainController.addCommand(UserEvent.ADD_USER, AddUserCommand);
                mainController.addCommand(UserEvent.SAVE_USER, SaveUserCommand);
                mainController.addCommand(UserEvent.DELETE_USER, DeleteUserCommand);

                mainController.addCommand(SwitchScreenEvent.SHOW_STARTSCREEN, ShowStartscreenCommand);
                mainController.addCommand(SwitchScreenEvent.SHOW_MODULE_MGMT_VIEW, ShowModuleManagementViewCommand);
                mainController.addCommand(SwitchScreenEvent.SHOW_LOCATION_VIEW, ShowLocationViewCommand);
                mainController.addCommand(SwitchScreenEvent.SHOW_LOCATIONGROUP_VIEW, ShowLocationGroupCommand);
                mainController.addCommand(SwitchScreenEvent.SHOW_USER_MGMT_VIEW, ShowUserManagementViewCommand);
                mainController.addCommand(SwitchScreenEvent.SHOW_TRANSPORTUNIT_VIEW, ShowTransportUnitCommand);

                mainController.addCommand(LoadLocationGroupsEvent.LOAD_ALL_LOCATION_GROUPS, LoadLocationGroupsCommand);
                mainController.addCommand(LocationEvent.LOAD_ALL_LOCATIONS, LoadLocationsCommand);

                mainController.addCommand(ApplicationEvent.LOAD_ALL_MODULES, LoadModulesCommand);
                mainController.addCommand(ApplicationEvent.SAVE_MODULE, SaveModuleCommand);
                mainController.addCommand(ApplicationEvent.DELETE_MODULE, DeleteModuleCommand);
			}
			
            public function onSecurityEvent(event:SecurityEvent):void {
                trace("onSecurityEvent: " + event);
                switch (event.type) {
                case SecurityEvent.INVALID_CREDENTIALS:
                    loginView.loginMessageText = "Invalid username or password";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.NOT_LOGGED_IN:
                    srv.logout();
                    loginView.loginMessageText = "";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.SESSION_EXPIRED:
                    srv.logout();
                    loginView.loginMessageText = "Session expired";
                    loginView.authenticated = false;
                    break;
                case SecurityEvent.ACCESS_DENIED:
                    Alert.show("You don't have required rights to execute this action");
                    break;
                }
            }

			private function onMenuChange(event:MenuEvent):void {
				trace("Switching to view:"+event.item.@action);
				new SwitchScreenEvent(event.item.@action).dispatch();
			}
			
            public function login(username:String, password:String):void {
                srv.setCredentials(username, password);
                srv.login();
            }

            public function logout():void {
                srv.logout();
                loginView.authenticated = false;
                loginView.loginMessageText = "";
            }
            
            private function registerEventListeners():void {
                var broker:EventBroker = EventBroker.getInstance();
                broker.addEventListener(ApplicationEvent.MODULE_CONFIG_CHANGED, moduleConfigChanged);
                // When all modules are loaded from DB then notify application to start modules automatically ...
                broker.addEventListener(ModulesEvent.MODULES_LOADED, loadAllModules);
            }
            
            /**
             * In the case the Module confifuration has changed, a re-organize of menus and
             * views becomes necessary.
             */ 
            private function moduleConfigChanged(event:ApplicationEvent):void {
                // Modules were loaded, hence update viewStack, menuBar and popUps...
                if (event.data != null && event.data is IApplicationModule) 
                {
                    var appModule:IApplicationModule = (event.data as IApplicationModule);
                    trace("Configuration changed for Module:"+appModule.getModuleName());
                    // Resolve MenuItems to populate application menu...
                    menuItems = appModule.getMainMenuItems();
                    //mainMenuBar.dataProvider.removeAll();
                    for each (var m:Object in menuItems) {
                        trace("m:"+m);
                    }
                    mainMenuBar.dataProvider = menuItems ;
                }
            }
            
            /**
             * This method rebuilds the viewStack of the application, and should be called,
             * in case application modules are loaded or unloaded.
             */
            private function refreshViewStack():void
            {
                
            }
            
            /**
             * This method rebuilds the main application menu and should be called
             * in case an application module is loaded or unloaded.
             * The main menu, could be an MenuBar or any other kind of menu.
             */
            private function refreshMainMenu():void
            {
                
            }
            
{'fraction_non_alphanumeric': 0.08528150900257217, 'fraction_numerical': 0.002629322663618177, 'mean_word_length': 2.0343392299687824, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 2, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3234786', 'n_tokens_mistral': 4543, 'n_tokens_neox': 4280, 'n_words': 1013}