| 1 | package de.uka.ipd.sdq.codegen.simucontroller.runconfig; |
| 2 | |
| 3 | import org.eclipse.core.runtime.CoreException; |
| 4 | import org.eclipse.core.runtime.IConfigurationElement; |
| 5 | import org.eclipse.core.runtime.IProgressMonitor; |
| 6 | import org.eclipse.core.runtime.Platform; |
| 7 | import org.eclipse.debug.core.ILaunch; |
| 8 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 9 | import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; |
| 10 | |
| 11 | import de.uka.ipd.sdq.simulation.AbstractSimulationConfig; |
| 12 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMLaunchConfigurationDelegate; |
| 13 | |
| 14 | public class SimulationWorkflowLauncher implements ILaunchConfigurationDelegate { |
| 15 | |
| 16 | @Override |
| 17 | public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) |
| 18 | throws CoreException { |
| 19 | // find simulator extension by its ID as specified in the launch configuration |
| 20 | String simulatorId = configuration.getAttribute(AbstractSimulationConfig.SIMULATOR_ID, |
| 21 | AbstractSimulationConfig.DEFAULT_SIMULATOR_ID); |
| 22 | IConfigurationElement[] simulatorExtensions = Platform.getExtensionRegistry().getConfigurationElementsFor( |
| 23 | SimulatorExtensionHelper.EXTENSION_POINT_ID); |
| 24 | IConfigurationElement selectedExtension = null; |
| 25 | for (IConfigurationElement extension : simulatorExtensions) { |
| 26 | if (extension.getAttribute("id").equals(simulatorId)) { |
| 27 | selectedExtension = extension; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | // create launch configuration delegate for the selected simulator |
| 32 | AbstractPCMLaunchConfigurationDelegate<?> delegate = null; |
| 33 | try { |
| 34 | delegate = (AbstractPCMLaunchConfigurationDelegate<?>) selectedExtension |
| 35 | .createExecutableExtension("launchDelegate"); |
| 36 | } catch (CoreException e) { |
| 37 | // TODO throw more detailed exception |
| 38 | throw e; |
| 39 | } |
| 40 | |
| 41 | // delegate simulator launch |
| 42 | delegate.launch(configuration, mode, launch, monitor); |
| 43 | } |
| 44 | |
| 45 | } |