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
|
9
|
16 /**
|
|
17 * @author dwinter
|
|
18 *
|
|
19 * Open an DigilibLinkEditorPart on the selected files. Currently, the selected files have to be index meta files.
|
|
20 * Where archive-path and texttols/image points to the image folder.
|
|
21 * TODO chck the format and allow other formats.
|
|
22 */
|
1
|
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;
|
9
|
40
|
1
|
41 Object object = selection.getFirstElement();
|
|
42
|
|
43 IFile file = (IFile) object;
|
|
44 DigilibLinkEditorInput input = new DigilibLinkEditorInput(file,DigilibLinkEditorInput.INDEX_META);
|
|
45
|
|
46 try {
|
|
47 DigilibLinkEditorPart dp = (DigilibLinkEditorPart) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().openEditor(input,"de.mpg.mpiwg.itgroup.digilib.plugin.digilibLinkEditor");
|
|
48 return dp;
|
|
49 } catch (PartInitException e) {
|
|
50 // TODO Auto-generated catch block
|
|
51 e.printStackTrace();
|
|
52 }
|
|
53 }
|
|
54 return null;
|
|
55 }
|
|
56
|
|
57 public boolean isEnabled() {
|
|
58
|
|
59 return true;
|
|
60 }
|
|
61
|
|
62 public boolean isHandled() {
|
|
63 // TODO Auto-generated method stub
|
|
64 return true;
|
|
65 }
|
|
66
|
|
67 public void removeHandlerListener(IHandlerListener handlerListener) {
|
|
68 // TODO Auto-generated method stub
|
|
69
|
|
70 }
|
|
71
|
|
72 }
|