mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
suggest to add a library only to allowed modules
This commit is contained in:
+1
-1
@@ -116,7 +116,7 @@ class AddNewLibraryItemAction extends ChooseAndAddAction<Library> {
|
||||
suitableTypes.add(null);
|
||||
final ModuleType moduleType = classpathPanel.getRootModel().getModule().getModuleType();
|
||||
for (LibraryType libraryType : LibraryType.EP_NAME.getExtensions()) {
|
||||
if (libraryType.isSuitableForModuleType(moduleType)) {
|
||||
if (libraryType.isSuitableModuleType(moduleType)) {
|
||||
suitableTypes.add(libraryType);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -31,7 +31,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiab
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.util.Icons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -79,7 +78,11 @@ public class CreateNewLibraryAction extends AnAction {
|
||||
|
||||
private void appendLibraryToModules(final ModuleStructureConfigurable rootConfigurable, final Library libraryToSelect) {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
ContainerUtil.addAll(modules, rootConfigurable.getModules());
|
||||
for (Module module : rootConfigurable.getModules()) {
|
||||
if (myType == null || myType.isSuitableModuleType(module.getModuleType())) {
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
if (modules.isEmpty()) return;
|
||||
final ChooseModulesDialog dlg = new ChooseModulesDialog(myProject,
|
||||
modules, ProjectBundle.message("choose.modules.dialog.title"),
|
||||
|
||||
@@ -51,7 +51,10 @@ public abstract class LibraryType<P extends LibraryProperties> extends LibraryPr
|
||||
@NotNull
|
||||
public abstract P createDefaultProperties();
|
||||
|
||||
public boolean isSuitableForModuleType(@NotNull ModuleType moduleType) {
|
||||
/**
|
||||
* @return {@code true} if library of this type can be added as a dependency to a module of type {@code moduleType}
|
||||
*/
|
||||
public boolean isSuitableModuleType(@NotNull ModuleType moduleType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user