Search in sources :

Example 1 with StructureConfigurableContext

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

the class ExternalModuleStructureExtension method getModulesConfigurator.

@Nullable
private static ModulesConfigurator getModulesConfigurator(Project project) {
    if (ApplicationManager.getApplication().isHeadlessEnvironment())
        return null;
    final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(project);
    StructureConfigurableContext context = structureConfigurable.isUiInitialized() ? structureConfigurable.getContext() : null;
    return context != null ? context.getModulesConfigurator() : null;
}
Also used : StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with StructureConfigurableContext

use of com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext 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 3 with StructureConfigurableContext

use of com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext 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)

Example 4 with StructureConfigurableContext

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

the class ClasspathPanelImpl method initPopupActions.

private void initPopupActions() {
    if (myPopupActions == null) {
        int actionIndex = 1;
        final List<AddItemPopupAction<?>> actions = new ArrayList<>();
        final StructureConfigurableContext context = getStructureConfigurableContext();
        actions.add(new AddNewModuleLibraryAction(this, actionIndex++, context));
        actions.add(new AddLibraryDependencyAction(this, actionIndex++, ProjectBundle.message("classpath.add.library.action"), context));
        actions.add(new AddModuleDependencyAction(this, actionIndex, context));
        myPopupActions = actions;
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 5 with StructureConfigurableContext

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

the class AddNewLibraryDependencyAction method chooseTypeAndCreate.

public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel, final StructureConfigurableContext context, final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
    if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
        final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, libraryType -> doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType)));
        popup.showUnderneathOf(contextButton);
    } else {
        doCreateLibrary(classpathPanel, context, callback, contextButton, null);
    }
}
Also used : Library(com.intellij.openapi.roots.libraries.Library) ListPopup(com.intellij.openapi.ui.popup.ListPopup) Nullable(org.jetbrains.annotations.Nullable) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryEditingUtil(com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryType(com.intellij.openapi.roots.libraries.LibraryType) NotNull(org.jetbrains.annotations.NotNull) ParameterizedRunnable(com.intellij.util.ParameterizedRunnable) javax.swing(javax.swing) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Aggregations

StructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext)12 ModuleProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement)6 Module (com.intellij.openapi.module.Module)3 Nullable (org.jetbrains.annotations.Nullable)3 Project (com.intellij.openapi.project.Project)2 Library (com.intellij.openapi.roots.libraries.Library)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 TIntArrayList (gnu.trove.TIntArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 ClonableOrderEntry (com.intellij.openapi.roots.impl.ClonableOrderEntry)1 ProjectRootManagerImpl (com.intellij.openapi.roots.impl.ProjectRootManagerImpl)1 RootModelImpl (com.intellij.openapi.roots.impl.RootModelImpl)1 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)1 LibraryType (com.intellij.openapi.roots.libraries.LibraryType)1 LibraryTableModifiableModelProvider (com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider)1 ProjectStructureConfigurable (com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)1 ArtifactsStructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurableContext)1 ArtifactsTreeNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ArtifactsTreeNode)1