use of edu.uah.rsesc.aadlsimulator.ui.handlers.StopHandler in project AGREE by loonwerks.
the class SimulationLaunchShortcut method launch.
public ILaunch launch(final ComponentImplementation componentImplementation, String engineTypeId, final String mode) throws CoreException {
if (engineTypeId == null) {
final SimulationService simulationService = Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationService.class), "Unable to retrieve simulation service");
final EngineType engineType = simulationService.getCompatibleEngineType(componentImplementation);
if (engineType == null) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, FrameworkUtil.getBundle(getClass()).getSymbolicName(), "Unable to find compatible simulation engine for " + componentImplementation.getQualifiedName()), StatusManager.BLOCK);
return null;
}
engineTypeId = engineType.getId();
}
// Stop the current simulation
new StopHandler().execute();
final ILaunchConfigurationType configType = getLaunchConfigurationType();
// Search for an existing launch configuration
final List<ILaunchConfiguration> launchConfigs = getLaunchConfigurations(configType, componentImplementation, engineTypeId);
ILaunchConfiguration launchConfig = launchConfigs.size() > 0 ? launchConfigs.get(0) : null;
if (launchConfig == null) {
final ILaunchConfigurationWorkingCopy wcLaunchConf = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(componentImplementation.getQualifiedName()));
// Set attributes, etc for the launch configuration
wcLaunchConf.setAttribute(SimulationLaunchConfigurationAttributes.COMPONENT_IMPLEMENTATION_NAME, componentImplementation.getQualifiedName());
wcLaunchConf.setAttribute(SimulationLaunchConfigurationAttributes.PROJECT_NAME, getProjectName(componentImplementation.eResource()));
if (engineTypeId != null) {
wcLaunchConf.setAttribute(SimulationLaunchConfigurationAttributes.ENGINE_TYPE_ID, engineTypeId);
}
launchConfig = wcLaunchConf;
}
// Launch the launch configuration
return DebugUITools.buildAndLaunch(launchConfig, mode, new NullProgressMonitor());
}
Aggregations