Search in sources :

Example 1 with ModuleEditor

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;
}
Also used : ArrayList(java.util.ArrayList) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor) Library(com.intellij.openapi.roots.libraries.Library) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 2 with ModuleEditor

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));
    }
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor)

Example 3 with ModuleEditor

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();
    }
}
Also used : ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor)

Example 4 with ModuleEditor

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();
}
Also used : ClonableOrderEntry(com.intellij.openapi.roots.impl.ClonableOrderEntry) ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor)

Example 5 with ModuleEditor

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);
}
Also used : ModuleConfigurationState(com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState) ModulesConfigurator(com.intellij.openapi.roots.ui.configuration.ModulesConfigurator) Module(com.intellij.openapi.module.Module) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor)

Aggregations

ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)8 Module (com.intellij.openapi.module.Module)2 ClonableOrderEntry (com.intellij.openapi.roots.impl.ClonableOrderEntry)2 ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)2 ModuleProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement)2 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 Library (com.intellij.openapi.roots.libraries.Library)1 ClasspathEditor (com.intellij.openapi.roots.ui.configuration.ClasspathEditor)1 ModuleConfigurationState (com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState)1 ActionCallback (com.intellij.openapi.util.ActionCallback)1 Place (com.intellij.ui.navigation.Place)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1