use of com.intellij.facet.impl.ProjectFacetsConfigurator in project intellij-community by JetBrains.
the class AddFrameworkSupportInProjectStructureAction method isVisible.
private boolean isVisible() {
final Module module = getSelectedModule();
if (module == null || !myProvider.isEnabledForModuleType(ModuleType.get(module))) {
return false;
}
final ProjectFacetsConfigurator facetsProvider = myModuleStructureConfigurable.getFacetConfigurator();
if (!myProvider.canAddSupport(module, facetsProvider)) {
return false;
}
final String underlyingFrameworkTypeId = myFrameworkType.getUnderlyingFrameworkTypeId();
if (underlyingFrameworkTypeId == null)
return true;
final FrameworkSupportInModuleProvider underlyingProvider = FrameworkSupportUtil.findProvider(underlyingFrameworkTypeId, FrameworkSupportUtil.getAllProviders());
if (underlyingProvider == null) {
LOG.error("framework not found by id " + underlyingFrameworkTypeId);
}
return underlyingProvider.isSupportAlreadyAdded(module, facetsProvider);
}
use of com.intellij.facet.impl.ProjectFacetsConfigurator in project intellij-community by JetBrains.
the class AddFacetOfTypeAction method addFacetToModule.
private void addFacetToModule(@NotNull FacetType type) {
final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator();
List<Module> suitableModules = new ArrayList<>(Arrays.asList(myContext.getModules()));
final Iterator<Module> iterator = suitableModules.iterator();
while (iterator.hasNext()) {
Module module = iterator.next();
if (!type.isSuitableModuleType(ModuleType.get(module)) || (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(module, null, type.getId()))) {
iterator.remove();
}
}
final Project project = myContext.getProject();
if (suitableModules.isEmpty()) {
Messages.showErrorDialog(project, "No suitable modules for " + type.getPresentableName() + " facet found.", "Cannot Create Facet");
return;
}
final ChooseModulesDialog dialog = new ChooseModulesDialog(project, suitableModules, "Choose Module", type.getPresentableName() + " facet will be added to selected module");
dialog.setSingleSelectionMode();
dialog.show();
final List<Module> elements = dialog.getChosenElements();
if (!dialog.isOK() || elements.size() != 1)
return;
final Module module = elements.get(0);
final Facet facet = ModuleStructureConfigurable.getInstance(project).getFacetEditorFacade().createAndAddFacet(type, module, null);
ProjectStructureConfigurable.getInstance(project).select(facet, true);
}
use of com.intellij.facet.impl.ProjectFacetsConfigurator in project intellij-community by JetBrains.
the class AddFacetOfTypeAction method addSubFacet.
private void addSubFacet(FacetType type, FacetTypeId<?> underlyingType) {
final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator();
List<Facet> suitableParents = new ArrayList<>();
for (Module module : myContext.getModules()) {
if (type.isSuitableModuleType(ModuleType.get(module))) {
suitableParents.addAll(facetsConfigurator.getFacetsByType(module, underlyingType));
}
}
final Iterator<Facet> iterator = suitableParents.iterator();
while (iterator.hasNext()) {
Facet parent = iterator.next();
if (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(parent.getModule(), parent, type.getId())) {
iterator.remove();
}
}
final Project project = myContext.getProject();
if (suitableParents.isEmpty()) {
final String parentType = FacetTypeRegistry.getInstance().findFacetType(underlyingType).getPresentableName();
Messages.showErrorDialog(project, "No suitable parent " + parentType + " facets found", "Cannot Create " + type.getPresentableName() + " Facet");
return;
}
ChooseParentFacetDialog dialog = new ChooseParentFacetDialog(project, suitableParents);
dialog.show();
final List<Facet> chosen = dialog.getChosenElements();
if (!dialog.isOK() || chosen.size() != 1)
return;
final Facet parent = chosen.get(0);
final Facet facet = ModuleStructureConfigurable.getInstance(project).getFacetEditorFacade().createAndAddFacet(type, parent.getModule(), parent);
ProjectStructureConfigurable.getInstance(project).select(facet, true);
}
use of com.intellij.facet.impl.ProjectFacetsConfigurator in project intellij-community by JetBrains.
the class FacetTypeEditor method createAllFacetsEditor.
@Nullable
private MultipleFacetSettingsEditor createAllFacetsEditor() {
ProjectFacetsConfigurator facetsConfigurator = myContext.myModulesConfigurator.getFacetsConfigurator();
List<Facet> facets = new ArrayList<>();
for (Module module : myContext.getModules()) {
facets.addAll(facetsConfigurator.getFacetsByType(module, myFacetType.getId()));
}
if (!facets.isEmpty()) {
final FacetEditor[] editors = new FacetEditor[facets.size()];
for (int i = 0; i < facets.size(); i++) {
editors[i] = facetsConfigurator.getOrCreateEditor(facets.get(i));
}
return myFacetType.createMultipleConfigurationsEditor(myProject, editors);
}
return null;
}
Aggregations