Search in sources :

Example 76 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project bndtools by bndtools.

the class AbstractLaunchShortcut method getLaunchConfigsForProject.

protected ILaunchConfiguration[] getLaunchConfigsForProject(@SuppressWarnings("unused") IProject project) {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchId);
    try {
        ILaunchConfiguration[] all = manager.getLaunchConfigurations(type);
        List<ILaunchConfiguration> result = new ArrayList<ILaunchConfiguration>(all.length);
        return result.toArray(new ILaunchConfiguration[0]);
    } catch (CoreException e) {
        logger.logError("Error retrieving launch configurations.", e);
        return null;
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 77 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project bndtools by bndtools.

the class AbstractLaunchShortcut method createConfiguration.

protected ILaunchConfigurationWorkingCopy createConfiguration(IPath targetPath, IProject targetProject) throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType configType = manager.getLaunchConfigurationType(launchId);
    ILaunchConfigurationWorkingCopy wc;
    wc = configType.newInstance(null, manager.generateLaunchConfigurationName(targetPath.lastSegment()));
    wc.setAttribute(LaunchConstants.ATTR_LAUNCH_TARGET, targetPath.toString());
    wc.setAttribute(LaunchConstants.ATTR_CLEAN, LaunchConstants.DEFAULT_CLEAN);
    wc.setAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES);
    if (targetProject != null) {
        IJavaProject javaProject = JavaCore.create(targetProject);
        if (javaProject.exists()) {
            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, targetProject.getName());
        }
    }
    return wc;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 78 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project titan.EclipsePlug-ins by eclipse.

the class LaunchShortcut method getWorkingCopy.

protected ILaunchConfigurationWorkingCopy getWorkingCopy(final IProject project, final IFile file, final String mode) {
    try {
        final ILaunchConfigurationType configurationType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(getConfigurationId());
        final ILaunchConfiguration[] configurations = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configurationType);
        final List<ILaunchConfiguration> candidateConfigurations = new ArrayList<ILaunchConfiguration>();
        for (ILaunchConfiguration configuration : configurations) {
            IResource[] resources = configuration.getMappedResources();
            if (null != resources) {
                boolean found = false;
                for (IResource resource : resources) {
                    if (file.equals(resource)) {
                        found = true;
                    }
                }
                if (found) {
                    candidateConfigurations.add(configuration);
                }
            }
        }
        if (1 == candidateConfigurations.size()) {
            candidateConfigurations.get(0).launch(mode, null);
            return null;
        } else if (candidateConfigurations.size() > 1) {
            ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
            ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, labelProvider);
            dialog.setTitle(getDialogTitle());
            dialog.setMessage("Select existing configuration:");
            dialog.setElements(candidateConfigurations.toArray(new ILaunchConfiguration[candidateConfigurations.size()]));
            if (dialog.open() == Window.OK) {
                ILaunchConfiguration result = (ILaunchConfiguration) dialog.getFirstResult();
                result.launch(mode, null);
                labelProvider.dispose();
                return null;
            }
            labelProvider.dispose();
        }
        final String configurationName = "new configuration (" + file.getFullPath().toString().replace("/", "__") + ")";
        ILaunchConfigurationWorkingCopy wc = configurationType.newInstance(null, configurationName);
        wc.setMappedResources(new IResource[] { project });
        wc.setAttribute(EXECUTECONFIGFILEONLAUNCH, true);
        return wc;
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return null;
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ArrayList(java.util.ArrayList) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IResource(org.eclipse.core.resources.IResource)

Example 79 with ILaunchConfigurationType

use of org.eclipse.debug.core.ILaunchConfigurationType in project titan.EclipsePlug-ins by eclipse.

the class LaunchShortcutConfig method getWorkingCopy.

protected ILaunchConfigurationWorkingCopy getWorkingCopy(final IProject project, final IFile file, final String mode) {
    try {
        final ILaunchConfigurationType configurationType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(getConfigurationId());
        final ILaunchConfiguration[] configurations = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configurationType);
        final List<ILaunchConfiguration> candidateConfigurations = new ArrayList<ILaunchConfiguration>();
        for (ILaunchConfiguration configuration : configurations) {
            IResource[] resources = configuration.getMappedResources();
            if (null != resources) {
                boolean found = false;
                for (IResource resource : resources) {
                    if (file.equals(resource)) {
                        found = true;
                    }
                }
                if (found) {
                    candidateConfigurations.add(configuration);
                }
            }
        }
        if (1 == candidateConfigurations.size()) {
            candidateConfigurations.get(0).launch(mode, null);
            return null;
        } else if (candidateConfigurations.size() > 1) {
            final ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
            final ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, labelProvider);
            dialog.setTitle(getDialogTitle());
            dialog.setMessage("Select existing configuration.");
            dialog.setElements(candidateConfigurations.toArray(new ILaunchConfiguration[candidateConfigurations.size()]));
            if (dialog.open() == Window.OK) {
                final ILaunchConfiguration result = (ILaunchConfiguration) dialog.getFirstResult();
                result.launch(mode, null);
                labelProvider.dispose();
                return null;
            }
            labelProvider.dispose();
        }
        // size() == 0 case: create new configuration
        final String configurationName = "new configuration (" + file.getFullPath().toString().replace("/", "__") + ")";
        final ILaunchConfigurationWorkingCopy wc = configurationType.newInstance(null, configurationName);
        wc.setMappedResources(new IResource[] { project, file });
        wc.setAttribute(EXECUTECONFIGFILEONLAUNCH, true);
        return wc;
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return null;
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ArrayList(java.util.ArrayList) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IResource(org.eclipse.core.resources.IResource)

Example 80 with ILaunchConfigurationType

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

the class HibernateJpaPlatformUi method createDefaultLaunchConfig.

public static ILaunchConfigurationWorkingCopy createDefaultLaunchConfig(String projectName) {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LaunchConfigurationType_ID);
    ILaunchConfigurationWorkingCopy wc = null;
    try {
        // $NON-NLS-1$
        wc = launchConfigurationType.newInstance(null, projectName + "-hibernate-generate");
        // Create exporters
        List<String> exporters = new ArrayList<String>();
        exporters.add(exporter_id);
        wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, exporters);
        wc.setAttribute(full_exporter_id, true);
    } catch (CoreException e) {
        HibernateJptUIPlugin.logException(e);
    }
    return wc;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) 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