use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class ModuleFactory method createModule.
@NotNull
Module createModule(@NotNull IdeaModule ideaModule, @NotNull SyncAction.ModuleModels moduleModels) {
File imlFilePath = getModuleImlFilePath(ideaModule, moduleModels);
Module newModule = myModelsProvider.newModule(imlFilePath.getPath(), StdModuleTypes.JAVA.getId());
ModifiableRootModel rootModel = myModelsProvider.getModifiableRootModel(newModule);
rootModel.inheritSdk();
// Remove all dependencies.
DependencyRemover dependencyRemover = new DependencyRemover(rootModel);
for (OrderEntry orderEntry : rootModel.getOrderEntries()) {
orderEntry.accept(dependencyRemover, null);
}
// Remove all facets.
ModifiableFacetModel facetModel = myModelsProvider.getModifiableFacetModel(newModule);
for (Facet facet : facetModel.getAllFacets()) {
facetModel.removeFacet(facet);
}
return newModule;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class AndroidUtils method addAndroidFacet.
@NotNull
public static AndroidFacet addAndroidFacet(final Module module, @NotNull VirtualFile contentRoot, boolean library) {
final FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel model = facetManager.createModifiableModel();
AndroidFacet facet = model.getFacetByType(AndroidFacet.ID);
if (facet == null) {
facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
AndroidFacetConfiguration configuration = facet.getConfiguration();
configuration.init(module, contentRoot);
if (library) {
facet.setProjectType(PROJECT_TYPE_LIBRARY);
}
model.addFacet(facet);
}
model.commit();
return facet;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class JavaFacetModuleSetupStep method gradleModelNotFound.
@Override
protected void gradleModelNotFound(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
ModifiableFacetModel facetModel = ideModelsProvider.getModifiableFacetModel(module);
removeAllFacets(facetModel, JavaFacet.getFacetTypeId());
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class NdkFacetModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull NdkModuleModel ndkModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
NdkFacet facet = findFacet(module, ideModelsProvider, NdkFacet.getFacetTypeId());
if (facet != null) {
configureFacet(facet, ndkModuleModel);
} else {
// Module does not have Native Android facet. Create one and add it.
ModifiableFacetModel model = ideModelsProvider.getModifiableFacetModel(module);
NdkFacetType facetType = NdkFacet.getFacetType();
facet = facetType.createFacet(module, NdkFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
model.addFacet(facet);
configureFacet(facet, ndkModuleModel);
}
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class ProjectSetupImplTest method simulateAndroidFacetLookup.
private void simulateAndroidFacetLookup(@NotNull Module module, @Nullable AndroidFacet facetToFind) {
ModifiableFacetModel facetModel = mock(ModifiableFacetModel.class);
when(myModelsProvider.getModifiableFacetModel(module)).thenReturn(facetModel);
when(facetModel.getFacetByType(AndroidFacet.ID)).thenReturn(facetToFind);
}
Aggregations