Search in sources :

Example 1 with ExporterProxy

use of edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService.ExporterProxy 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();
                }
            });
        }
    }
}
Also used : SimulationUIService(edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService) IAction(org.eclipse.jface.action.IAction) AGREESimulationEngine(edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine) ExporterProxy(edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService.ExporterProxy) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SimulatorState(edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AGREESimulatorExtensionService(edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService) MenuItem(org.eclipse.swt.widgets.MenuItem)

Aggregations

AGREESimulationEngine (edu.uah.rsesc.aadlsimulator.agree.engine.AGREESimulationEngine)1 AGREESimulatorExtensionService (edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService)1 ExporterProxy (edu.uah.rsesc.aadlsimulator.agree.services.AGREESimulatorExtensionService.ExporterProxy)1 SimulationUIService (edu.uah.rsesc.aadlsimulator.ui.services.SimulationUIService)1 SimulatorState (edu.uah.rsesc.aadlsimulator.ui.services.SimulatorState)1 IAction (org.eclipse.jface.action.IAction)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1