Search in sources :

Example 1 with FacetManagerAdapter

use of com.intellij.facet.FacetManagerAdapter in project android by JetBrains.

the class AndroidProjectComponent method projectOpened.

@Override
public void projectOpened() {
    final CompilerManager manager = CompilerManager.getInstance(myProject);
    manager.addBeforeTask(new AndroidPrecompileTask());
    myDisposable = Disposer.newDisposable(getClass().getName());
    if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
        if (ProjectFacetManager.getInstance(myProject).hasFacets(AndroidFacet.ID)) {
            createAndroidSpecificComponents();
        } else {
            final MessageBusConnection connection = myProject.getMessageBus().connect(myDisposable);
            connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {

                @Override
                public void facetAdded(@NotNull Facet facet) {
                    if (facet instanceof AndroidFacet) {
                        createAndroidSpecificComponents();
                        connection.disconnect();
                    }
                }
            });
        }
    }
}
Also used : AndroidPrecompileTask(org.jetbrains.android.compiler.AndroidPrecompileTask) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) CompilerManager(com.intellij.openapi.compiler.CompilerManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) FacetManagerAdapter(com.intellij.facet.FacetManagerAdapter) Facet(com.intellij.facet.Facet) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 2 with FacetManagerAdapter

use of com.intellij.facet.FacetManagerAdapter in project intellij-plugins by JetBrains.

the class OsmorcPostStartupActivity method runActivity.

@Override
public void runActivity(@NotNull Project project) {
    if (project.isDefault()) {
        return;
    }
    MessageBusConnection connection = project.getMessageBus().connect();
    connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {

        @Override
        public void facetAdded(@NotNull Facet facet) {
            handleFacetChange(facet, project);
        }

        @Override
        public void facetConfigurationChanged(@NotNull Facet facet) {
            handleFacetChange(facet, project);
        }
    });
    connection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {

        @Override
        public void projectClosing(Project project) {
            for (Module module : ModuleManager.getInstance(project).getModules()) {
                AdditionalJARContentsWatcherManager.getInstance(module).cleanup();
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ProjectManagerListener(com.intellij.openapi.project.ProjectManagerListener) Module(com.intellij.openapi.module.Module) FacetManagerAdapter(com.intellij.facet.FacetManagerAdapter) Facet(com.intellij.facet.Facet)

Example 3 with FacetManagerAdapter

use of com.intellij.facet.FacetManagerAdapter in project intellij-community by JetBrains.

the class FacetPointersManagerImpl method initComponent.

@Override
public void initComponent() {
    MessageBusConnection connection = myProject.getMessageBus().connect();
    connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {

        @Override
        public void moduleAdded(@NotNull Project project, @NotNull Module module) {
            refreshPointers(module);
        }

        @Override
        public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
            for (Module module : modules) {
                refreshPointers(module);
            }
        }
    });
    connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {

        @Override
        public void facetAdded(@NotNull Facet facet) {
            refreshPointers(facet.getModule());
        }

        @Override
        public void beforeFacetRenamed(@NotNull Facet facet) {
            final FacetPointerImpl pointer = myPointers.get(constructId(facet));
            if (pointer != null) {
                pointer.refresh();
            }
        }

        @Override
        public void facetRenamed(@NotNull final Facet facet, @NotNull final String oldName) {
            refreshPointers(facet.getModule());
        }
    });
    for (Module module : ModuleManager.getInstance(myProject).getModules()) {
        refreshPointers(module);
    }
}
Also used : Project(com.intellij.openapi.project.Project) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ModuleListener(com.intellij.openapi.project.ModuleListener) Module(com.intellij.openapi.module.Module) FacetManagerAdapter(com.intellij.facet.FacetManagerAdapter) Facet(com.intellij.facet.Facet)

Aggregations

Facet (com.intellij.facet.Facet)3 FacetManagerAdapter (com.intellij.facet.FacetManagerAdapter)3 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 CompilerManager (com.intellij.openapi.compiler.CompilerManager)1 ModuleListener (com.intellij.openapi.project.ModuleListener)1 ProjectManagerListener (com.intellij.openapi.project.ProjectManagerListener)1 AndroidPrecompileTask (org.jetbrains.android.compiler.AndroidPrecompileTask)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1