Java Code Examples for com.intellij.facet.ModifiableFacetModel#commit()
The following examples show how to use
com.intellij.facet.ModifiableFacetModel#commit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidFacetModuleCustomizer.java From intellij with Apache License 2.0 | 6 votes |
public static void createAndroidFacet(Module module, boolean isApp) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { configureFacet(facet, isApp); } else { // Module does not have Android facet. Create one and add it. FacetManager facetManager = FacetManager.getInstance(module); ModifiableFacetModel model = facetManager.createModifiableModel(); try { facet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null); model.addFacet(facet); configureFacet(facet, isApp); } finally { model.commit(); } } }
Example 2
Source File: BlazeKotlinSyncPlugin.java From intellij with Apache License 2.0 | 6 votes |
private static KotlinFacet getOrCreateKotlinFacet(Module module) { KotlinFacet facet = KotlinFacet.Companion.get(module); if (facet != null) { return facet; } FacetManager facetManager = FacetManager.getInstance(module); ModifiableFacetModel model = facetManager.createModifiableModel(); try { facet = facetManager.createFacet( KotlinFacetType.Companion.getINSTANCE(), KotlinFacetType.NAME, null); model.addFacet(facet); } finally { model.commit(); } return facet; }
Example 3
Source File: MuleMavenModuleBuilder.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
public void setMuleFacet(Module module) { MuleFacetType type = (MuleFacetType)FacetTypeRegistry.getInstance().findFacetType(MuleFacet.ID); MuleFacetConfiguration configuration = type.createDefaultConfiguration(); configuration.setPathToSdk(MuleSdkManager.getInstance().findFromVersion(muleVersion).getMuleHome()); Facet facet = type.createFacet(module, type.getPresentableName(), configuration, null); ModifiableFacetModel model = FacetManager.getInstance(module).createModifiableModel(); model.addFacet(facet); model.commit(); }
Example 4
Source File: AndroidFacetModuleCustomizer.java From intellij with Apache License 2.0 | 5 votes |
public static void removeAndroidFacet(Module module) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { ModifiableFacetModel facetModel = FacetManager.getInstance(module).createModifiableModel(); facetModel.removeFacet(facet); facetModel.commit(); } }
Example 5
Source File: BlazePythonSyncPlugin.java From intellij with Apache License 2.0 | 5 votes |
private static void removeFacet(Module workspaceModule) { FacetManager manager = FacetManager.getInstance(workspaceModule); ModifiableFacetModel facetModel = manager.createModifiableModel(); LibraryContributingFacet<?> facet = manager.findFacet(PythonFacetUtil.getFacetId(), "Python"); if (facet != null) { facetModel.removeFacet(facet); facetModel.commit(); } }
Example 6
Source File: DWFrameworkSupportConfigurable.java From intellij-demandware with MIT License | 5 votes |
@Override public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel, @Nullable Library library) { final FacetManager facetManager = FacetManager.getInstance(module); ModifiableFacetModel facetModel = facetManager.createModifiableModel(); DWSettingsProvider dwSettingsProvider = ModuleServiceManager.getService(module, DWSettingsProvider.class); dwSettingsProvider.setPasswordKey(UUID.randomUUID().toString()); dwSettingsProvider.setHostname(dwFrameworkSupportConfigurablePanel.getHostname()); dwSettingsProvider.setUsername(dwFrameworkSupportConfigurablePanel.getUsername()); dwSettingsProvider.setPassword(dwFrameworkSupportConfigurablePanel.getPassword()); dwSettingsProvider.setVersion(dwFrameworkSupportConfigurablePanel.getVersion()); dwSettingsProvider.setAutoUploadEnabled(dwFrameworkSupportConfigurablePanel.getAutoUploadEnabled()); Facet facet = FacetManager.getInstance(modifiableRootModel.getModule()).addFacet(DWFacetType.INSTANCE, "Demandware", null); facetModel.addFacet(facet); facetModel.commit(); }
Example 7
Source File: BlazePythonSyncPlugin.java From intellij with Apache License 2.0 | 4 votes |
@Nullable private static LibraryContributingFacet<?> getOrCreatePythonFacet( Project project, BlazeContext context, Module module, BlazeProjectData blazeProjectData) { LibraryContributingFacet<?> facet = findPythonFacet(module); if (facet != null && isValidPythonSdk(PythonFacetUtil.getSdk(facet))) { return facet; } FacetManager manager = FacetManager.getInstance(module); ModifiableFacetModel facetModel = manager.createModifiableModel(); if (facet != null) { // we can't modify in place, IntelliJ has no hook to trigger change events. Instead we create // a new facet. facetModel.removeFacet(facet); } Sdk sdk = getPythonSdk(project, blazeProjectData, context); if (sdk == null) { String fixDirections = "Configure a suitable Python Interpreter for the module \"" + module.getName() + "\" via File->\"Project Structure...\", \"Project Settings\"->\"Facets\", then" + " sync the project again."; if (PlatformUtils.isCLion()) { fixDirections = "Configure a suitable Python Interpreter for the module \"" + module.getName() + "\" via File->\"Settings...\", \"Build," + " Execution, Deployment\"->\"Python Interpreter\", then sync the project again."; } String msg = "Unable to find a compatible Python SDK installed.\n" + fixDirections; IssueOutput.error(msg).submit(context); return null; } facet = manager.createFacet(PythonFacetUtil.getFacetType(), "Python", null); // This is ugly like this to get around PythonFacet related classes being in different package // paths in different IDEs. Thankfully, PythonFacetSettings is in the same packackage path. if (facet.getConfiguration() instanceof PythonFacetSettings) { ((PythonFacetSettings) facet.getConfiguration()).setSdk(sdk); } facetModel.addFacet(facet); facetModel.commit(); return facet; }