Search in sources :

Example 1 with OpenFlutterViewAction

use of io.flutter.view.OpenFlutterViewAction in project flutter-intellij by flutter.

the class LaunchState method setUpConsoleAndActions.

@NotNull
private ExecutionResult setUpConsoleAndActions(@NotNull FlutterApp app) throws ExecutionException {
    final ConsoleView console = createConsole(getEnvironment().getExecutor());
    if (console != null) {
        app.setConsole(console);
        console.attachToProcess(app.getProcessHandler());
    }
    // Add observatory actions.
    // These actions are effectively added only to the Run tool window.
    // For Debug see FlutterDebugProcess.registerAdditionalActions()
    final Computable<Boolean> observatoryAvailable = () -> !app.getProcessHandler().isProcessTerminated() && app.getConnector().getBrowserUrl() != null;
    final List<AnAction> actions = new ArrayList<>(Arrays.asList(super.createActions(console, app.getProcessHandler(), getEnvironment().getExecutor())));
    actions.add(new Separator());
    actions.add(new OpenObservatoryAction(app.getConnector(), observatoryAvailable));
    actions.add(new OpenTimelineViewAction(app.getConnector(), observatoryAvailable));
    actions.add(new Separator());
    actions.add(new OpenFlutterViewAction(() -> !app.getProcessHandler().isProcessTerminated()));
    return new DefaultExecutionResult(console, app.getProcessHandler(), actions.toArray(new AnAction[actions.size()]));
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) ArrayList(java.util.ArrayList) OpenFlutterViewAction(io.flutter.view.OpenFlutterViewAction) AnAction(com.intellij.openapi.actionSystem.AnAction) Separator(com.intellij.openapi.actionSystem.Separator) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with OpenFlutterViewAction

use of io.flutter.view.OpenFlutterViewAction 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)2 OpenFlutterViewAction (io.flutter.view.OpenFlutterViewAction)2 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Separator (com.intellij.openapi.actionSystem.Separator)1 ReloadFlutterApp (io.flutter.actions.ReloadFlutterApp)1 RestartFlutterApp (io.flutter.actions.RestartFlutterApp)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1