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