use of edu.uah.rsesc.aadlsimulator.ui.dialogs.VariablesChartDialog in project AGREE by loonwerks.
the class OpenVariablesChartHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
final SimulationUIService simulationUIService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "unable to get simulation UI service");
// Open Value Visualization Chart
simulationUIService.getCurrentState().getSimulationEngine().queueNotification(new NotificationHandler() {
@Override
public void handleNotification(final SimulationEngineNotification notification) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
if (simulationUIService.getCurrentState().getEngineState().getNumberOfFrames() != 0) {
simulationUIService.lockUserInterface();
final Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.SHELL_TRIM & ~SWT.MIN);
// Listening for cancellation
final SimulatorStateListener simCanceledListener = new SimulatorStateListener() {
@Override
public void onSimulatorStateChanged(SimulatorState simulatorState) {
if (simulationUIService.getCurrentState().getEngineState() == null) {
if (shell != null && !shell.isDisposed()) {
// Close view on cancel
shell.close();
}
}
}
};
simulationUIService.addStateChangeListener(simCanceledListener);
try {
new VariablesChartDialog(shell, simulationUIService);
} finally {
simulationUIService.removeStateChangeListener(simCanceledListener);
simulationUIService.unlockUserInterface();
}
}
}
});
}
});
} catch (final Exception ex) {
final Status status = new Status(IStatus.ERROR, FrameworkUtil.getBundle(getClass()).getSymbolicName(), "Error", ex);
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
}
return null;
}
Aggregations