use of com.intellij.openapi.roots.ui.configuration.ModuleEditor in project intellij-community by JetBrains.
the class ModuleProjectStructureElement method getUsagesInElement.
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
final List<ProjectStructureElementUsage> usages = new ArrayList<>();
final ModuleEditor moduleEditor = myContext.getModulesConfigurator().getModuleEditor(myModule);
if (moduleEditor != null) {
for (OrderEntry entry : moduleEditor.getOrderEntries()) {
if (entry instanceof ModuleOrderEntry) {
ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry) entry;
final Module module = moduleOrderEntry.getModule();
if (module != null) {
usages.add(new UsageInModuleClasspath(myContext, this, new ModuleProjectStructureElement(myContext, module), moduleOrderEntry.getScope()));
}
} else if (entry instanceof LibraryOrderEntry) {
LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry;
final Library library = libraryOrderEntry.getLibrary();
if (library != null) {
usages.add(new UsageInModuleClasspath(myContext, this, new LibraryProjectStructureElement(myContext, library), libraryOrderEntry.getScope()));
}
} else if (entry instanceof JdkOrderEntry) {
final Sdk jdk = ((JdkOrderEntry) entry).getJdk();
if (jdk != null) {
usages.add(new UsageInModuleClasspath(myContext, this, new SdkProjectStructureElement(myContext, jdk), null));
}
}
}
}
return usages;
}
use of com.intellij.openapi.roots.ui.configuration.ModuleEditor in project intellij-community by JetBrains.
the class UsageInModuleClasspath method replaceElement.
@Override
public void replaceElement(final ProjectStructureElement newElement) {
final ModuleEditor editor = myContext.getModulesConfigurator().getModuleEditor(myModule);
if (editor != null) {
final ModifiableRootModel rootModel = editor.getModifiableRootModelProxy();
OrderEntryUtil.replaceLibrary(rootModel, ((LibraryProjectStructureElement) mySourceElement).getLibrary(), ((LibraryProjectStructureElement) newElement).getLibrary());
myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, myModule));
}
}
use of com.intellij.openapi.roots.ui.configuration.ModuleEditor in project intellij-community by JetBrains.
the class ModuleStructureConfigurable method updateModuleEditorSelection.
private void updateModuleEditorSelection(final NamedConfigurable configurable) {
if (configurable instanceof ModuleConfigurable) {
final ModuleConfigurable moduleConfigurable = (ModuleConfigurable) configurable;
final ModuleEditor editor = moduleConfigurable.getModuleEditor();
if (editor != null) {
//already deleted
editor.init(myHistory);
}
}
if (configurable instanceof FacetConfigurable) {
((FacetConfigurable) configurable).getEditor().onFacetSelected();
}
}
use of com.intellij.openapi.roots.ui.configuration.ModuleEditor in project intellij-community by JetBrains.
the class ModuleStructureConfigurable method addLibraryOrderEntry.
public void addLibraryOrderEntry(final Module module, final Library library) {
final ModuleEditor moduleEditor = myContext.myModulesConfigurator.getModuleEditor(module);
LOG.assertTrue(moduleEditor != null, "Current module editor was not initialized");
final ModifiableRootModel modelProxy = moduleEditor.getModifiableRootModelProxy();
final OrderEntry[] entries = modelProxy.getOrderEntries();
for (OrderEntry entry : entries) {
if (entry instanceof LibraryOrderEntry && Comparing.strEqual(entry.getPresentableName(), library.getName())) {
if (Messages.showYesNoDialog(module.getProject(), ProjectBundle.message("project.roots.replace.library.entry.message", entry.getPresentableName()), ProjectBundle.message("project.roots.replace.library.entry.title"), Messages.getInformationIcon()) == Messages.YES) {
modelProxy.removeOrderEntry(entry);
break;
}
}
}
modelProxy.addLibraryEntry(library);
myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
myTree.repaint();
}
use of com.intellij.openapi.roots.ui.configuration.ModuleEditor in project intellij-community by JetBrains.
the class ProjectFacetsConfigurator method createContext.
protected FacetEditorContext createContext(@NotNull final Facet facet, @Nullable final FacetEditorContext parentContext) {
Module module = facet.getModule();
ModulesConfigurator modulesConfigurator = myContext.getModulesConfigurator();
ModuleEditor moduleEditor = modulesConfigurator.getModuleEditor(module);
if (moduleEditor == null) {
LOG.error("ModuleEditor[" + module.getName() + "]==null: disposed = " + module.isDisposed() + ", is in model = " + Arrays.asList(modulesConfigurator.getModules()).contains(module));
}
final ModuleConfigurationState state = moduleEditor.createModuleConfigurationState();
return new MyProjectConfigurableContext(facet, parentContext, state);
}
Aggregations