Search in sources :

Example 1 with RuntimeProcess

use of org.eclipse.debug.core.model.RuntimeProcess in project erlide_eclipse by erlang.

the class InterpretedModulesView method contextActivated.

private void contextActivated(final ISelection selection) {
    if (!isAvailable() || !isVisible()) {
        return;
    }
    erlangDebugTarget = null;
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        final Object o = structuredSelection.getFirstElement();
        if (o instanceof ErlangDebugElement) {
            final ErlangDebugElement e = (ErlangDebugElement) o;
            erlangDebugTarget = e.getErlangDebugTarget();
        } else if (o instanceof ILaunch) {
            final ILaunch launch = (ILaunch) o;
            final IDebugTarget target = launch.getDebugTarget();
            if (target instanceof IErlangDebugNode) {
                final IErlangDebugNode edn = (IErlangDebugNode) target;
                erlangDebugTarget = edn.getErlangDebugTarget();
            }
        } else if (o instanceof RuntimeProcess) {
            final RuntimeProcess ep = (RuntimeProcess) o;
            final ILaunch launch = ep.getLaunch();
            final IDebugTarget target = launch.getDebugTarget();
            if (target instanceof IErlangDebugNode) {
                final IErlangDebugNode edn = (IErlangDebugNode) target;
                erlangDebugTarget = edn.getErlangDebugTarget();
            }
        }
        if (erlangDebugTarget == null) {
            ErlLogger.debug("no debug target found for " + selection);
            return;
        }
        final ILaunchConfiguration launchConfiguration = erlangDebugTarget.getLaunch().getLaunchConfiguration();
        setViewerInput(launchConfiguration);
        try {
            final EnumSet<ErlDebugFlags> debugFlags = ErlDebugFlags.makeSet(launchConfiguration.getAttribute(ErlRuntimeAttributes.DEBUG_FLAGS, ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
            distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
        } catch (final CoreException e1) {
            distributed = false;
        }
    }
    listViewer.refresh();
    showViewer();
// updateAction(VARIABLES_FIND_ELEMENT_ACTION);
// updateAction(FIND_ACTION);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IErlangDebugNode(org.erlide.backend.debug.IErlangDebugNode) CoreException(org.eclipse.core.runtime.CoreException) ErlDebugFlags(org.erlide.runtime.api.ErlDebugFlags) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) ILaunch(org.eclipse.debug.core.ILaunch) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ErlangDebugElement(org.erlide.backend.debug.model.ErlangDebugElement)

Example 2 with RuntimeProcess

use of org.eclipse.debug.core.model.RuntimeProcess in project ow by vtst.

the class EasyExtProgramLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    Fixture fixture = getFixture(config);
    if (monitor == null)
        monitor = new NullProgressMonitor();
    monitor.beginTask(config.getName() + "...", 3);
    if (monitor.isCanceled())
        return;
    ProcessBuilder pb = this.getProcessBuilder(config, fixture);
    try {
        Process process;
        try {
            // We do not catch NullPointerException or IndexOutOfBoundsException, because it would mean
            // the command of the process is null or empty.
            process = pb.start();
        } catch (SecurityException exn) {
            throw createCoreException(messages.getString("process_security_exception"), exn);
        } catch (IOException exn) {
            throw createCoreException(messages.getString("process_io_exception"), exn);
        }
        launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");
        RuntimeProcess runtimeProcess = new RuntimeProcess(launch, process, "External program", Collections.EMPTY_MAP);
        runtimeProcess.setAttribute(IProcess.ATTR_CMDLINE, MiscUi.renderCommandLine(pb.command()));
        addProcessListeners(config, fixture, new EasyLaunchConfigurationDelegateUtils.ProcessListernerAcceptorImpl(runtimeProcess));
    } finally {
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) IProcess(org.eclipse.debug.core.model.IProcess) IOException(java.io.IOException)

Example 3 with RuntimeProcess

use of org.eclipse.debug.core.model.RuntimeProcess in project webtools.servertools by eclipse.

the class ExternalLaunchConfigurationDelegate method launch.

/* (non-Javadoc)
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
	 */
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    IServer server = ServerUtil.getServer(configuration);
    if (server == null) {
        abort(GenericServerCoreMessages.missingServer, null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    }
    @SuppressWarnings("null") ExternalServerBehaviour serverBehavior = (ExternalServerBehaviour) server.loadAdapter(ServerBehaviourDelegate.class, null);
    // initialize the server, check the ports and start the PingThread that will check
    // server state
    serverBehavior.setupLaunch(launch, mode, monitor);
    // get the "external" command
    String commandline = configuration.getAttribute(COMMANDLINE, (String) null);
    if (commandline == null || commandline.length() == 0) {
        abort(GenericServerCoreMessages.commandlineUnspecified, null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    }
    // parse the "external" command into multiple args
    String[] cmdArgs = DebugPlugin.parseArguments(commandline);
    // get the "programArguments", parsed into multiple args
    String[] pgmArgs = DebugPlugin.parseArguments(getProgramArguments(configuration));
    // Create the full array of cmds
    String[] cmds = new String[cmdArgs.length + pgmArgs.length];
    System.arraycopy(cmdArgs, 0, cmds, 0, cmdArgs.length);
    System.arraycopy(pgmArgs, 0, cmds, cmdArgs.length, pgmArgs.length);
    // get a descriptive name for the executable
    String executableName = configuration.getAttribute(EXECUTABLE_NAME, DEFAULT_EXECUTABLE_NAME);
    // get the executable environment
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    String[] env = manager.getEnvironment(configuration);
    // get the working directory
    File workingDir = verifyWorkingDirectory(configuration);
    if (workingDir == null) {
        abort(GenericServerCoreMessages.workingdirUnspecified, null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    }
    // Launch the executable for the configuration using the Ant Execute class
    try {
        Process process = Execute.launch(null, cmds, env, workingDir, true);
        serverBehavior.startPingThread();
        IProcess runtimeProcess = new RuntimeProcess(launch, process, executableName, null);
        launch.addProcess(runtimeProcess);
        serverBehavior.setProcess(runtimeProcess);
    } catch (IOException ioe) {
        abort(GenericServerCoreMessages.errorLaunchingExecutable, ioe, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    }
    if (mode.equals("debug")) {
        // $NON-NLS-1$
        ILaunchConfigurationWorkingCopy wc = createDebuggingConfig(configuration);
        // if we're launching the debugging we need to wait for the config to start
        // before launching the debugging session
        serverBehavior.setDebuggingConfig(wc, mode, launch, monitor);
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ILaunchManager(org.eclipse.debug.core.ILaunchManager) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) IProcess(org.eclipse.debug.core.model.IProcess) IOException(java.io.IOException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) ServerBehaviourDelegate(org.eclipse.wst.server.core.model.ServerBehaviourDelegate) File(java.io.File) IProcess(org.eclipse.debug.core.model.IProcess)

Example 4 with RuntimeProcess

use of org.eclipse.debug.core.model.RuntimeProcess in project ow by vtst.

the class EasyExtProgramLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    Fixture fixture = getFixture(config);
    if (monitor == null)
        monitor = new NullProgressMonitor();
    monitor.beginTask(config.getName() + "...", 3);
    if (monitor.isCanceled())
        return;
    ProcessBuilder pb = this.getProcessBuilder(config, fixture);
    try {
        Process process;
        try {
            // We do not catch NullPointerException or IndexOutOfBoundsException, because it would mean
            // the command of the process is null or empty.
            process = pb.start();
        } catch (SecurityException exn) {
            throw createCoreException(messages.getString("process_security_exception"), exn);
        } catch (IOException exn) {
            throw createCoreException(messages.getString("process_io_exception"), exn);
        }
        launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");
        RuntimeProcess runtimeProcess = new RuntimeProcess(launch, process, "External program", Collections.EMPTY_MAP);
        runtimeProcess.setAttribute(IProcess.ATTR_CMDLINE, Utils.renderCommandLine(pb.command()));
        addProcessListeners(config, fixture, new EasyLaunchConfigurationDelegateUtils.ProcessListernerAcceptorImpl(runtimeProcess));
    } finally {
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) RuntimeProcess(org.eclipse.debug.core.model.RuntimeProcess) IProcess(org.eclipse.debug.core.model.IProcess) IOException(java.io.IOException)

Aggregations

RuntimeProcess (org.eclipse.debug.core.model.RuntimeProcess)4 IOException (java.io.IOException)3 IProcess (org.eclipse.debug.core.model.IProcess)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 File (java.io.File)1 CoreException (org.eclipse.core.runtime.CoreException)1 ILaunch (org.eclipse.debug.core.ILaunch)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 ILaunchManager (org.eclipse.debug.core.ILaunchManager)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IServer (org.eclipse.wst.server.core.IServer)1 ServerBehaviourDelegate (org.eclipse.wst.server.core.model.ServerBehaviourDelegate)1 IErlangDebugNode (org.erlide.backend.debug.IErlangDebugNode)1 ErlangDebugElement (org.erlide.backend.debug.model.ErlangDebugElement)1 ErlDebugFlags (org.erlide.runtime.api.ErlDebugFlags)1