Search in sources :

Example 6 with ProjectType

use of com.intellij.openapi.project.ProjectType in project flutter-intellij by flutter.

the class AddToAppUtils method initializeAndDetectFlutter.

public static boolean initializeAndDetectFlutter(@NotNull Project project) {
    MessageBusConnection connection = project.getMessageBus().connect(project);
    // GRADLE_SYNC_TOPIC is not public in Android Studio 3.5. It is in 3.6. It isn't defined in 3.4.
    // noinspection unchecked
    Topic<GradleSyncListener> topic = getStaticFieldValue(GradleSyncState.class, Topic.class, "GRADLE_SYNC_TOPIC");
    assert topic != null;
    connection.subscribe(topic, makeSyncListener(project));
    if (!FlutterModuleUtils.hasFlutterModule(project)) {
        connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {

            @Override
            public void moduleAdded(@NotNull Project proj, @NotNull Module mod) {
                if (AndroidUtils.FLUTTER_MODULE_NAME.equals(mod.getName()) || (FlutterUtils.flutterGradleModuleName(project)).equals(mod.getName())) {
                    // connection.disconnect(); TODO(messick) Test this deletion!
                    AppExecutorUtil.getAppExecutorService().execute(() -> {
                        GradleUtils.enableCoeditIfAddToAppDetected(project);
                    });
                }
            }
        });
        return false;
    } else {
        @Nullable ProjectType projectType = ProjectTypeService.getProjectType(project);
        if (projectType != null && "Android".equals(projectType.getId())) {
            // This is an add-to-app project.
            connection.subscribe(DebuggerManagerListener.TOPIC, makeAddToAppAttachListener(project));
        }
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ModuleListener(com.intellij.openapi.project.ModuleListener) GradleSyncListener(com.android.tools.idea.gradle.project.sync.GradleSyncListener) ProjectType(com.intellij.openapi.project.ProjectType) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectType (com.intellij.openapi.project.ProjectType)6 Project (com.intellij.openapi.project.Project)4 Nullable (org.jetbrains.annotations.Nullable)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 GradleSyncListener (com.android.tools.idea.gradle.project.sync.GradleSyncListener)1 ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)1 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)1 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Module (com.intellij.openapi.module.Module)1 ModuleType (com.intellij.openapi.module.ModuleType)1 StdModuleTypes (com.intellij.openapi.module.StdModuleTypes)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ModuleListener (com.intellij.openapi.project.ModuleListener)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 FileUtilRt (com.intellij.openapi.util.io.FileUtilRt)1 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1 LiferayProjectTypeService (com.liferay.ide.idea.core.LiferayProjectTypeService)1