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);
}
}
});
}
Aggregations