use of edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService in project AGREE by loonwerks.
the class ExporterMenuContributionItem method fill.
@Override
public void fill(final Menu menu, int index) {
final SimulationUIService simUiService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "Unable to retrieve Simulation UI Service");
final SimulatorState simulatorState = simUiService.getCurrentState();
final boolean visible = simulatorState.getEngineState() != null && simulatorState.getSimulationEngine() instanceof AGREESimulationEngine;
if (visible) {
final AGREESimulatorExtensionService extService = Objects.requireNonNull((AGREESimulatorExtensionService) PlatformUI.getWorkbench().getService(AGREESimulatorExtensionService.class), "unable to get AGREE Simulator Extension service");
for (final ExporterProxy exporter : extService.getExporters()) {
final IAction exporterAction = new ExportAction(exporter);
final MenuItem exporterMenuItem = new MenuItem(menu, SWT.CHECK, index++);
exporterMenuItem.setEnabled(simUiService.getCurrentState().getEngineState().getNumberOfFrames() > 0);
exporterMenuItem.setText(exporter.getName());
exporterMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
exporterAction.run();
}
});
}
}
}
Aggregations