1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.pde.internal.core.ischema.ISchema; 18 import org.eclipse.pde.internal.core.schema.SchemaDescriptor; 19 import org.eclipse.ui.IObjectActionDelegate; 20 import org.eclipse.ui.IWorkbenchPart; 21 22 public class PreviewReferenceAction implements IObjectActionDelegate { 23 private IFile fFile; 24 private ShowDescriptionAction fDelegate; 25 26 29 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 30 } 31 32 35 public void run(IAction action) { 36 if (fFile == null) 37 return; 38 SchemaDescriptor sd = new SchemaDescriptor(fFile, false); 39 ISchema schema = sd.getSchema(false); 40 if (fDelegate == null) { 41 fDelegate = new ShowDescriptionAction(schema); 42 } else 43 fDelegate.setSchema(schema); 44 fDelegate.run(); 45 } 46 47 50 public void selectionChanged(IAction action, ISelection selection) { 51 fFile = null; 52 if (selection instanceof IStructuredSelection) { 53 Object obj = ((IStructuredSelection)selection).getFirstElement(); 54 if (obj instanceof IFile) 55 fFile = (IFile)obj; 56 } 57 } 58 } 59 | Popular Tags |