Search in sources :

Example 76 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class AddConfigurationAction method doAddConfiguration.

protected void doAddConfiguration() {
    try {
        ILaunchConfiguration wc = createTemporaryLaunchConfiguration();
        // $NON-NLS-1$
        int res = DebugUITools.openLaunchConfigurationPropertiesDialog(part.getSite().getShell(), wc, "org.eclipse.debug.ui.launchGroup.run");
        if (res != Window.OK) {
            deleteTemporaryLaunchConfigurations();
        } else {
            makeTemporaryLaunchConfigurationsPermanent();
        }
    } catch (CoreException ce) {
        HibernateConsolePlugin.getDefault().showError(part.getSite().getShell(), HibernateConsoleMessages.AddConfigurationAction_problem_add_console_config, ce);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException)

Example 77 with ILaunchConfiguration

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

the class XpectRunConfiguration method toLaunchConfiguration.

/**
 * Creates an {@link ILaunchConfiguration} containing the information of this instance, only available when run
 * within the Eclipse IDE. If an {@link ILaunchConfiguration} with the same name has been run before, the instance
 * from the launch manager is used. This is usually done in the {@code ILaunchShortcut}.
 *
 * @see #fromLaunchConfiguration(ILaunchConfiguration)
 */
public ILaunchConfiguration toLaunchConfiguration() throws CoreException {
    ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configurationType);
    boolean configurationHasChanged = false;
    for (ILaunchConfiguration config : configs) {
        if (configName.equals(config.getName())) {
            configurationHasChanged = hasConfigurationChanged(config);
            if (!configurationHasChanged) {
                return config;
            }
        }
    }
    IContainer container = null;
    ILaunchConfigurationWorkingCopy workingCopy = configurationType.newInstance(container, configName);
    workingCopy.setAttribute(XT_FILE_TO_RUN, xtFileToRun);
    workingCopy.setAttribute(WORKING_DIRECTORY, workingDirectory.getAbsolutePath());
    return workingCopy.doSave();
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IContainer(org.eclipse.core.resources.IContainer)

Example 78 with ILaunchConfiguration

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

the class TestConfigurationConverter method toLaunchConfiguration.

/**
 * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see TestConfiguration#readPersistentValues()
 */
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) {
    try {
        final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
        for (ILaunchConfiguration config : configs) {
            if (equals(testConfig, config))
                return config;
        }
        final IContainer container = null;
        final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName());
        workingCopy.setAttributes(testConfig.readPersistentValues());
        return workingCopy.doSave();
    } catch (Exception e) {
        throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) WrappedException(org.eclipse.emf.common.util.WrappedException) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IContainer(org.eclipse.core.resources.IContainer) CoreException(org.eclipse.core.runtime.CoreException) WrappedException(org.eclipse.emf.common.util.WrappedException)

Example 79 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmLaunchShortcut method findLaunchConfiguration.

/**
 * Locate a configuration to launch the given binary.<br>
 * If one cannot be found, create one.
 *
 * @param bin   The binary to launched
 *
 * @return A re-usable config or <code>null</code> if none.
 * @throws Exception
 */
protected ILaunchConfiguration findLaunchConfiguration(IBinary bin) throws Exception {
    ILaunchConfigurationType configType = getLaunchConfigType();
    List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
    IPath binPath = bin.getResource().getProjectRelativePath();
    try {
        ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
        candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
        for (ILaunchConfiguration config : configs) {
            IPath programPath = CDebugUtils.getProgramPath(config);
            String projectName = CDebugUtils.getProjectName(config);
            if (programPath != null && programPath.equals(binPath)) {
                if ((projectName != null) && projectName.equals(bin.getCProject().getProject().getName())) {
                    candidateConfigs.add(config);
                }
            }
        }
    } catch (CoreException e) {
        System.err.println(e);
    }
    IProject project = bin.getCProject().getProject();
    // If there are no existing configurations associated with the IBinary,
    // create one. If there is exactly one configuration associated with the
    // IBinary, return it. Otherwise, if there is more than one
    // configuration associated with the IBinary, prompt the user to choose
    // one.
    ILaunchConfiguration configuration = null;
    int candidateCount = candidateConfigs.size();
    if (candidateCount < 1) {
        // Create default launch
        configuration = LaunchParameterUtilities.createLaunchConfig(getActiveWorkbenchShell(), project, bin);
    } else if (candidateCount == 1) {
        configuration = candidateConfigs.get(0);
    } else {
        // Prompt the user to choose a configuration. A null result means
        // the user
        // cancelled the dialog, in which case this method returns null,
        // since canceling the dialog should also cancel launching
        // anything.
        configuration = chooseConfiguration(candidateConfigs);
    }
    return configuration;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) IProject(org.eclipse.core.resources.IProject)

Example 80 with ILaunchConfiguration

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

the class CommandConfirmation method confirmHardReset.

/**
 * Ask the user to confirm hard reset. Warns the user if a running launch
 * could be affected by the reset.
 *
 * @param shell
 * @param repo
 * @return {@code true} if the user confirmed hard reset
 */
public static boolean confirmHardReset(Shell shell, final Repository repo) {
    String question = UIText.ResetTargetSelectionDialog_ResetConfirmQuestion;
    ILaunchConfiguration launch = LaunchFinder.getRunningLaunchConfiguration(Collections.singleton(repo), null);
    if (launch != null) {
        question = MessageFormat.format(question, "\n\n" + // $NON-NLS-1$
        MessageFormat.format(UIText.LaunchFinder_RunningLaunchMessage, launch.getName()));
    } else {
        // $NON-NLS-1$
        question = MessageFormat.format(question, "");
    }
    MessageDialog messageDialog = new MessageDialog(shell, UIText.ResetTargetSelectionDialog_ResetQuestion, null, question, MessageDialog.QUESTION, new String[] { UIText.CommandConfirmationHardResetDialog_resetButtonLabel, IDialogConstants.CANCEL_LABEL }, 0);
    return messageDialog.open() == Window.OK;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

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