package at.bestsolution.efxclipse.tooling.ui.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.program.Program;
import org.eclipse.ui.ISources;
public class OpenWithFXMLHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEvaluationContext context = (IEvaluationContext) event.getApplicationContext();
ISelection s = (ISelection) context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if( s instanceof IStructuredSelection ) {
Object o = ((IStructuredSelection) s).getFirstElement();
if( o instanceof IFile ) {
IFile f = (IFile) o;
Program.launch(f.getLocation().toFile().getAbsolutePath());
}
}
return null;
}
}