Mercurial > hg > de.mpg.mpiwg.itgroup.digilib.plugin
view src/de/mpg/mpiwg/itgroup/digilib/plugin/DigilibHandler.java @ 28:0205c3f41d1d default tip
repackaging (separate textgridlab and dgilib local parts more rigorously
author | dwinter |
---|---|
date | Fri, 24 Aug 2012 09:42:57 +0200 |
parents | e63a64652f4d |
children |
line wrap: on
line source
package de.mpg.mpiwg.itgroup.digilib.plugin; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; import org.eclipse.core.commands.IHandlerListener; import org.eclipse.core.resources.IFile; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.PartInitException; import org.eclipse.ui.handlers.HandlerUtil; import de.mpg.mpiwg.itgroup.digilib.plugin.editors.DigilibLinkEditorInput; import de.mpg.mpiwg.itgroup.digilib.plugin.editors.IDigilibLinkEditorPart; /** * @author dwinter * * Open an DigilibLinkEditorPart on the selected files. Currently, the selected files have to be index meta files. * Where archive-path and texttols/image points to the image folder. * TODO chck the format and allow other formats. */ public class DigilibHandler implements IHandler { public void addHandlerListener(IHandlerListener handlerListener) { // TODO Auto-generated method stub } public void dispose() { // TODO Auto-generated method stub } public Object execute(ExecutionEvent event) throws ExecutionException { ISelection currentSelection = HandlerUtil.getCurrentSelection(event); if (IStructuredSelection.class.isInstance(currentSelection)) { IStructuredSelection selection = (IStructuredSelection) currentSelection; Object object = selection.getFirstElement(); IFile file = (IFile) object; DigilibLinkEditorInput input = new DigilibLinkEditorInput(file,DigilibLinkEditorInput.INDEX_META); try { IDigilibLinkEditorPart dp = (IDigilibLinkEditorPart) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().openEditor(input,"de.mpg.mpiwg.itgroup.digilib.plugin.digilibLinkEditor"); return dp; } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } public boolean isEnabled() { return true; } public boolean isHandled() { // TODO Auto-generated method stub return true; } public void removeHandlerListener(IHandlerListener handlerListener) { // TODO Auto-generated method stub } }