Search in sources :

Example 1 with ProgressHelper

use of io.flutter.utils.ProgressHelper in project flutter-intellij by flutter.

the class OpenInXcodeAction method openFile.

private static void openFile(@NotNull VirtualFile file) {
    final Project project = ProjectUtil.guessProjectForFile(file);
    final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null;
    if (sdk == null) {
        FlutterSdkAction.showMissingSdkDialog(project);
        return;
    }
    final PubRoot pubRoot = PubRoot.forFile(file);
    if (pubRoot == null) {
        FlutterMessages.showError("Error Opening Xcode", "Unable to run `flutter build` (no pub root found)");
        return;
    }
    // Trigger an iOS build if necessary.
    if (!hasBeenBuilt(pubRoot)) {
        final ProgressHelper progressHelper = new ProgressHelper(project);
        progressHelper.start("Building for iOS");
        sdk.flutterBuild(pubRoot, "ios", "--debug").start(null, new ProcessAdapter() {

            @Override
            public void processTerminated(@NotNull ProcessEvent event) {
                progressHelper.done();
                if (event.getExitCode() != 0) {
                    FlutterMessages.showError("Error Opening Xcode", "`flutter build` returned: " + event.getExitCode());
                    return;
                }
                openWithXcode(file.getPath());
            }
        });
    } else {
        openWithXcode(file.getPath());
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProgressHelper(io.flutter.utils.ProgressHelper) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot)

Aggregations

ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 Project (com.intellij.openapi.project.Project)1 PubRoot (io.flutter.pub.PubRoot)1 FlutterSdk (io.flutter.sdk.FlutterSdk)1 ProgressHelper (io.flutter.utils.ProgressHelper)1