Search in sources :

Example 1 with ILaunchConfiguration

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

the class Processor method debug.

/**
     * Debug the process using a given context.
     * 
     * @param context Context to be used.
     * @return The configuration to be launched in debug mode.
     * @throws ProcessorException Process failed.
     * @throws CoreException
     * @throws ProcessorException
     */
@Override
public ILaunchConfiguration debug() throws ProcessorException {
    if (context == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("Context is empty, context must be set before call");
    }
    ILaunchConfiguration config = null;
    try {
        setProcessorStates(STATES_EDIT);
        config = (ILaunchConfiguration) saveLaunchConfiguration();
    } catch (CoreException ce) {
        throw new ProcessorException(ce);
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with ILaunchConfiguration

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

the class Processor method getDebugConfiguration.

/**
     * 
     * DOC xzhang Comment method "getDebugConfiguration". For the bug 5430
     * 
     * @param statOption
     * @param traceOption
     * @param codeOptions
     * @return
     * @throws ProcessorException
     */
public ILaunchConfiguration getDebugConfiguration(int statOption, int traceOption, String... codeOptions) throws ProcessorException {
    if (context == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("Context is empty, context must be set before call");
    }
    //$NON-NLS-1$
    StringBuilder parameterStr = new StringBuilder(" ");
    if (codeOptions != null) {
        for (String string : codeOptions) {
            if (string != null) {
                //$NON-NLS-1$
                parameterStr.append(string).append(" ");
            }
        }
    }
    if (statOption != -1) {
        //$NON-NLS-1$
        parameterStr = parameterStr.append(STAT_PORT_ARG + statOption).append(" ");
    }
    if (traceOption != -1) {
        //$NON-NLS-1$
        parameterStr = parameterStr.append(TRACE_PORT_ARG + traceOption).append(" ");
    }
    ILaunchConfiguration config = null;
    try {
        setProcessorStates(STATES_EDIT);
        config = (ILaunchConfiguration) saveLaunchConfigurationWithParam(parameterStr.toString());
    } catch (CoreException ce) {
        throw new ProcessorException(ce);
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 with ILaunchConfiguration

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

the class TalendLaunchToolbarAction method run.

/**
     * Launch the last launch, or open the launch config dialog if none.
     * 
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
     */
@Override
public void run(IAction action) {
    // launch the job that is selected in the repository.
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) selection;
        Object o = sel.getFirstElement();
        if ((o instanceof RepositoryNode)) {
            RepositoryNode node = (RepositoryNode) o;
            if (node.getObject() != null && node.getObject().getRepositoryObjectType().equals(ERepositoryObjectType.PROCESS)) {
                JobLaunchShortcutManager.run(selection);
                return;
            }
        }
    }
    // launch the job that is open in editor
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            if (page.getActivePart() == page.getActiveEditor()) {
                IEditorPart editor = page.getActiveEditor();
                IEditorInput input = editor.getEditorInput();
                if (input instanceof RepositoryEditorInput) {
                    JobLaunchShortcutManager.run(editor);
                    return;
                }
            }
        }
    }
    ILaunchConfiguration configuration = getLastLaunch();
    if (configuration == null) {
        // MessageDialog
        // .openInformation(
        // DebugUIPlugin.getShell(),
        //                            Messages.getString("TalendLaunchToolbarAction.information"), Messages.getString("TalendLaunchToolbarAction.noAvailableItem")); //$NON-NLS-1$ //$NON-NLS-2$
        MessageDialog.openInformation(getShell(), Messages.getString("TalendLaunchToolbarAction.information"), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("TalendLaunchToolbarAction.noAvailableItem"));
    // DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(),
    // getLaunchGroupIdentifier());
    } else {
        DebugUITools.launch(configuration, getMode());
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IEditorInput(org.eclipse.ui.IEditorInput)

Example 4 with ILaunchConfiguration

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

the class JobLaunchShortcut method findLaunchConfiguration.

/**
     * If re-usable configuration associated with the File and the project exist, this configuration is returned.
     * Otherwise a new configuration is created.
     * 
     * @param bin
     * @param mode
     * @return a re-useable or new config or <code>null</code> if none
     */
private ILaunchConfiguration findLaunchConfiguration(ProcessItem file, String mode) {
    ILaunchConfiguration configuration = null;
    List candidateConfigs = Collections.EMPTY_LIST;
    try {
        ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
        candidateConfigs = new ArrayList(configs.length);
        for (ILaunchConfiguration config : configs) {
            String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
            if (projectName == null) {
                continue;
            }
            if (!projectName.equals(ProjectManager.getInstance().getCurrentProject().getLabel())) {
                continue;
            }
            String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
            String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
            if (jobId == null) {
                continue;
            }
            if (file.getProperty().getId().equals(jobId) && file.getProperty().getVersion().equals(jobVersion)) {
                candidateConfigs.add(config);
            }
        }
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
    int candidateCount = candidateConfigs.size();
    if (candidateCount < 1) {
        configuration = createConfiguration(file);
    } else {
        configuration = (ILaunchConfiguration) candidateConfigs.get(0);
    }
    return configuration;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ILaunchConfiguration

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

the class JobLaunchShortcut method createConfiguration.

/**
     * Creates a new configuration associated with the given file.
     * 
     * @param file
     * @return ILaunchConfiguration
     */
private ILaunchConfiguration createConfiguration(ProcessItem file) {
    ILaunchConfiguration config = null;
    String jobId = file.getProperty().getId();
    String jobName = file.getProperty().getLabel();
    String jobVersion = file.getProperty().getVersion();
    ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
    //$NON-NLS-1$
    String displayName = jobName + " " + jobVersion;
    try {
        if (type != null) {
            ILaunchConfigurationWorkingCopy wc = type.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(displayName));
            wc.setAttribute(TalendDebugUIConstants.JOB_NAME, jobName);
            wc.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
            wc.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
            String projectName = ProjectManager.getInstance().getCurrentProject().getLabel();
            wc.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
            config = wc.doSave();
        }
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)266 CoreException (org.eclipse.core.runtime.CoreException)96 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)76 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)50 ILaunchManager (org.eclipse.debug.core.ILaunchManager)40 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)35 IProject (org.eclipse.core.resources.IProject)20 IPath (org.eclipse.core.runtime.IPath)20 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IStatus (org.eclipse.core.runtime.IStatus)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 IProcess (org.eclipse.debug.core.model.IProcess)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 Shell (org.eclipse.swt.widgets.Shell)10 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)10