Search in sources :

Example 1 with ModuleProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement 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 2 with ModuleProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement in project intellij-community by JetBrains.

the class ModuleStructureConfigurable method addModuleNode.

private void addModuleNode(final Module module) {
    final TreePath selectionPath = myTree.getSelectionPath();
    MyNode parent = null;
    if (selectionPath != null) {
        MyNode selected = (MyNode) selectionPath.getLastPathComponent();
        final Object o = selected.getConfigurable().getEditableObject();
        if (o instanceof ModuleGroup) {
            myContext.myModulesConfigurator.getModuleModel().setModuleGroupPath(module, ((ModuleGroup) o).getGroupPath());
            parent = selected;
        } else if (o instanceof Module) {
            //create near selected
            final ModifiableModuleModel modifiableModuleModel = myContext.myModulesConfigurator.getModuleModel();
            final String[] groupPath = modifiableModuleModel.getModuleGroupPath((Module) o);
            if (groupPath != null) {
                modifiableModuleModel.setModuleGroupPath(module, groupPath);
                parent = findNodeByObject(myRoot, new ModuleGroup(Arrays.asList(groupPath)));
            }
        }
    }
    if (parent == null)
        parent = myRoot;
    MyNode node = createModuleNode(module, getModuleGrouper());
    TreeUtil.insertNode(node, parent, getTreeModel(), getNodeComparator());
    selectNodeInTree(node);
    final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
    daemonAnalyzer.queueUpdate(new ModuleProjectStructureElement(myContext, module));
    //missing modules added
    daemonAnalyzer.queueUpdateForAllElementsWithErrors();
}
Also used : ProjectStructureDaemonAnalyzer(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer) ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement) ModuleGroup(com.intellij.ide.projectView.impl.ModuleGroup)

Example 3 with ModuleProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement in project intellij-community by JetBrains.

the class ModulesConfigurator method moduleRenamed.

public void moduleRenamed(Module module, final String oldName, final String name) {
    ModuleEditor moduleEditor = myModuleEditors.get(module);
    if (moduleEditor != null) {
        moduleEditor.setModuleName(name);
        moduleEditor.updateCompilerOutputPathChanged(ProjectStructureConfigurable.getInstance(myProject).getProjectConfig().getCompilerOutputUrl(), name);
        myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
    }
}
Also used : ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement)

Example 4 with ModuleProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement in project intellij-community by JetBrains.

