97a4c21728bd40f765e7b8658308785b43d5b5de
[public/netxms.git] / webui / webapp / OSM / src / org / netxms / ui / eclipse / osm / views / LocationMap.java
1 /**
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2011 Victor Kirhenshtein
4 *
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.
9 *
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.
14 *
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.
18 */
19 package org.netxms.ui.eclipse.osm.views;
20
21 import org.eclipse.ui.IViewSite;
22 import org.eclipse.ui.PartInitException;
23 import org.netxms.base.GeoLocation;
24 import org.netxms.client.NXCSession;
25 import org.netxms.client.objects.AbstractObject;
26 import org.netxms.ui.eclipse.osm.Messages;
27 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
28
29 /**
30 * Geolocation view
31 */
32 public class LocationMap extends AbstractGeolocationView
33 {
34 public static final String ID = "org.netxms.ui.eclipse.osm.views.LocationMap"; //$NON-NLS-1$
35
36 private AbstractObject object;
37
38 /* (non-Javadoc)
39 * @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
40 */
41 @Override
42 public void init(IViewSite site) throws PartInitException
43 {
44 super.init(site);
45
46 try
47 {
48 long id = Long.parseLong(site.getSecondaryId());
49 object = ((NXCSession)ConsoleSharedData.getSession()).findObjectById(id);
50 setPartName(Messages.get().LocationMap_PartNamePrefix + object.getObjectName());
51 }
52 catch(Exception e)
53 {
54 throw new PartInitException(Messages.get().LocationMap_InitError1, e);
55 }
56 if (object == null)
57 throw new PartInitException(Messages.get().LocationMap_InitError2);
58 }
59
60 /* (non-Javadoc)
61 * @see org.netxms.ui.eclipse.osm.views.AbstractGeolocationView#getInitialCenterPoint()
62 */
63 @Override
64 protected GeoLocation getInitialCenterPoint()
65 {
66 return object.getGeolocation();
67 }
68
69 /* (non-Javadoc)
70 * @see org.netxms.ui.eclipse.osm.views.AbstractGeolocationView#getInitialZoomLevel()
71 */
72 @Override
73 protected int getInitialZoomLevel()
74 {
75 // TODO Auto-generated method stub
76 return 15;
77 }
78 }