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;
}
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;
}
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());
}
}
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;
}
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;
}
Aggregations