Search in sources :

Example 6 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class SystemTapScriptLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    // Wait for other stap launches' consoles to be initiated before starting a new launch.
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    for (ILaunch olaunch : manager.getLaunches()) {
        if (olaunch.equals(launch)) {
            continue;
        }
        if (olaunch instanceof SystemTapScriptLaunch && ((SystemTapScriptLaunch) olaunch).getConsole() == null) {
            throw new CoreException(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, Messages.SystemTapScriptLaunchError_waitForConsoles));
        }
    }
    if (!SystemTapScriptGraphOptionsTab.isValidLaunch(configuration)) {
        throw new CoreException(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, Messages.SystemTapScriptLaunchError_graph));
    }
    RunScriptHandler action;
    boolean runWithChart = configuration.getAttribute(SystemTapScriptGraphOptionsTab.RUN_WITH_CHART, false);
    // If runWithChart is true there must be at least one graph, but this isn't guaranteed
    // to be true for outdated Launch Configurations. So for safety, make sure there are graphs.
    int numGraphs = configuration.getAttribute(SystemTapScriptGraphOptionsTab.NUMBER_OF_REGEXS, 0);
    if (runWithChart && numGraphs > 0) {
        List<IDataSetParser> parsers = SystemTapScriptGraphOptionsTab.createDatasetParsers(configuration);
        List<IFilteredDataSet> dataSets = SystemTapScriptGraphOptionsTab.createDataset(configuration);
        List<String> names = SystemTapScriptGraphOptionsTab.createDatasetNames(configuration);
        List<LinkedList<GraphData>> graphs = SystemTapScriptGraphOptionsTab.createGraphsFromConfiguration(configuration);
        action = new RunScriptChartHandler(parsers, dataSets, names, graphs);
    } else {
        action = new RunScriptHandler();
    }
    // Path
    // $NON-NLS-1$
    IPath scriptPath = new Path(configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.SCRIPT_PATH_ATTR, ""));
    if (!scriptPath.toFile().exists()) {
        throw new CoreException(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, MessageFormat.format(Messages.SystemTapScriptLaunchError_fileNotFound, scriptPath.toString())));
    }
    String extension = scriptPath.getFileExtension();
    if (extension == null || !extension.equals("stp")) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, MessageFormat.format(Messages.SystemTapScriptLaunchError_fileNotStp, scriptPath.toString())));
    }
    action.setPath(scriptPath);
    // Run locally and/or as current user.
    action.setRemoteScriptOptions(configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.CURRENT_USER_ATTR, true) ? null : new RemoteScriptOptions(// $NON-NLS-1$
    configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_NAME_ATTR, ""), // $NON-NLS-1$
    configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USER_PASS_ATTR, ""), configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.LOCAL_HOST_ATTR, true) ? LOCALHOST : configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.HOST_NAME_ATTR, LOCALHOST), configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.USE_DEFAULT_PORT_ATTR, true) ? DEFAULT_PORT : configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.PORT_ATTR, DEFAULT_PORT)));
    // $NON-NLS-1$
    String value = configuration.getAttribute(IDEPreferenceConstants.STAP_CMD_OPTION[IDEPreferenceConstants.KEY], "");
    if (!value.isEmpty()) {
        // $NON-NLS-1$
        action.addComandLineOptions(IDEPreferenceConstants.STAP_CMD_OPTION[IDEPreferenceConstants.FLAG] + " " + value);
    }
    // Add command line options
    for (int i = 0; i < IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS.length; i++) {
        boolean flag = configuration.getAttribute(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.KEY], false);
        if (flag) {
            action.addComandLineOptions(IDEPreferenceConstants.STAP_BOOLEAN_OPTIONS[i][IDEPreferenceConstants.FLAG]);
        }
    }
    for (int i = 0; i < IDEPreferenceConstants.STAP_STRING_OPTIONS.length; i++) {
        // $NON-NLS-1$
        value = configuration.getAttribute(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.KEY], "");
        if (!value.isEmpty()) {
            // $NON-NLS-1$
            action.addComandLineOptions(IDEPreferenceConstants.STAP_STRING_OPTIONS[i][IDEPreferenceConstants.FLAG] + " " + value);
        }
    }
    // $NON-NLS-1$
    value = configuration.getAttribute(SystemTapScriptOptionsTab.MISC_COMMANDLINE_OPTIONS, "");
    if (!value.isEmpty()) {
        action.addComandLineOptions(value);
    }
    action.setLaunch((SystemTapScriptLaunch) launch);
    try {
        action.execute(null);
    } catch (ExecutionException e) {
        throw new CoreException(new Status(IStatus.ERROR, IDEPlugin.PLUGIN_ID, e.getMessage()));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) RunScriptChartHandler(org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.RunScriptChartHandler) IPath(org.eclipse.core.runtime.IPath) ILaunchManager(org.eclipse.debug.core.ILaunchManager) IFilteredDataSet(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IFilteredDataSet) LinkedList(java.util.LinkedList) RemoteScriptOptions(org.eclipse.linuxtools.systemtap.ui.consolelog.structures.RemoteScriptOptions) CoreException(org.eclipse.core.runtime.CoreException) IDataSetParser(org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSetParser) ILaunch(org.eclipse.debug.core.ILaunch) RunScriptHandler(org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.RunScriptHandler) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 7 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project linuxtools by eclipse.

