]>
git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.ui.gis/src/main/java/org/argeo/slc/ui/gis/commands/ImportGpx.java
1 package org
.argeo
.slc
.ui
.gis
.commands
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.eclipse
.ui
.dialogs
.Error
;
8 import org
.argeo
.eclipse
.ui
.jcr
.views
.GenericJcrBrowser
;
9 import org
.argeo
.slc
.gpx
.TrackDao
;
10 import org
.argeo
.slc
.ui
.gis
.wizards
.ImportGpxWizard
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.jface
.viewers
.ISelection
;
15 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
16 import org
.eclipse
.jface
.wizard
.WizardDialog
;
17 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
19 /** Open a JCR query editor. */
20 public class ImportGpx
extends AbstractHandler
{
21 private final static Log log
= LogFactory
.getLog(ImportGpx
.class);
22 private TrackDao trackDao
;
24 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
25 ISelection selection
= HandlerUtil
.getActiveWorkbenchWindow(event
)
26 .getActivePage().getSelection();
27 GenericJcrBrowser view
= (GenericJcrBrowser
) HandlerUtil
28 .getActiveWorkbenchWindow(event
).getActivePage()
29 .findView(HandlerUtil
.getActivePartId(event
));
30 if (selection
!= null && !selection
.isEmpty()
31 && selection
instanceof IStructuredSelection
) {
32 Object obj
= ((IStructuredSelection
) selection
).getFirstElement();
34 if (obj
instanceof Node
) {
35 Node baseNode
= (Node
) obj
;
36 ImportGpxWizard wizard
= new ImportGpxWizard(trackDao
,
38 WizardDialog dialog
= new WizardDialog(
39 HandlerUtil
.getActiveShell(event
), wizard
);
41 view
.refresh(baseNode
);
43 Error
.show("Can only import to a node");
45 } catch (Exception e
) {
46 Error
.show("Cannot import files to " + obj
, e
);
52 public void setTrackDao(TrackDao trackDao
) {
53 this.trackDao
= trackDao
;