Search in sources :

Example 1 with IEclipseProcessor

use of org.talend.core.model.runprocess.IEclipseProcessor in project tdi-studio-se by Talend.

the class ProcessDebugDialog method okPressed.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
     */
@Override
protected void okPressed() {
    if (contextComposite.promptConfirmLauch()) {
        final IContext context = contextComposite.getSelectedContext();
        super.okPressed();
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                IProcessor processor = ProcessorUtilities.getProcessor(process, process.getProperty(), context);
                //$NON-NLS-1$
                monitor.beginTask("Launching debugger", IProgressMonitor.UNKNOWN);
                try {
                    // use this function to generate childrens also.
                    ProcessorUtilities.generateCode(process, context, false, false, true, monitor);
                    ILaunchConfiguration config = ((IEclipseProcessor) processor).debug();
                    if (config != null) {
                        // PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new
                        // DebugInNewWindowListener());
                        DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
                    } else {
                        MessageDialog.openInformation(getShell(), Messages.getString("ProcessDebugDialog.debugBtn"), //$NON-NLS-1$
                        Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
                        "ProcessDebugDialog.errortext"));
                    }
                } catch (ProcessorException e) {
                    IStatus status = new Status(IStatus.ERROR, RunProcessPlugin.PLUGIN_ID, IStatus.OK, "Debug launch failed.", //$NON-NLS-1$
                    e);
                    RunProcessPlugin.getDefault().getLog().log(status);
                    //$NON-NLS-1$
                    MessageDialog.openError(//$NON-NLS-1$
                    getShell(), //$NON-NLS-1$
                    Messages.getString("ProcessDebugDialog.debugBtn"), //$NON-NLS-1$
                    "");
                } finally {
                    monitor.done();
                }
            }
        };
        IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
        try {
            progressService.runInUI(PlatformUI.getWorkbench().getProgressService(), worker, ResourcesPlugin.getWorkspace().getRoot());
        } catch (InvocationTargetException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        } catch (InterruptedException e) {
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) IContext(org.talend.core.model.process.IContext) ProcessorException(org.talend.designer.runprocess.ProcessorException) IProgressService(org.eclipse.ui.progress.IProgressService) IProcessor(org.talend.designer.runprocess.IProcessor) IEclipseProcessor(org.talend.core.model.runprocess.IEclipseProcessor) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IProgressService (org.eclipse.ui.progress.IProgressService)1 IContext (org.talend.core.model.process.IContext)1 IEclipseProcessor (org.talend.core.model.runprocess.IEclipseProcessor)1 IProcessor (org.talend.designer.runprocess.IProcessor)1 ProcessorException (org.talend.designer.runprocess.ProcessorException)1