Search in sources :

Example 71 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project generator by mybatis.

the class GeneratorLaunchShortcut method findOrCreateLaunchConfiguration.

private ILaunchConfiguration findOrCreateLaunchConfiguration(IFile file) throws CoreException {
    ILaunchConfigurationType ctype = getLaunchConfigurationType();
    ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(ctype);
    List<ILaunchConfiguration> candidateConfigs = new ArrayList<>(configs.length);
    for (ILaunchConfiguration config : configs) {
        String configFile = config.getAttribute(GeneratorLaunchConstants.ATTR_CONFIGURATION_FILE_NAME, (String) null);
        try {
            configFile = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configFile);
        } catch (CoreException e) {
            continue;
        }
        Path path = new Path(configFile);
        if (path.equals(file.getLocation())) {
            candidateConfigs.add(config);
        }
    }
    ILaunchConfiguration config;
    if (candidateConfigs.size() > 1) {
        config = chooseConfiguration(candidateConfigs);
    } else if (candidateConfigs.size() == 1) {
        config = candidateConfigs.get(0);
    } else {
        config = createConfiguration(file);
    }
    return config;
}
Also used : Path(org.eclipse.core.runtime.Path) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList)

Example 72 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project generator by mybatis.

the class GeneratorLaunchShortcut method createConfiguration.

private ILaunchConfiguration createConfiguration(IFile file) throws CoreException {
    ILaunchConfigurationType configType = getLaunchConfigurationType();
    String variableExpression = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", // $NON-NLS-1$
    file.getFullPath().toPortableString());
    // $NON-NLS-1$
    String namePrefix = String.format("%s-%s", file.getProject().getName(), file.getName());
    ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(namePrefix));
    wc.setAttribute(GeneratorLaunchConstants.ATTR_CONFIGURATION_FILE_NAME, variableExpression);
    wc.setMappedResources(new IResource[] { file.getProject() });
    wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, getJavaProjectNameFromResource(file));
    ILaunchConfiguration config = wc.doSave();
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 73 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project iobserve-analysis by research-iobserve.

the class PerOpteryxLaunchConfigurationBuilder method getDefaultLaunchConfiguration.

/**
 * Returns a default launch configuration.
 *
 * @param projectModelDir
 *            The Peropteryx project dir in eclipse workspace
 * @param sourceModelDir
 *            The PCM model directory
 * @return The launch configuration
 * @throws CoreException
 *             when creating or saving the launch configuration fails
 */
public static ILaunchConfiguration getDefaultLaunchConfiguration(final String projectModelDir, final String sourceModelDir) throws CoreException {
    final Map<String, Object> attr = new HashMap<>();
    PerOpteryxLaunchConfigurationBuilder.setDefaultConfigFiles(projectModelDir, attr);
    PerOpteryxLaunchConfigurationBuilder.setDefaultGeneralOptions(attr);
    PerOpteryxLaunchConfigurationBuilder.setDefaultAnalysisOptions(attr);
    PerOpteryxLaunchConfigurationBuilder.setDefaultResourceOptions(attr);
    PerOpteryxLaunchConfigurationBuilder.setDefaultReliabilityOptions(attr);
    // setSimuComDefaultOptions(attr);
    PerOpteryxLaunchConfigurationBuilder.setLQNSDefaultOptions(attr, projectModelDir, sourceModelDir);
    PerOpteryxLaunchConfigurationBuilder.setDefaultTacticsOptions(attr);
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    final ILaunchConfigurationType launchConfigType = launchManager.getLaunchConfigurationType(PerOpteryxLaunchConfigurationBuilder.DSE_LAUNCH_TYPE_ID);
    final ILaunchConfigurationWorkingCopy workingCopy = launchConfigType.newInstance(null, PerOpteryxLaunchConfigurationBuilder.DEFAULT_LAUNCH_CONFIG_NAME);
    workingCopy.setAttributes(attr);
    final ILaunchConfiguration launchConfig = workingCopy.doSave();
    return launchConfig;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) HashMap(java.util.HashMap) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 74 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project statecharts by Yakindu.

the class StatechartLaunchShortcut method createNewLaunchConfiguration.

protected ILaunchConfiguration createNewLaunchConfiguration(IFile file) {
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(getConfigType());
    try {
        ILaunchConfigurationWorkingCopy newConfig = configType.newInstance(null, launchManager.generateLaunchConfigurationName(file.getName()));
        newConfig.setAttribute(FILE_NAME, file.getFullPath().toString());
        return newConfig.doSave();
    } catch (CoreException e) {
        e.printStackTrace();
    }
    throw new IllegalStateException();
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 75 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project azure-tools-for-java by Microsoft.

the class MavenExecuteAction method createLaunchConfiguration.

private ILaunchConfiguration createLaunchConfiguration(IContainer basedir) {
    try {
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);
        String launchSafeGoalName = goalName.replace(':', '-');
        ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, launchSafeGoalName);
        workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString());
        workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goalName);
        workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
        workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${project}");
        workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true);
        setProjectConfiguration(workingCopy, basedir);
        IPath path = getJREContainerPath(basedir);
        if (path != null) {
            workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString());
        }
        return workingCopy;
    } catch (CoreException ex) {
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)91 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)62 ILaunchManager (org.eclipse.debug.core.ILaunchManager)54 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)50 CoreException (org.eclipse.core.runtime.CoreException)43 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)8 IPath (org.eclipse.core.runtime.IPath)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6 Path (org.eclipse.core.runtime.Path)6 ILaunch (org.eclipse.debug.core.ILaunch)6 File (java.io.File)5 IOException (java.io.IOException)5 Map (java.util.Map)5 IProject (org.eclipse.core.resources.IProject)5 IResource (org.eclipse.core.resources.IResource)4 IStatus (org.eclipse.core.runtime.IStatus)4 List (java.util.List)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2