aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHallvard Traetteberg2012-04-30 04:04:13 (EDT)
committerHallvard Traetteberg2012-04-30 04:04:13 (EDT)
commit7f73516f24fb056c8b6d6b3861af32c7f0a5b03f (patch)
tree35020f8da75f0e19c94bacc20c1cd6b70b2bb832
parente9dbd6ab177aadff07c0921e5f184c34e5b0de85 (diff)
downloadorg.eclipse.nebula-7f73516f24fb056c8b6d6b3861af32c7f0a5b03f.zip
org.eclipse.nebula-7f73516f24fb056c8b6d6b3861af32c7f0a5b03f.tar.gz
org.eclipse.nebula-7f73516f24fb056c8b6d6b3861af32c7f0a5b03f.tar.bz2
Examples tab for geomap jface viewer.
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/.classpath7
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/.project28
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/META-INF/MANIFEST.MF12
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/build.properties5
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/plugin.xml10
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/pom.xml17
-rw-r--r--widgets/geomap/org.eclipse.nebula.jface.geomap.example/src/org/eclipse/nebula/jface/geomap/example/GeoMapViewerExampleTab.java155
8 files changed, 242 insertions, 0 deletions
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.classpath b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.project b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.project
new file mode 100644
index 0000000..a4289ae
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.nebula.jface.geomap.example</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.settings/org.eclipse.jdt.core.prefs b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..9d86851
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Sun Nov 27 01:07:21 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/META-INF/MANIFEST.MF b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..db0d264
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Nebule GeoMapViewer Example
+Bundle-SymbolicName: org.eclipse.nebula.jface.geomap.example;singleton:=true
+Bundle-Version: 0.1.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.nebula.examples;bundle-version="1.0.4",
+ org.eclipse.nebula.jface.geomap;bundle-version="0.1.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: Eclipse.org
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/build.properties b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/plugin.xml b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/plugin.xml
new file mode 100644
index 0000000..3301a35
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension point="org.eclipse.nebula.examples.examples">
+ <tab
+ name="GeoMapViewer"
+ class="org.eclipse.nebula.jface.geomap.example.GeoMapViewerExampleTab"
+ />
+ </extension>
+</plugin>
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/pom.xml b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/pom.xml
new file mode 100644
index 0000000..b276759
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>nebula-parent</artifactId>
+ <groupId>org.eclipse.nebula</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../../releng/org.eclipse.nebula.nebula-parent</relativePath>
+ </parent>
+
+ <groupId>org.eclipse.nebula</groupId>
+ <artifactId>org.eclipse.nebula.jface.geomap.example</artifactId>
+ <version>0.14.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
diff --git a/widgets/geomap/org.eclipse.nebula.jface.geomap.example/src/org/eclipse/nebula/jface/geomap/example/GeoMapViewerExampleTab.java b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/src/org/eclipse/nebula/jface/geomap/example/GeoMapViewerExampleTab.java
new file mode 100644
index 0000000..ce1b4e7
--- /dev/null
+++ b/widgets/geomap/org.eclipse.nebula.jface.geomap.example/src/org/eclipse/nebula/jface/geomap/example/GeoMapViewerExampleTab.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * hal - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.nebula.jface.geomap.example;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.nebula.examples.AbstractExampleTab;
+import org.eclipse.nebula.jface.geomap.GeoMapViewer;
+import org.eclipse.nebula.jface.geomap.GoogleIconDescriptor;
+import org.eclipse.nebula.jface.geomap.LocationProvider;
+import org.eclipse.nebula.jface.geomap.PinPointProvider;
+import org.eclipse.nebula.widgets.geomap.PointD;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+public class GeoMapViewerExampleTab extends AbstractExampleTab {
+
+ private GeoMapViewer geoMapViewer;
+
+ public GeoMapViewerExampleTab() {
+ }
+
+ public Control createControl(Composite parent) {
+ geoMapViewer = new GeoMapViewer(parent, SWT.NONE);
+ configureMapViewer();
+ geoMapViewer.getControl().addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (imageRegistry != null) {
+ imageRegistry.dispose();
+ }
+ }
+ });
+ return geoMapViewer.getControl();
+ }
+
+ public String[] createLinks() {
+ return new String[] {
+ "<a href=\"http://www.eclipse.org/nebula/widgets/geomap/geomap.php\">GeoMap Home Page</a>",
+ "<a href=\"http://www.eclipse.org/nebula/widgets/geomap/snippets.php\">Snippets</a>",
+ "<a href=\"https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&classification=Technology&product=Nebula&component=GeoMap&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=\">Bugs</a>" };
+ }
+
+ @Override
+ public void createParameters(Composite parent) {
+ GridLayoutFactory.swtDefaults().margins(0,0).numColumns(1).applyTo(parent);
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setText("Interaction");
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+ group.setLayout(new GridLayout(2, false));
+
+ Label moveSelectionModeLabel = new Label(group, SWT.NONE);
+ moveSelectionModeLabel.setText("Move selection mode: ");
+ moveSelectionModeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ final Combo moveSelectionModeControl = new Combo(group, SWT.CHECK);
+ moveSelectionModeControl.setItems(new String[]{"Cannot move selection", "Allow, check readonly on mouse down", "Allow, just try to set new location"});
+ moveSelectionModeControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ moveSelectionModeControl.select(1);
+ moveSelectionModeControl.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ geoMapViewer.setMoveSelectionMode(moveSelectionModeControl.getSelectionIndex());
+ }
+ });
+ }
+
+ private ImageRegistry imageRegistry;
+
+ private ImageRegistry getImageRegistry() {
+ if (imageRegistry == null) {
+ imageRegistry = new ImageRegistry();
+ imageRegistry.put("Gl┐shaugen", GoogleIconDescriptor.letterPin('G', false, new RGB(180, 0, 0)));
+ imageRegistry.put("Dragvoll", GoogleIconDescriptor.letterPin('D', false, new RGB( 0, 180, 0)));
+ }
+ return imageRegistry;
+ }
+
+ private String[] locationNames = {"Gl┐shaugen", "Dragvoll"};
+ private PointD[] locationPoints = {new PointD(10.40272, 63.41861), new PointD(10.46976, 63.40857)};
+
+ private int indexOfLocation(Object element) {
+ for (int i = 0; i < locationNames.length; i++) {
+ if (element.equals(locationNames[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private void configureMapViewer() {
+ geoMapViewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return locationNames;
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ public void dispose() {}
+ });
+ final ImageRegistry imageRegistry = getImageRegistry();
+ geoMapViewer.setLabelProvider(new PinPointProvider() {
+ @Override
+ public Image getImage(Object element) {
+ return imageRegistry.get(element.toString());
+ }
+ @Override
+ public Point getPinPoint(Object element) {
+ return getPinPoint(element, 0.5f, 1.0f);
+ }
+ });
+ geoMapViewer.setLocationProvider(new LocationProvider() {
+ public PointD getLonLat(Object element) {
+ int pos = indexOfLocation(element);
+ return pos >= 0 ? locationPoints[pos] : null;
+ }
+ public boolean setLonLat(Object element, double lon, double lat) {
+ int pos = indexOfLocation(element);
+ if (pos > 0) {
+ locationPoints[pos] = new PointD(lon, lat);
+ return true;
+ }
+ return false;
+ }
+ });
+ geoMapViewer.getGeoMap().setZoom(13);
+ geoMapViewer.getGeoMap().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ geoMapViewer.setSelection(new StructuredSelection("Gl┐shaugen"), true);
+ }
+ });
+ }
+}