use of com.intellij.facet.ModifiableFacetModel in project intellij-community by JetBrains.
the class PythonFrameworkSupportConfigurable method addSupport.
public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @Nullable Library library) {
final FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
PythonFacet facet = facetManager.createFacet(PythonFacetType.getInstance(), "Python", null);
facet.getConfiguration().setSdk(mySdkComboBox.getSelectedSdk());
facetModel.addFacet(facet);
facetModel.commit();
}
use of com.intellij.facet.ModifiableFacetModel in project intellij-community by JetBrains.
the class MvcModuleStructureUtil method updateModuleStructure.
public static void updateModuleStructure(final Module module, MvcProjectStructure structure, @NotNull VirtualFile root) {
final Pair<Collection<Consumer<ModifiableRootModel>>, Collection<Consumer<ModifiableFacetModel>>> actions = getUpdateProjectStructureActions(Collections.singletonList(root), structure);
// update module
if (!actions.first.isEmpty()) {
ModuleRootModificationUtil.updateModel(module, model -> {
for (final Consumer<ModifiableRootModel> action : actions.first) {
action.consume(model);
}
});
}
// update facets
if (!actions.second.isEmpty()) {
final Application application = ApplicationManager.getApplication();
final ModifiableFacetModel model = application.runReadAction(new Computable<ModifiableFacetModel>() {
@Override
public ModifiableFacetModel compute() {
return FacetManager.getInstance(module).createModifiableModel();
}
});
for (Consumer<ModifiableFacetModel> action : actions.second) {
action.consume(model);
}
application.invokeAndWait(() -> application.runWriteAction(() -> model.commit()));
}
}
use of com.intellij.facet.ModifiableFacetModel in project intellij-community by JetBrains.
the class BuildoutFacetConfigurator method setupFacet.
static void setupFacet(Module module, @NotNull BuildoutFacetConfiguration config) {
//TODO: refactor, see other python facets
FacetManager facetManager = FacetManager.getInstance(module);
final ModifiableFacetModel model = facetManager.createModifiableModel();
BuildoutFacetType facetType = BuildoutFacetType.getInstance();
BuildoutFacet facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), config, null);
model.addFacet(facet);
new WriteAction() {
protected void run(@NotNull final Result result) throws Throwable {
model.commit();
}
}.execute();
facet.updatePaths();
BuildoutFacet.attachLibrary(module);
}
use of com.intellij.facet.ModifiableFacetModel in project kotlin by JetBrains.
the class KotlinAndroidTestCase method addAndroidFacet.
public AndroidFacet addAndroidFacet(Module module, String sdkPath, String platformDir, boolean addSdk) {
FacetManager facetManager = FacetManager.getInstance(module);
AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
if (addSdk) {
addAndroidSdk(module, sdkPath, platformDir);
}
final ModifiableFacetModel facetModel = facetManager.createModifiableModel();
facetModel.addFacet(facet);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
facetModel.commit();
}
});
return facet;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class NdkModuleModelDataService method onModelsNotFound.
@Override
protected void onModelsNotFound(@NotNull IdeModifiableModelsProvider modelsProvider) {
// See https://code.google.com/p/android/issues/detail?id=229806
for (Module module : modelsProvider.getModules()) {
ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(module);
removeAllFacets(facetModel, NdkFacet.getFacetTypeId());
}
}
Aggregations