use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-community by JetBrains.
the class ExternalModuleStructureExtension method disposeUIResources.
@Override
public void disposeUIResources() {
try {
if (isExternalSystemsInvolved) {
assert myOrphanProjectsCandidates != null;
assert myProject != null;
if (myExternalProjectsToRestore != null) {
for (Pair<ProjectSystemId, ExternalProjectSettings> settingsPair : myExternalProjectsToRestore.values()) {
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(myProject, settingsPair.first);
String rootProjectPath = settingsPair.second.getExternalProjectPath();
if (settings.getLinkedProjectSettings(rootProjectPath) == null) {
//noinspection unchecked
settings.linkProject(settingsPair.second);
}
myOrphanProjectsCandidates.remove(rootProjectPath);
}
}
ModulesConfigurator modulesConfigurator = getModulesConfigurator(myProject);
if (modulesConfigurator != null) {
for (Map.Entry<String, ProjectSystemId> entry : myOrphanProjectsCandidates.entrySet()) {
String rootProjectPath = entry.getKey();
if (StringUtil.isNotEmpty(rootProjectPath)) {
unlinkProject(myProject, entry.getValue(), rootProjectPath);
}
}
}
}
} catch (Throwable e) {
LOG.warn(e);
} finally {
myProject = null;
myExternalProjectsToRestore = null;
myOrphanProjectsCandidates = null;
}
}
use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method checkDependencies.
private void checkDependencies(final ProjectStructureProblemsHolder problemsHolder, final FlexProjectConfigurationEditor editor) {
final ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
for (DependencyEntry entry : myBc.getDependencies().getEntries()) {
if (entry instanceof BuildConfigurationEntry) {
final String moduleName = ((BuildConfigurationEntry) entry).getModuleName();
final String bcName = ((BuildConfigurationEntry) entry).getBcName();
final Module module = modulesConfigurator.getModule(moduleName);
String errorMessage = null;
if (module == null) {
errorMessage = FlexBundle.message("bc.problem.dependency.module.not.found", moduleName);
} else if (ContainerUtil.find(editor.getConfigurations(module), configuration -> bcName.equals(configuration.getName())) == null) {
errorMessage = FlexBundle.message("bc.problem.dependency.bc.not.found", bcName, moduleName);
}
if (errorMessage != null) {
Object location = DependenciesConfigurable.Location.TableEntry.forBc(moduleName, bcName);
PlaceInProjectStructure place = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
problemsHolder.registerProblem(errorMessage, null, ProjectStructureProblemType.error("flex-bc-dependency-bc"), place, null);
}
}
}
}
use of com.intellij.openapi.roots.ui.configuration.ModulesConfigurator in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method getUsagesInElement.
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
FlexBCConfigurator configurator = FlexBuildConfigurationsExtension.getInstance().getConfigurator();
final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
assert editor != null;
final ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
final List<ProjectStructureElementUsage> usages = new ArrayList<>();
for (DependencyEntry dependencyEntry : myBc.getDependencies().getEntries()) {
if (dependencyEntry instanceof SharedLibraryEntry) {
String libraryName = ((SharedLibraryEntry) dependencyEntry).getLibraryName();
String libraryLevel = ((SharedLibraryEntry) dependencyEntry).getLibraryLevel();
final Library library = myContext.getLibrary(libraryName, libraryLevel);
if (library != null) {
usages.add(new UsageInBcDependencies(this, new LibraryProjectStructureElement(myContext, library)) {
@Override
public void removeSourceElement() {
libraryReplaced(library, null);
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
libraryReplaced(library, ((LibraryProjectStructureElement) newElement).getLibrary());
}
});
}
} else if (dependencyEntry instanceof BuildConfigurationEntry) {
final BuildConfigurationEntry bcEntry = (BuildConfigurationEntry) dependencyEntry;
Module module = modulesConfigurator.getModule(bcEntry.getModuleName());
if (module != null) {
final ModifiableFlexBuildConfiguration bc = ContainerUtil.find(editor.getConfigurations(module), configuration -> bcEntry.getBcName().equals(configuration.getName()));
if (bc != null) {
usages.add(new UsageInBcDependencies(this, new BuildConfigurationProjectStructureElement(bc, module, myContext)) {
@Override
public void removeSourceElement() {
// ignore as editor already listens to BC removal
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
throw new UnsupportedOperationException();
}
});
}
}
bcEntry.findBuildConfiguration();
}
}
Sdk sdk = myBc.getSdk();
if (sdk != null) {
usages.add(new UsageInBcDependencies(this, new SdkProjectStructureElement(myContext, sdk)) {
@Override
public void removeSourceElement() {
myBc.getDependencies().setSdkEntry(null);
}
@Override
public void replaceElement(final ProjectStructureElement newElement) {
throw new UnsupportedOperationException();
}
});
}
return usages;
}
Aggregations