private void measure(PerformanceMeter performanceMeter, int runs) throws Exception { IPackagesViewPart view = (IPackagesViewPart) EditorTestHelper.getActivePage() .findViewReference(EditorTestHelper.PACKAGE_EXPLORER_VIEW_ID) .getView(false); IAction action = ((IViewSite) view.getSite()).getActionBars().getGlobalActionHandler(FORMAT_ACTION_ID); boolean wasEnabled = EditorTestHelper.setDialogEnabled(FORMAT_DIALOG_ID, false); StructuredSelection selection = new StructuredSelection( JavaCore.create(ResourceTestHelper.getProject(TextPluginTestSetup.PROJECT))); for (int i = 0; i < runs; i++) { performanceMeter.start(); ((SelectionDispatchAction) action).run(selection); performanceMeter.stop(); TextPluginTestSetup.createProjectFromZip(); } EditorTestHelper.setDialogEnabled(FORMAT_DIALOG_ID, wasEnabled); }
public void run() throws CoreException { IViewPart thePart = Activator.getWorkbenchPage().showView(JavaUI.ID_PACKAGES); if (thePart != null) { ((IPackagesViewPart) thePart).selectAndReveal(getElement()); } }