]> git.argeo.org Git - lgpl/argeo-commons.git/blob - MapFormPage.java
c84816571c4a79c07eab21d91f49e1203ec243cc
[lgpl/argeo-commons.git] / MapFormPage.java
1 package org.argeo.gis.ui.editors;
2
3 import javax.jcr.Node;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.argeo.gis.ui.MapControlCreator;
8 import org.argeo.gis.ui.MapViewer;
9 import org.eclipse.swt.SWT;
10 import org.eclipse.swt.layout.FillLayout;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.widgets.Composite;
13 import org.eclipse.ui.forms.IManagedForm;
14 import org.eclipse.ui.forms.editor.FormEditor;
15 import org.eclipse.ui.forms.editor.FormPage;
16 import org.eclipse.ui.forms.widgets.FormToolkit;
17
18 /** A form editor page to edit geographical data. */
19 public class MapFormPage extends FormPage {
20 private final static Log log = LogFactory.getLog(MapFormPage.class);
21
22 private Node context;
23 private MapViewer mapViewer;
24 private MapControlCreator mapControlCreator;
25
26 public MapFormPage(FormEditor editor, String id, String title,
27 Node context, MapControlCreator mapControlCreator) {
28 super(editor, id, title);
29 this.context = context;
30 this.mapControlCreator = mapControlCreator;
31 }
32
33 @Override
34 protected void createFormContent(IManagedForm managedForm) {
35 Composite parent = managedForm.getForm().getBody();
36 parent.setLayout(new FillLayout());
37
38 FormToolkit tk = managedForm.getToolkit();
39
40 Composite mapArea = new Composite(parent, SWT.NONE);
41 GridLayout layout = new GridLayout();
42 layout.marginHeight = 0;
43 layout.marginWidth = 0;
44 mapArea.setLayout(layout);
45 mapViewer = mapControlCreator.createMapControl(context, mapArea);
46 tk.adapt(mapViewer.getControl());
47 }
48
49 public void featureSelected(String layerId, String featureId) {
50 if (log.isDebugEnabled())
51 log.debug("Selected feature '" + featureId + "' of layer '"
52 + layerId + "'");
53
54 }
55
56 public void featureUnselected(String layerId, String featureId) {
57 if (log.isDebugEnabled())
58 log.debug("Unselected feature '" + featureId + "' of layer '"
59 + layerId + "'");
60
61 }
62
63 public void setFocus() {
64 super.setFocus();
65 mapViewer.getControl().setFocus();
66 }
67
68 public MapViewer getMapViewer() {
69 return mapViewer;
70 }
71
72 }