Search in sources :

Example 1 with RestartFlutterApp

use of io.flutter.actions.RestartFlutterApp in project flutter-intellij by flutter.

the class FlutterDebugProcess method registerAdditionalActions.

@Override
public void registerAdditionalActions(@NotNull final DefaultActionGroup leftToolbar, @NotNull final DefaultActionGroup topToolbar, @NotNull final DefaultActionGroup settings) {
    if (app.getMode() != RunMode.DEBUG) {
        // Remove the debug-specific actions that aren't needed when we're not debugging.
        // Remove all but specified actions.
        final AnAction[] leftActions = leftToolbar.getChildActionsOrStubs();
        // Not all on the classpath so we resort to Strings.
        final List<String> actionClassNames = Arrays.asList("com.intellij.execution.actions.StopAction", "com.intellij.ui.content.tabs.PinToolwindowTabAction", "com.intellij.execution.ui.actions.CloseAction", "com.intellij.ide.actions.ContextHelpAction");
        for (AnAction a : leftActions) {
            if (!actionClassNames.contains(a.getClass().getName())) {
                leftToolbar.remove(a);
            }
        }
        // Remove all top actions.
        final AnAction[] topActions = topToolbar.getChildActionsOrStubs();
        for (AnAction action : topActions) {
            topToolbar.remove(action);
        }
        // Remove all settings actions.
        final AnAction[] settingsActions = settings.getChildActionsOrStubs();
        for (AnAction a : settingsActions) {
            settings.remove(a);
        }
    }
    // Add actions common to the run and debug windows.
    final Computable<Boolean> isSessionActive = () -> app.isStarted() && getVmConnected() && !getSession().isStopped();
    final Computable<Boolean> canReload = () -> app.getLaunchMode().supportsReload() && isSessionActive.compute() && !app.isReloading();
    final Computable<Boolean> observatoryAvailable = () -> isSessionActive.compute() && app.getConnector().getBrowserUrl() != null;
    if (app.getMode() == RunMode.DEBUG) {
        topToolbar.addSeparator();
        topToolbar.addAction(new FlutterPopFrameAction());
    }
    topToolbar.addSeparator();
    topToolbar.addAction(new ReloadFlutterApp(app, canReload));
    topToolbar.addAction(new RestartFlutterApp(app, canReload));
    topToolbar.addSeparator();
    topToolbar.addAction(new OpenObservatoryAction(app.getConnector(), observatoryAvailable));
    topToolbar.addAction(new OpenTimelineViewAction(app.getConnector(), observatoryAvailable));
    topToolbar.addSeparator();
    topToolbar.addAction(new OpenFlutterViewAction(isSessionActive));
// Don't call super since we have our own observatory action.
}
Also used : ReloadFlutterApp(io.flutter.actions.ReloadFlutterApp) RestartFlutterApp(io.flutter.actions.RestartFlutterApp) OpenFlutterViewAction(io.flutter.view.OpenFlutterViewAction) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)1 ReloadFlutterApp (io.flutter.actions.ReloadFlutterApp)1 RestartFlutterApp (io.flutter.actions.RestartFlutterApp)1 OpenFlutterViewAction (io.flutter.view.OpenFlutterViewAction)1