de.espirit.firstspirit.client.gui.applications.browser.BrowserApplicationExample


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

import de.espirit.firstspirit.access.ServicesBroker;
import de.espirit.firstspirit.client.gui.applications.ApplicationService;
import de.espirit.firstspirit.client.gui.applications.ApplicationTab;


/**
 * Examples how to create a browser application.
 *
 * @since 4.2.416
 */
public class BrowserApplicationExample {


	/**
	 * Opens a browser application tab with the given title and opens the given url.
	 *
	 * @since 4.2.416
	 */
	public BrowserApplication createBrowserApplication(final ServicesBroker serviceBroker, final String title) {
		final ApplicationService appService = serviceBroker.getService(ApplicationService.class);

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

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


		// open an application tab of type browser
		final ApplicationTab<BrowserApplication> browserTab = appService.openApplication(BrowserApplication.TYPE, config);

		// 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 browserApplication;
	}
}