use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.
the class AddFrameworkSupportInProjectStructureAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Module module = getSelectedModule();
if (module == null)
return;
final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myModuleStructureConfigurable.getContext());
new AddSupportForSingleFrameworkDialog(module, myFrameworkType, myProvider, librariesContainer, new IdeaModifiableModelsProvider()).show();
}
use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.
the class AddSupportForSingleFrameworkDialog method createDialog.
public static AddSupportForSingleFrameworkDialog createDialog(@NotNull Module module, @NotNull FrameworkSupportInModuleProvider provider) {
List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(module, DefaultFacetsProvider.INSTANCE);
if (providers.isEmpty())
return null;
IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
LibrariesContainer container = LibrariesContainerFactory.createContainer(modifiableModelsProvider.getModuleModifiableModel(module));
return new AddSupportForSingleFrameworkDialog(module, provider.getFrameworkType(), provider, container, modifiableModelsProvider);
}
use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.
the class AddSupportForSingleFrameworkDialog method askAndRemoveDuplicatedLibraryEntry.
private boolean askAndRemoveDuplicatedLibraryEntry(@NotNull ModifiableRootModel rootModel, @NotNull CustomLibraryDescription description) {
List<OrderEntry> existingEntries = new ArrayList<>();
final LibrariesContainer container = myModel.getLibrariesContainer();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof LibraryOrderEntry))
continue;
final Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null)
continue;
if (LibraryPresentationManager.getInstance().isLibraryOfKind(library, container, description.getSuitableLibraryKinds())) {
existingEntries.add(entry);
}
}
if (!existingEntries.isEmpty()) {
String message;
if (existingEntries.size() > 1) {
message = "There are already " + existingEntries.size() + " " + myFrameworkType.getPresentableName() + " libraries.\n Do you want to replace them?";
} else {
final String name = existingEntries.get(0).getPresentableName();
message = "There is already a " + myFrameworkType.getPresentableName() + " library '" + name + "'.\n Do you want to replace it?";
}
final int result = Messages.showYesNoCancelDialog(rootModel.getProject(), message, "Library Already Exists", "&Replace", "&Add", "&Cancel", null);
if (result == Messages.YES) {
for (OrderEntry entry : existingEntries) {
rootModel.removeOrderEntry(entry);
}
} else if (result != Messages.NO) {
return false;
}
}
return true;
}
use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.
the class CloudModuleBuilder method getFrameworkSupportModel.
public FrameworkSupportModelBase getFrameworkSupportModel() {
if (myFrameworkSupportModel == null) {
final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myProject);
myFrameworkSupportModel = new FrameworkSupportModelBase(myProject, this, librariesContainer) {
@NotNull
@Override
public String getBaseDirectoryForLibrariesPath() {
return StringUtil.notNullize(getContentEntryPath());
}
};
}
return myFrameworkSupportModel;
}
use of com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer in project intellij-community by JetBrains.
the class MvcUpgradeAction method removeOldMvcSdk.
public static void removeOldMvcSdk(MvcFramework framework, ModifiableRootModel model) {
final LibraryPresentationManager presentationManager = LibraryPresentationManager.getInstance();
for (OrderEntry entry : model.getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final Library library = ((LibraryOrderEntry) entry).getLibrary();
final LibrariesContainer container = LibrariesContainerFactory.createContainer(model);
if (library != null) {
final VirtualFile[] files = container.getLibraryFiles(library, OrderRootType.CLASSES);
if (presentationManager.isLibraryOfKind(Arrays.asList(files), framework.getLibraryKind())) {
model.removeOrderEntry(entry);
}
}
}
}
}
Aggregations