Search in sources :

Example 46 with ILaunchConfiguration

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

the class ImageRunSWTBotTest method testNetworkModeOther.

@Test
public void testNetworkModeOther() throws CoreException {
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "jeffnet");
    final ILaunchConfiguration runDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
    assertThat(runDockerImageLaunchConfig).isNotNull();
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("Test");
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("jeffnet");
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 47 with ILaunchConfiguration

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

the class ImageRunSWTBotTest method testNetworkModeBridge.

@Test
public void testNetworkModeBridge() throws CoreException {
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "bridge");
    final ILaunchConfiguration runDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
    assertThat(runDockerImageLaunchConfig).isNotNull();
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("Test");
    assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("bridge");
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 48 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project dbeaver by dbeaver.

the class DatabaseLaunchShortcut method getCandidates.

protected List<ILaunchConfiguration> getCandidates(DBSObject launchable, ILaunchConfigurationType configType, Map<String, Object> databaseContext) {
    List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
    try {
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(configType);
        candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
        for (int i = 0; i < configs.length; i++) {
            ILaunchConfiguration config = configs[i];
            if (isCandidate(config, launchable, databaseContext)) {
                candidateConfigs.add(config);
            }
        }
    } catch (CoreException e) {
        DebugUI.log(e.getStatus());
    }
    return candidateConfigs;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 49 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project dbeaver by dbeaver.

the class DatabaseLaunchShortcut method launch.

protected void launch(DBSObject launchable, String mode) {
    Map<String, Object> databaseContext = DebugCore.resolveDatabaseContext(launchable);
    List<ILaunchConfiguration> configs = getCandidates(launchable, getConfigurationType(), databaseContext);
    if (configs != null) {
        ILaunchConfiguration config = null;
        int count = configs.size();
        if (count == 1) {
            config = configs.get(0);
        } else if (count > 1) {
            config = chooseConfiguration(configs, mode);
            if (config == null) {
                return;
            }
        }
        if (config == null) {
            try {
                config = createConfiguration(launchable);
            } catch (CoreException e) {
                IStatus status = e.getStatus();
                DebugUI.log(status);
                MessageDialog.openError(getShell(), DebugUIMessages.DatabaseLaunchShortcut_e_launch, status.getMessage());
                return;
            }
        }
        if (config != null) {
            DebugUITools.launch(config, mode);
        }
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject)

Example 50 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project liferay-ide by liferay.

the class PortalServerBehavior method stop.

@Override
public void stop(boolean force) {
    if (force) {
        terminate();
        return;
    }
    int state = getServer().getServerState();
    // If stopped or stopping, no need to run stop command again
    if (state == IServer.STATE_STOPPED || state == IServer.STATE_STOPPING) {
        return;
    } else if (state == IServer.STATE_STARTING) {
        terminate();
        return;
    }
    try {
        if (state != IServer.STATE_STOPPED) {
            setServerState(IServer.STATE_STOPPING);
        }
        final ILaunchConfiguration launchConfig = ((Server) getServer()).getLaunchConfiguration(false, null);
        final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
        final String args = renderCommandLine(getRuntimeStopProgArgs(), " ");
        // Remove JMX arguments if present
        final String existingVMArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null);
        if (existingVMArgs.indexOf(JMX_EXCLUDE_ARGS[0]) >= 0) {
            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, mergeArguments(existingVMArgs, getRuntimeStopVMArguments(), JMX_EXCLUDE_ARGS, false));
        } else {
            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, mergeArguments(existingVMArgs, getRuntimeStopVMArguments(), null, true));
        }
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
        wc.setAttribute("org.eclipse.debug.ui.private", true);
        wc.setAttribute(ATTR_STOP, "true");
        wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
    } catch (Exception e) {
        LiferayServerCore.logError("Error stopping portal", e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) Server(org.eclipse.wst.server.core.internal.Server) IServer(org.eclipse.wst.server.core.IServer) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)275 CoreException (org.eclipse.core.runtime.CoreException)100 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)79 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)51 ILaunchManager (org.eclipse.debug.core.ILaunchManager)41 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)37 IPath (org.eclipse.core.runtime.IPath)20 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 IStatus (org.eclipse.core.runtime.IStatus)16 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IProcess (org.eclipse.debug.core.model.IProcess)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 Status (org.eclipse.core.runtime.Status)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11