Search in sources :

Example 41 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method renameJobLaunch.

/**
     * 
     * cli Comment method "renameJobLaunch".
     */
public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
        return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
        Project project = ProjectManager.getInstance().getProject(property);
        if (project == null) {
            return;
        }
        final String objProjectName = project.getLabel();
        final String id = property.getId();
        final String version = property.getVersion();
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        if (launchManager == null) {
            return;
        }
        try {
            for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
                String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
                String jobVersion = configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
                String projectName = configuration.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
                // ILaunchConfigurationType type = launchManager
                // .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
                ILaunchConfigurationType type = configuration.getType();
                if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && id.equals(jobId) && version.equals(jobVersion) && type != null) {
                    //$NON-NLS-1$
                    String displayName = newLabel + " " + jobVersion;
                    ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
                    workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
                    // workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
                    // update to new version
                    workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
                    // workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
                    workingCopy.rename(displayName);
                    workingCopy.doSave();
                    break;
                }
            }
            clearUnusedLaunchs();
        } catch (CoreException e) {
        // nothing to do
        }
    }
}
Also used : Project(org.talend.core.model.properties.Project) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Property(org.talend.core.model.properties.Property)

Example 42 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method removeJobLaunch.

// debug not used yet, so code is disabled
// public static void debug(ISelection selection) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(selection, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
//
// public static void debug(IEditorPart editor) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(editor, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
/**
     * 
     * cli Comment method "removeJobLaunch".
     */
public static void removeJobLaunch(IRepositoryViewObject objToDelete) {
    if (objToDelete == null) {
        return;
    }
    Property property = objToDelete.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    Project project = ProjectManager.getInstance().getProject(property);
    if (project == null) {
        return;
    }
    final String objProjectName = project.getLabel();
    final String objId = property.getId();
    // final String objName = property.getLabel();
    final String objVersion = property.getVersion();
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    if (launchManager == null) {
        return;
    }
    try {
        ILaunchConfiguration configuration = null;
        for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) {
            String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
            // String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String) null);
            String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
            String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
            ILaunchConfigurationType type = config.getType();
            if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && objId.equals(jobId) && objVersion.equals(jobVersion)) {
                configuration = config;
                break;
            }
        }
        if (configuration == null) {
            return;
        }
        configuration.delete();
    } catch (CoreException e) {
    // nothing to do
    }
}
Also used : Project(org.talend.core.model.properties.Project) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) Property(org.talend.core.model.properties.Property)

Example 43 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class JavaProcessor method saveLaunchConfiguration.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.runprocess.IProcessor#saveLaunchConfiguration()
     */
@Override
public Object saveLaunchConfiguration() throws CoreException {
    /*
         * When launch debug progress, just share all libraries between farther job and child jobs
         */
    // computeLibrariesPath(this.getProcess().getNeededLibraries(true));
    ILaunchConfiguration config = null;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String projectName = this.getCodeProject().getName();
    ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    if (type != null) {
        ILaunchConfigurationWorkingCopy wc = type.newInstance(null, launchManager.generateUniqueLaunchConfigurationNameFrom(this.getCodePath().lastSegment()));
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, this.getMainClass());
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, true);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, CTX_ARG + context.getName());
        config = wc.doSave();
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 44 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project tdi-studio-se by Talend.

the class JavaProcessor method saveLaunchConfigurationWithParam.

// generate the ILaunchConfiguration with the parameter string.
@Override
public Object saveLaunchConfigurationWithParam(String parameterStr) throws CoreException {
    /*
         * When launch debug progress, just share all libraries between farther job and child jobs
         */
    // computeLibrariesPath(this.getProcess().getNeededLibraries(true));
    ILaunchConfiguration config = null;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String projectName = this.getCodeProject().getName();
    ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    if (type != null) {
        ILaunchConfigurationWorkingCopy wc = type.newInstance(null, launchManager.generateUniqueLaunchConfigurationNameFrom(this.getCodePath().lastSegment()));
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, this.getMainClass());
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, true);
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, CTX_ARG + context.getName() + parameterStr);
        config = wc.doSave();
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 45 with ILaunchManager

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

the class DebugCore method createConfiguration.

public static ILaunchConfigurationWorkingCopy createConfiguration(IContainer container, String typeName, String name) throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(typeName);
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, name);
    return workingCopy;
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

ILaunchManager (org.eclipse.debug.core.ILaunchManager)78 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)53 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)41 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)37 CoreException (org.eclipse.core.runtime.CoreException)28 ArrayList (java.util.ArrayList)15 ILaunch (org.eclipse.debug.core.ILaunch)14 IPath (org.eclipse.core.runtime.IPath)9 File (java.io.File)7 HashMap (java.util.HashMap)6 Path (org.eclipse.core.runtime.Path)6 IProject (org.eclipse.core.resources.IProject)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IOException (java.io.IOException)4 Map (java.util.Map)4 IStatus (org.eclipse.core.runtime.IStatus)4 LinkedList (java.util.LinkedList)3 Status (org.eclipse.core.runtime.Status)3 IProcess (org.eclipse.debug.core.model.IProcess)3 IProcess2 (org.talend.core.model.process.IProcess2)3