2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2013 Victor Kirhenshtein
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 package org
.netxms
.ui
.eclipse
.console
;
21 import java
.util
.Locale
;
22 import java
.util
.Properties
;
23 import java
.util
.TimeZone
;
24 import org
.eclipse
.equinox
.app
.IApplication
;
25 import org
.eclipse
.equinox
.app
.IApplicationContext
;
26 import org
.eclipse
.rap
.rwt
.RWT
;
27 import org
.eclipse
.rap
.rwt
.client
.service
.ClientInfo
;
28 import org
.eclipse
.swt
.widgets
.Display
;
29 import org
.eclipse
.ui
.PlatformUI
;
30 import org
.eclipse
.ui
.application
.WorkbenchAdvisor
;
31 import org
.netxms
.client
.NXCSession
;
32 import org
.netxms
.ui
.eclipse
.console
.resources
.SharedIcons
;
33 import org
.netxms
.ui
.eclipse
.shared
.ConsoleSharedData
;
36 * This class controls all aspects of the application's execution and is
37 * contributed through the plugin.xml.
39 public class Application
implements IApplication
42 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
44 public Object
start(IApplicationContext context
) throws Exception
46 String lang
= RWT
.getRequest().getParameter("lang"); //$NON-NLS-1$
48 RWT
.setLocale(new Locale(lang
));
50 final Properties properties
= new AppPropertiesLoader().load();
54 timeout
= Integer
.parseInt(properties
.getProperty("sessionTimeout", "600"));
56 catch(NumberFormatException e
)
61 final Display display
= PlatformUI
.createDisplay();
62 RWT
.getUISession().getHttpSession().setMaxInactiveInterval(timeout
);
63 display
.disposeExec(new Runnable() {
66 NXCSession session
= ConsoleSharedData
.getSession();
72 ClientInfo clientInfo
= RWT
.getClient().getService(ClientInfo
.class);
73 if (clientInfo
!= null)
75 String
[] tzList
= TimeZone
.getAvailableIDs(-clientInfo
.getTimezoneOffset() * 60000); // convert offset in minutes to milliseconds (in RAP - means ahead of UTC)
76 if (tzList
.length
> 0)
78 RWT
.getUISession().setAttribute(ConsoleSharedData
.ATTRIBUTE_TIMEZONE
, TimeZone
.getTimeZone(tzList
[0]));
82 SharedIcons
.init(display
);
83 WorkbenchAdvisor advisor
= new ApplicationWorkbenchAdvisor();
84 return PlatformUI
.createAndRunWorkbench(display
, advisor
);
88 * @see org.eclipse.equinox.app.IApplication#stop()