de.espirit.firstspirit.client.gui.applications.MultiApplicationExample


package de.espirit.firstspirit.client.gui.applications;

import de.espirit.firstspirit.access.ServicesBroker;
import de.espirit.firstspirit.client.gui.applications.browser.BrowserApplication;
import de.espirit.firstspirit.client.gui.applications.browser.BrowserApplicationConfiguration;
import de.espirit.firstspirit.client.gui.applications.browser.EngineType;


/**
 * Examples how to create a multi application.
 *
 * @since 4.2.416
 */
public class MultiApplicationExample {	


	/**
	 * Opens a multi application tab with the given title and a browser tab as sub tab
	 *
	 * @since 4.2.416
	 */
	public MultiApplication createMultiApplication(final ServicesBroker servicesBroker, final String title) {
		// get the applicationservice from the servicesBroker
		final ApplicationService appService = servicesBroker.getService(ApplicationService.class);

		// new browser configuration
		final MultiApplicationConfiguration config = MultiApplicationConfiguration.GENERATOR.invoke().
				// the title for the application tab
				title(title);


		// open an application tab of type multitab
		final ApplicationTab<MultiApplication> multiTab = appService.openApplication(MultiApplication.TYPE, config);


		// get the multi application
		final MultiApplication multiApp = multiTab.getApplication();


		// new browser configuration for the sub browser tab
		final BrowserApplicationConfiguration browserConfig = BrowserApplicationConfiguration.GENERATOR.invoke().
				// the title for the application tab
				title(title).

				// use firefox as engine type for the browser applicationi
				engineType(EngineType.FIREFOX);


		// create a browser application tab as sub tab of the multiapplication
		final ApplicationTab<BrowserApplication> browserTab = multiApp.openApplication(BrowserApplication.TYPE, browserConfig);

		// get the browser application
		final BrowserApplication browserApplication = browserTab.getApplication();

		// open www.e-spirit.de in the created browser application
		browserApplication.openUrl("www.e-spirit.de");


		return multiApp;
	}
}