22
22
import org.eclipse.jface.action.Action;
23
23
import org.eclipse.jface.action.ControlContribution;
24
24
import org.eclipse.jface.action.IAction;
25
import org.eclipse.jface.action.IMenuManager;
25
26
import org.eclipse.jface.action.IToolBarManager;
27
import org.eclipse.jface.action.Separator;
26
28
import org.eclipse.jface.viewers.ArrayContentProvider;
27
29
import org.eclipse.jface.viewers.ComboViewer;
28
30
import org.eclipse.jface.viewers.IElementComparer;
52
54
import com.bdaum.zoom.gps.CoordinatesListener;
53
55
import com.bdaum.zoom.gps.MaptypeChangedListener;
54
56
import com.bdaum.zoom.gps.geonames.Place;
57
import com.bdaum.zoom.gps.internal.GeoService;
55
58
import com.bdaum.zoom.gps.internal.GpsActivator;
56
59
import com.bdaum.zoom.gps.internal.GpsConfiguration;
57
60
import com.bdaum.zoom.gps.internal.HelpContextIds;
142
145
private static final String LAST_LONGITUDE = "lastLongitude"; //$NON-NLS-1$
143
146
private static final String LAST_LATITUDE = "lastLatitude"; //$NON-NLS-1$
144
147
public static final String ID = "com.bdaum.zoom.gps.MapView"; //$NON-NLS-1$
148
private static final String LAST_ZOOM = "lastZoom"; //$NON-NLS-1$
145
149
private Action lockAction;
146
150
protected boolean locked = true;
147
151
private double lastLongitude = Double.NaN;
155
159
private ComboContributionItem comboContributionItem;
156
160
private Composite viewParent;
157
161
private boolean clientClustering = false;
162
private Action webAction;
163
protected int lastZoom;
164
private IConfigurationElement currentConf;
160
167
public void init(IViewSite site, IMemento memento) throws PartInitException {
175
185
&& !Double.isNaN(lastLongitude)) {
176
186
memento.putFloat(LAST_LATITUDE, (float) lastLatitude);
177
187
memento.putFloat(LAST_LONGITUDE, (float) lastLongitude);
188
memento.putInteger(LAST_ZOOM, lastZoom);
179
190
super.saveState(memento);
206
217
assetsChanged(navigationHistory.getSelectedAssets());
211
223
private void createMapComponent(Composite parent, IConfigurationElement conf) {
212
224
mapComponent = GpsActivator.getMapComponent(conf);
213
225
if (mapComponent != null) {
214
227
clientClustering = Boolean.parseBoolean(conf
215
228
.getAttribute("clientClustering")); //$NON-NLS-1$
216
mapComponent.createComponent(parent);
229
mapComponent.createComponent(parent, true);
217
230
mapComponent.addCoordinatesListener(new CoordinatesListener() {
219
public void setCoordinates(double latitude, double longitude) {
231
public void setCoordinates(double latitude, double longitude, int zoom) {
220
232
updateGeoPosition(latitude, longitude);
221
233
lastLatitude = latitude;
222
234
lastLongitude = longitude;
225
238
mapComponent.addMaptypeListener(new MaptypeChangedListener() {
227
239
public void setMaptype(String maptype) {
228
240
IStructuredSelection sel = comboContributionItem
279
292
for (Asset asset : lastSelection)
280
293
assetIds[i++] = asset.getStringId();
281
294
OperationJob.executeOperation(new GeotagOperation(
282
new Trackpoint[] { new Trackpoint(latitude, longitude) },
295
new Trackpoint[] { new Trackpoint(latitude, longitude, false) },
283
296
assetIds, gpsConfig), this);
290
303
IActionBars bars = viewSite.getActionBars();
291
304
IToolBarManager toolBarManager = bars.getToolBarManager();
292
305
fillLocalToolBar(toolBarManager);
306
IMenuManager menuManager = bars.getMenuManager();
307
fillLocalPullDown(menuManager);
293
308
toolBarManager.update(true);
309
menuManager.update(true);
312
protected void fillLocalPullDown(IMenuManager menuManager) {
313
menuManager.add(webAction);
314
menuManager.add(lockAction);
296
317
protected void fillLocalToolBar(IToolBarManager manager) {
318
if (comboContributionItem != null) {
319
manager.add(comboContributionItem);
320
manager.add(new Separator());
322
manager.add(webAction);
297
323
manager.add(lockAction);
298
if (comboContributionItem != null)
299
manager.add(comboContributionItem);
303
327
protected void makeActions() {
304
lockAction = new Action(Messages.MapView_0, IAction.AS_CHECK_BOX) {
328
lockAction = new Action(Messages.MapView_lock_locked, IAction.AS_CHECK_BOX) {
307
330
public void run() {
308
331
locked = !locked;
309
332
lockAction.setChecked(locked);
310
333
lockAction.setImageDescriptor((locked ? Icons.closedlock
311
334
: Icons.openlock).getDescriptor());
335
lockAction.setToolTipText(locked ? Messages.MapView_click_to_unlock : Messages.MapView_click_to_lock );
336
lockAction.setText(locked ? Messages.MapView_lock_locked : Messages.MapView_lock_unlocked );
312
337
AssetSelection selectedAssets = lastSelection;
313
338
lastSelection = null;
314
339
if (assetsChanged(selectedAssets))
318
343
lockAction.setImageDescriptor(Icons.closedlock.getDescriptor());
319
344
lockAction.setChecked(true);
345
lockAction.setToolTipText(Messages.MapView_click_to_unlock);
347
webAction = new Action(Messages.MapView_show_in_web, IAction.AS_PUSH_BUTTON) {
351
GeoService.showInWebbrowser(lastLatitude, lastLongitude, lastZoom);
352
} catch (Exception e) {
357
webAction.setImageDescriptor(Icons.external.getDescriptor());
320
359
createComboContributionItem();
409
448
private void showMap(Place[] markerPositions, int mode) {
410
449
if (mapComponent != null) {
411
450
mapComponent.setInput(mapPosition, initialZoomLevel,
412
markerPositions, dbIsReadonly() ? IMapComponent.LOCATION
451
markerPositions, null, dbIsReadonly() ? IMapComponent.LOCATION
414
453
if (!Double.isNaN(mapPosition.getLat())
415
454
&& !Double.isNaN(mapPosition.getLon())) {