Search in sources :

Example 1 with LibraryEditorListener

use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener in project intellij-community by JetBrains.

the class ArtifactsStructureConfigurable method init.

public void init(StructureConfigurableContext context, ModuleStructureConfigurable moduleStructureConfigurable, ProjectLibrariesConfigurable projectLibrariesConfig, GlobalLibrariesConfigurable globalLibrariesConfig) {
    super.init(context);
    myPackagingEditorContext = new ArtifactsStructureConfigurableContextImpl(myContext, myProject, myDefaultSettings, new ArtifactAdapter() {

        @Override
        public void artifactAdded(@NotNull Artifact artifact) {
            final MyNode node = addArtifactNode(artifact);
            selectNodeInTree(node);
            myContext.getDaemonAnalyzer().queueUpdate(myPackagingEditorContext.getOrCreateArtifactElement(artifact));
        }
    });
    context.getModulesConfigurator().addAllModuleChangeListener(new ModuleEditor.ChangeListener() {

        @Override
        public void moduleStateChanged(ModifiableRootModel moduleRootModel) {
            for (ProjectStructureElement element : getProjectStructureElements()) {
                myContext.getDaemonAnalyzer().queueUpdate(element);
            }
        }
    });
    final ItemsChangeListener listener = new ItemsChangeListener() {

        @Override
        public void itemChanged(@Nullable Object deletedItem) {
            if (deletedItem instanceof Library || deletedItem instanceof Module) {
                onElementDeleted();
            }
        }

        @Override
        public void itemsExternallyChanged() {
        }
    };
    moduleStructureConfigurable.addItemsChangeListener(listener);
    projectLibrariesConfig.addItemsChangeListener(listener);
    globalLibrariesConfig.addItemsChangeListener(listener);
    context.addLibraryEditorListener(new LibraryEditorListener() {

        @Override
        public void libraryRenamed(@NotNull Library library, String oldName, String newName) {
            final Artifact[] artifacts = myPackagingEditorContext.getArtifactModel().getArtifacts();
            for (Artifact artifact : artifacts) {
                updateLibraryElements(artifact, library, oldName, newName);
            }
        }
    });
}
Also used : LibraryEditorListener(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) NotNull(org.jetbrains.annotations.NotNull) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor) InvalidArtifact(com.intellij.packaging.impl.artifacts.InvalidArtifact) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Module (com.intellij.openapi.module.Module)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 Library (com.intellij.openapi.roots.libraries.Library)1 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)1 LibraryEditorListener (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener)1 ProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)1 InvalidArtifact (com.intellij.packaging.impl.artifacts.InvalidArtifact)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1