info.magnolia.ui.framework.app
Class AppControllerImpl

java.lang.Object
  extended by info.magnolia.ui.framework.app.AppControllerImpl
All Implemented Interfaces:
info.magnolia.event.EventHandler, AppController, LocationChangedEvent.Handler, LocationChangeRequestedEvent.Handler

@Singleton
public class AppControllerImpl
extends Object
implements AppController, LocationChangedEvent.Handler, LocationChangeRequestedEvent.Handler

Implementation of the AppController. The App controller that manages the lifecycle of running apps and raises callbacks to the app. It provides methods to start, stop and focus already running Apps. Registers handlers to the following location change events triggered by the LocationController:

See Also:
LocationController, AppContext, App

Constructor Summary
AppControllerImpl(info.magnolia.module.ModuleRegistry moduleRegistry, info.magnolia.objectfactory.ComponentProvider componentProvider, AppDescriptorRegistry appDescriptorRegistry, LocationController locationController, info.magnolia.event.EventBus admincentralEventBus, MessagesManager messagesManager, info.magnolia.i18nsystem.SimpleTranslator i18n)
           
 
Method Summary
 void focusCurrentApp()
           
 Location getAppLocation(String appName)
          Returns the current location of a running app instance or null, if it is not running.
 App getCurrentApp()
           
 Location getCurrentAppLocation()
          Returns the current location of the focused app.
 boolean isAppStarted(String appName)
           
 void onLocationChanged(LocationChangedEvent event)
          Takes care of LocationChangedEvents by: Obtaining the AppDescriptor associated with the Location. Creating a new AppContext if not running, otherwise obtain it from the running apps. Updating the and redirecting in case of missing subAppId. Starting the App. Adding the AppContext to the appHistory. Setting the viewport and updating the current running app.
 void onLocationChangeRequested(LocationChangeRequestedEvent event)
           
 void openChooseDialog(String appName, UiContext uiContext, String selectedId, ChooseDialogCallback callback)
           
 void setViewport(Viewport viewport)
           
 App startIfNotAlreadyRunning(String appName, Location location)
          Deprecated. 
 App startIfNotAlreadyRunningThenFocus(String appName, Location location)
          This method can be called to launch an App and then delegate it to the LocationController.
 void stopApp(String appName)
           
 void stopCurrentApp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppControllerImpl

@Inject
public AppControllerImpl(info.magnolia.module.ModuleRegistry moduleRegistry,
                                info.magnolia.objectfactory.ComponentProvider componentProvider,
                                AppDescriptorRegistry appDescriptorRegistry,
                                LocationController locationController,
                                @Named(value="admincentral")
                                info.magnolia.event.EventBus admincentralEventBus,
                                MessagesManager messagesManager,
                                info.magnolia.i18nsystem.SimpleTranslator i18n)
Method Detail

setViewport

public void setViewport(Viewport viewport)
Specified by:
setViewport in interface AppController

startIfNotAlreadyRunningThenFocus

public App startIfNotAlreadyRunningThenFocus(String appName,
                                             Location location)
This method can be called to launch an App and then delegate it to the LocationController. It should have the same effect as calling the LocationController directly.

Parameters:
appName - of the App to start.
location - holds information about the subApp to use and the parameters.

startIfNotAlreadyRunning

@Deprecated
public App startIfNotAlreadyRunning(String appName,
                                               Location location)
Deprecated. 

This method is called to launch an app independent from the LocationController. It will not open in the Viewport. This is e.g. used to pass the App into a dialog and obtain app-specific information from outside the app. See MGNLUI-379.

Parameters:
appName - of the App to start.
location - holds information about the subApp to use and the parameters.

stopApp

public void stopApp(String appName)
Specified by:
stopApp in interface AppController

stopCurrentApp

public void stopCurrentApp()
Specified by:
stopCurrentApp in interface AppController

isAppStarted

public boolean isAppStarted(String appName)
Specified by:
isAppStarted in interface AppController

focusCurrentApp

public void focusCurrentApp()
Specified by:
focusCurrentApp in interface AppController

getCurrentApp

public App getCurrentApp()
Specified by:
getCurrentApp in interface AppController

getCurrentAppLocation

public Location getCurrentAppLocation()
Returns the current location of the focused app. This can differ from the actual location of the admin central, e.g. when a shell app is open.

Specified by:
getCurrentAppLocation in interface AppController
See Also:
LocationController.getWhere()

getAppLocation

public Location getAppLocation(String appName)
Returns the current location of a running app instance or null, if it is not running. The App does not have to be focused.

Specified by:
getAppLocation in interface AppController

onLocationChanged

public void onLocationChanged(LocationChangedEvent event)
Takes care of LocationChangedEvents by:

Specified by:
onLocationChanged in interface LocationChangedEvent.Handler

onLocationChangeRequested

public void onLocationChangeRequested(LocationChangeRequestedEvent event)
Specified by:
onLocationChangeRequested in interface LocationChangeRequestedEvent.Handler

openChooseDialog

public void openChooseDialog(String appName,
                             UiContext uiContext,
                             String selectedId,
                             ChooseDialogCallback callback)
Specified by:
openChooseDialog in interface AppController


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.