the class InlineModuleDependencyAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    OrderEntry selectedEntry = myClasspathPanel.getSelectedEntry();
    if (!(selectedEntry instanceof ModuleOrderEntry))
        return;
    ModuleOrderEntry entryToInline = (ModuleOrderEntry) selectedEntry;
    Module module = entryToInline.getModule();
    if (module == null)
        return;
    ModifiableRootModel model = myClasspathPanel.getRootModel();
    int toInlineIndex = findModuleEntryIndex(model, module);
    if (toInlineIndex == -1)
        return;
    model.removeOrderEntry(entryToInline);
    RootModelImpl modelImpl;
    if (Proxy.isProxyClass(model.getClass())) {
        modelImpl = (RootModelImpl) ((ModuleEditor.ProxyDelegateAccessor) Proxy.getInvocationHandler(model)).getDelegate();
    } else {
        modelImpl = (RootModelImpl) model;
    }
    int addedCount = 0;
    ModuleRootModel otherModel = myClasspathPanel.getModuleConfigurationState().getModulesProvider().getRootModel(module);
    ProjectRootManagerImpl rootManager = ProjectRootManagerImpl.getInstanceImpl(myClasspathPanel.getProject());
    VirtualFilePointerManager virtualFilePointerManager = VirtualFilePointerManager.getInstance();
    for (OrderEntry entry : otherModel.getOrderEntries()) {
        if (entry instanceof LibraryOrderEntry || entry instanceof ModuleOrderEntry) {
            LOG.assertTrue(entry instanceof ClonableOrderEntry, entry);
            ExportableOrderEntry entryToCopy = (ExportableOrderEntry) entry;
            ExportableOrderEntry cloned = (ExportableOrderEntry) ((ClonableOrderEntry) entry).cloneEntry(modelImpl, rootManager, virtualFilePointerManager);
            cloned.setExported(entryToInline.isExported() && entryToCopy.isExported());
            cloned.setScope(OrderEntryUtil.intersectScopes(entryToInline.getScope(), entryToCopy.getScope()));
            model.addOrderEntry(cloned);
            addedCount++;
        }
    }
    OrderEntry[] oldEntries = model.getOrderEntries();
    OrderEntry[] newEntries = new OrderEntry[oldEntries.length];
    System.arraycopy(oldEntries, 0, newEntries, 0, toInlineIndex);
    System.arraycopy(oldEntries, oldEntries.length - addedCount, newEntries, toInlineIndex, addedCount);
    System.arraycopy(oldEntries, toInlineIndex, newEntries, toInlineIndex + addedCount, oldEntries.length - toInlineIndex - addedCount);
    model.rearrangeOrderEntries(newEntries);
    StructureConfigurableContext context = ProjectStructureConfigurable.getInstance(myClasspathPanel.getProject()).getContext();
    context.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(context, module));
}
Also used : RootModelImpl(com.intellij.openapi.roots.impl.RootModelImpl) ProjectRootManagerImpl(com.intellij.openapi.roots.impl.ProjectRootManagerImpl) ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement) ClonableOrderEntry(com.intellij.openapi.roots.impl.ClonableOrderEntry) ClonableOrderEntry(com.intellij.openapi.roots.impl.ClonableOrderEntry) VirtualFilePointerManager(com.intellij.openapi.vfs.pointers.VirtualFilePointerManager) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) Module(com.intellij.openapi.module.Module)

Example 5 with ModuleProjectStructureElement

use of com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement in project intellij-community by JetBrains.

the class SourceItemFindUsagesAction method getSelectedElement.

@Override
protected ProjectStructureElement getSelectedElement() {
    final List<SourceItemNode> nodes = myTree.getSelectedSourceItemNodes();
    if (nodes.size() != 1)
        return null;
    ArtifactsTreeNode node = nodes.get(0);
    if (!(node instanceof SourceItemNode)) {
        return null;
    }
    PackagingSourceItem sourceItem = ((SourceItemNode) node).getSourceItem();
    if (sourceItem == null)
        return null;
    final StructureConfigurableContext context = getContext();
    if (sourceItem instanceof ModuleOutputSourceItem) {
        return new ModuleProjectStructureElement(context, ((ModuleOutputSourceItem) sourceItem).getModule());
    } else if (sourceItem instanceof LibrarySourceItem) {
        return new LibraryProjectStructureElement(context, ((LibrarySourceItem) sourceItem).getLibrary());
    } else if (sourceItem instanceof ArtifactSourceItem) {
        return myArtifactContext.getOrCreateArtifactElement(((ArtifactSourceItem) sourceItem).getArtifact());
    }
    return null;
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) ModuleProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) ArtifactsStructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurableContext) ArtifactsTreeNode(com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)

Aggregations

ModuleProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement)10 StructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext)6 Module (com.intellij.openapi.module.Module)3 ClonableOrderEntry (com.intellij.openapi.roots.impl.ClonableOrderEntry)3 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)2 ModuleGroup (com.intellij.ide.projectView.impl.ModuleGroup)1 Project (com.intellij.openapi.project.Project)1 ProjectRootManagerImpl (com.intellij.openapi.roots.impl.ProjectRootManagerImpl)1 RootModelImpl (com.intellij.openapi.roots.impl.RootModelImpl)1 ArtifactsStructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurableContext)1 ArtifactsTreeNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode)1 ModuleStructureConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable)1 LibraryProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)1 ProjectStructureDaemonAnalyzer (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer)1 VirtualFilePointerManager (com.intellij.openapi.vfs.pointers.VirtualFilePointerManager)1 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 TIntArrayList (gnu.trove.TIntArrayList)1