public class CountElements implements IObjectActionDelegate { private IFile xmlFile; public CountElements() { super(); } public void setActivePart(IAction action, IWorkbenchPart targetPart) { } public void run(IAction action) { XMLElementCountWizard wizard = new XMLElementCountWizard(xmlFile); WizardDialog dialog = new WizardDialog(XMLProcessing.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),wizard); dialog.create(); dialog.open(); } public void selectionChanged(IAction action, ISelection selection) { this.xmlFile = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() == 1) { Object selectedResource = structuredSelection.getFirstElement(); if (selectedResource instanceof IFile) this.xmlFile = (IFile) selectedResource; } } } public IFile getXmlFile() { return xmlFile; } }