0
|
1 package de.mpg.mpiwg.itgroup.textgrid.digilib;
|
|
2
|
|
3 import java.net.URI;
|
|
4
|
|
5 import info.textgrid.lab.authn.RBACSession;
|
|
6 import info.textgrid.lab.core.model.TextGridObject;
|
|
7
|
|
8 import org.eclipse.core.commands.ExecutionEvent;
|
|
9 import org.eclipse.core.commands.ExecutionException;
|
|
10 import org.eclipse.core.commands.IHandler;
|
|
11 import org.eclipse.core.commands.IHandlerListener;
|
|
12 import org.eclipse.core.resources.IFile;
|
|
13 import org.eclipse.jface.viewers.ISelection;
|
|
14 import org.eclipse.jface.viewers.IStructuredSelection;
|
|
15 import org.eclipse.ui.PartInitException;
|
|
16 import org.eclipse.ui.handlers.HandlerUtil;
|
|
17 import info.textgrid.lab.core.swtutils.AdapterUtils;
|
|
18
|
|
19 import de.mpg.mpiwg.itgroup.digilib.plugin.editors.DigilibLinkEditorInput;
|
|
20 import de.mpg.mpiwg.itgroup.digilib.plugin.editors.DigilibLinkEditorPart;
|
|
21
|
|
22
|
|
23 public class DigilibHandler implements IHandler {
|
|
24
|
|
25 public void addHandlerListener(IHandlerListener handlerListener) {
|
|
26 // TODO Auto-generated method stub
|
|
27
|
|
28 }
|
|
29
|
|
30 public void dispose() {
|
|
31 // TODO Auto-generated method stub
|
|
32
|
|
33 }
|
|
34
|
|
35 public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
36
|
|
37 ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
|
|
38 if (IStructuredSelection.class.isInstance(currentSelection)) {
|
|
39 IStructuredSelection selection = (IStructuredSelection) currentSelection;
|
|
40 TextGridObject object = AdapterUtils.getAdapter(selection.getFirstElement(), TextGridObject.class);
|
|
41
|
|
42
|
|
43 IFile file = (IFile) object.getAdapter(IFile.class);
|
|
44 URI textGridUri = object.getURI();
|
|
45 String sid = RBACSession.getInstance().getSID(true);
|
|
46 DigilibLinkEditorInput input = new DigilibLinkEditorInput(textGridUri,sid,DigilibLinkEditorInput.TEXTGRID);
|
|
47
|
|
48 try {
|
|
49 DigilibLinkEditorPart dp = (DigilibLinkEditorPart) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().openEditor(input,"de.mpg.mpiwg.itgroup.digilib.plugin.digilibLinkEditor");
|
|
50 return dp;
|
|
51 } catch (PartInitException e) {
|
|
52 // TODO Auto-generated catch block
|
|
53 e.printStackTrace();
|
|
54 }
|
|
55 }
|
|
56 return null;
|
|
57 }
|
|
58
|
|
59 public boolean isEnabled() {
|
|
60
|
|
61 return true;
|
|
62 }
|
|
63
|
|
64 public boolean isHandled() {
|
|
65 // TODO Auto-generated method stub
|
|
66 return false;
|
|
67 }
|
|
68
|
|
69 public void removeHandlerListener(IHandlerListener handlerListener) {
|
|
70 // TODO Auto-generated method stub
|
|
71
|
|
72 }
|
|
73
|
|
74 }
|