eac944160af78b86a23294f87c401642cb242216
[public/netxms.git] / webui / webapp / Dashboard / src / org / netxms / ui / eclipse / dashboard / widgets / GeoMapElement.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.dashboard.widgets;
20
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.layout.FillLayout;
23 import org.eclipse.ui.IViewPart;
24 import org.netxms.client.dashboards.DashboardElement;
25 import org.netxms.ui.eclipse.dashboard.widgets.internal.GeoMapConfig;
26 import org.netxms.ui.eclipse.osm.widgets.GeoMapViewer;
27
28 /**
29 * Geo map element for dashboard
30 *
31 */
32 public class GeoMapElement extends ElementWidget
33 {
34 private GeoMapViewer mapWidget;
35 private GeoMapConfig config;
36
37 /**
38 * @param parent
39 * @param data
40 */
41 public GeoMapElement(DashboardControl parent, DashboardElement element, IViewPart viewPart)
42 {
43 super(parent, element, viewPart);
44
45 try
46 {
47 config = GeoMapConfig.createFromXml(element.getData());
48 }
49 catch(Exception e)
50 {
51 e.printStackTrace();
52 config = new GeoMapConfig();
53 }
54
55 FillLayout layout = new FillLayout();
56 layout.marginHeight = 0;
57 layout.marginWidth = 0;
58 setLayout(layout);
59
60 mapWidget = new GeoMapViewer(this, SWT.NONE, false, null);
61 mapWidget.setViewPart(viewPart);
62 mapWidget.setTitle(config.getTitle());
63 mapWidget.showMap(config.getLatitude(), config.getLongitude(), config.getZoom());
64 }
65 }