the class AbstractValgrindTest method tearDown.

@After
public void tearDown() throws CoreException {
    ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
    if (launches.size() > 0) {
        lm.removeLaunches(launches.toArray(new ILaunch[launches.size()]));
        launches.clear();
    }
    // Delete the Launch Configurations
    ILaunchConfiguration[] configs = lm.getLaunchConfigurations();
    for (ILaunchConfiguration config : configs) {
        config.delete();
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager) After(org.junit.After)

Example 8 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class DebugProcessTosComposite method exec.

public void exec() {
    setHideconsoleLine(false);
    if (getProcessContext() == null) {
        return;
    }
    if (getProcessContext().getProcess() instanceof IProcess2) {
        ReplaceNodesInProcessProvider.beforeRunJobInGUI(getProcessContext().getProcess());
    }
    CorePlugin.getDefault().getRunProcessService().saveJobBeforeRun(getProcessContext().getProcess());
    if (manager.getClearBeforeExec()) {
        processContext.clearMessages();
    }
    if (manager.getExecTime()) {
        processContext.switchTime();
    }
    processContext.setWatchAllowed(manager.getExecTime());
    processContext.setMonitorPerf(manager.getStat());
    // processContext.setMonitorTrace(traceBtn.getSelection());
    processContext.setNextBreakPoint(false);
    processContext.setSelectedContext(manager.getSelectContext());
    processContext.exec(manager.getProcessShell());
    checkSaveBeforeRunSelection();
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    manager.removeLaunches(launches);
    // trace debug to collect when tos
    IPreferenceStore preferenceStore = RunProcessPlugin.getDefault().getPreferenceStore();
    int num = preferenceStore.getInt(RunProcessTokenCollector.TOS_COUNT_DEBUG_RUNS.getPrefKey());
    preferenceStore.setValue(RunProcessTokenCollector.TOS_COUNT_DEBUG_RUNS.getPrefKey(), num + 1);
}
Also used : IProcess2(org.talend.core.model.process.IProcess2) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Point(org.eclipse.swt.graphics.Point)

Example 9 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class ProcessComposite method exec.

public void exec() {
    setHideconsoleLine(false);
    if (getProcessContext() == null) {
        return;
    }
    if (getProcessContext().getProcess() instanceof IProcess2) {
        ReplaceNodesInProcessProvider.beforeRunJobInGUI(getProcessContext().getProcess());
    }
    CorePlugin.getDefault().getRunProcessService().saveJobBeforeRun(getProcessContext().getProcess());
    if (processContext.isClearBeforeExec()) {
        processContext.clearMessages();
    }
    // processContext.
    // if (processContext.isWatchAllowed()) {
    // processContext.switchTime();
    // }
    processContext.setMonitorTrace(false);
    processContext.setWatchAllowed(processManager.getExecTime());
    processContext.setMonitorPerf(processManager.getStat());
    // processContext.setMonitorTrace(traceBtn.getSelection());
    /* check and save should be execute before processContext.exec,or it will cause dirty problem,bug 16791 */
    checkSaveBeforeRunSelection();
    processContext.setSelectedContext(processManager.getSelectContext());
    processContext.exec(processManager.getProcessShell());
    processContext.cleanWorkingDirectory();
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    manager.removeLaunches(launches);
}
Also used : IProcess2(org.talend.core.model.process.IProcess2) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 10 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class MemoryRuntimeComposite method exec.

private void exec() {
    if (processContext instanceof IProcess2) {
        ReplaceNodesInProcessProvider.beforeRunJobInGUI(processContext.getProcess());
    }
    CorePlugin.getDefault().getRunProcessService().saveJobBeforeRun(processContext.getProcess());
    if (processContext.isClearBeforeExec()) {
        processContext.clearMessages();
    }
    processContext.setMonitorTrace(false);
    processContext.setWatchAllowed(processManager.getExecTime());
    processContext.setMonitorPerf(processManager.getStat());
    if (processContext.isSaveBeforeRun()) {
        SaveJobBeforeRunAction action = new SaveJobBeforeRunAction(processContext.getProcess());
        action.run();
    }
    processContext.setSelectedContext(processManager.getSelectContext());
    processContext.exec(processManager.getProcessShell());
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    manager.removeLaunches(launches);
}
Also used : SaveJobBeforeRunAction(org.talend.designer.runprocess.ui.actions.SaveJobBeforeRunAction) IProcess2(org.talend.core.model.process.IProcess2) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Aggregations

ILaunchManager (org.eclipse.debug.core.ILaunchManager)26 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)14 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)13 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)10 CoreException (org.eclipse.core.runtime.CoreException)8 ArrayList (java.util.ArrayList)7 ILaunch (org.eclipse.debug.core.ILaunch)6 File (java.io.File)4 IPath (org.eclipse.core.runtime.IPath)4 Path (org.eclipse.core.runtime.Path)4 LinkedList (java.util.LinkedList)3 IProcess2 (org.talend.core.model.process.IProcess2)3 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2 IVMInstall (org.eclipse.jdt.launching.IVMInstall)2 IRemoteCommandLauncher (org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 Project (org.talend.core.model.properties.Project)2