public static void run(IEditorPart editor) { List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts(); for (LaunchShortcutExtension lse : launchShortcuts) { if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) { lse.launch(editor, ILaunchManager.RUN_MODE); return; } } }
/** * Runs with either the active editor or workbench selection. * * @see IAction#run() */ public void run() { IWorkbenchWindow wb = DebugUIPlugin.getActiveWorkbenchWindow(); if (wb != null) { IWorkbenchPage page = wb.getActivePage(); if (page != null) { if (page.getActivePart() == page.getActiveEditor()) { IEditorPart editor = page.getActiveEditor(); if (editor != null) { fShortcut.launch(editor, fMode); } } else if (page.getActivePart() instanceof IJobSettingsView) { ISelection selection = ((IJobSettingsView) page.getActivePart()).getSelection(); fShortcut.launch(selection, fMode); } else { ISelection selection = page.getSelection(); if (selection instanceof IStructuredSelection) { fShortcut.launch(selection, fMode); } } } } }
protected void launchTests(String prefixForErrorMessage, int howManyNumbersInErrorString) throws CoreException, JavaModelException { // have to set up an 1.3 project to avoid requiring a 5.0 VM JavaProjectHelper.addRTJar13(fProject); JavaProjectHelper.addVariableEntry(fProject, new Path("JUNIT_HOME/junit.jar"), null, null); IPackageFragmentRoot root = JavaProjectHelper.addSourceContainer(fProject, "src"); IPackageFragment pack = root.createPackageFragment("pack", true, null); ICompilationUnit cu1 = pack.getCompilationUnit("LongTraceLines.java"); String initialString = prefixForErrorMessage + "Numbers:"; String initializeString = "String errorString = \"" + initialString + "\";"; String contents = "public class LongTraceLines extends TestCase {\n" + " public void testLongTraceLine() throws Exception {\n" + (" " + initializeString + "\n") + (" for (int i = 0; i < " + howManyNumbersInErrorString + "; i++) {\n") + " errorString += \" \" + i;\n" + " }\n" + " throw new RuntimeException(errorString);\n" + " }\n" + "}"; IType type = cu1.createType(contents, null, true, null); cu1.createImport("junit.framework.TestCase", null, Flags.AccDefault, null); cu1.createImport("java.util.Arrays", null, Flags.AccDefault, null); ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); lm.addLaunchListener(this); LaunchConfigurationManager manager = DebugUIPlugin.getDefault().getLaunchConfigurationManager(); List launchShortcuts = manager.getLaunchShortcuts(); LaunchShortcutExtension ext = null; for (Iterator iter = launchShortcuts.iterator(); iter.hasNext(); ) { ext = (LaunchShortcutExtension) iter.next(); if (ext.getLabel().equals("JUnit Test")) break; } ext.launch(new StructuredSelection(type), ILaunchManager.RUN_MODE); }