Search in sources :

Example 1 with ClientInfo

use of org.eclipse.rap.rwt.client.service.ClientInfo in project netxms by netxms.

the class Application method start.

/* (non-Javadoc)
	 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
	 */
public Object start(IApplicationContext context) throws Exception {
    // $NON-NLS-1$
    String lang = getParameter("lang");
    if (lang != null)
        RWT.setLocale(new Locale(lang));
    final Properties properties = new AppPropertiesLoader().load();
    int timeout;
    try {
        timeout = Integer.parseInt(properties.getProperty("sessionTimeout", "600"));
    } catch (NumberFormatException e) {
        timeout = 600;
    }
    final Display display = PlatformUI.createDisplay();
    RWT.getUISession().getHttpSession().setMaxInactiveInterval(timeout);
    display.disposeExec(new Runnable() {

        public void run() {
            NXCSession session = ConsoleSharedData.getSession();
            if (session != null)
                session.disconnect();
        }
    });
    ClientInfo clientInfo = RWT.getClient().getService(ClientInfo.class);
    if (clientInfo != null) {
        // convert offset in minutes to milliseconds (in RAP - means ahead of UTC)
        String[] tzList = TimeZone.getAvailableIDs(-clientInfo.getTimezoneOffset() * 60000);
        if (tzList.length > 0) {
            RWT.getUISession().setAttribute(ConsoleSharedData.ATTRIBUTE_TIMEZONE, TimeZone.getTimeZone(tzList[0]));
        }
    }
    SharedIcons.init(display);
    WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
    return PlatformUI.createAndRunWorkbench(display, advisor);
}
Also used : Locale(java.util.Locale) NXCSession(org.netxms.client.NXCSession) WorkbenchAdvisor(org.eclipse.ui.application.WorkbenchAdvisor) Properties(java.util.Properties) ClientInfo(org.eclipse.rap.rwt.client.service.ClientInfo) Display(org.eclipse.swt.widgets.Display)

Aggregations

Locale (java.util.Locale)1 Properties (java.util.Properties)1 ClientInfo (org.eclipse.rap.rwt.client.service.ClientInfo)1 Display (org.eclipse.swt.widgets.Display)1 WorkbenchAdvisor (org.eclipse.ui.application.WorkbenchAdvisor)1 NXCSession (org.netxms.client.NXCSession)1