Search in sources :

Example 6 with ProjectStructureElement

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

the class ChangeLibraryLevelAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final ProjectStructureElement selectedElement = mySourceConfigurable.getSelectedElement();
    if (!(selectedElement instanceof LibraryProjectStructureElement))
        return;
    final StructureConfigurableContext context = mySourceConfigurable.myContext;
    final LibraryProjectStructureElement libraryElement = (LibraryProjectStructureElement) selectedElement;
    final LibraryEx oldLibrary = (LibraryEx) context.getLibrary(libraryElement.getLibrary().getName(), mySourceConfigurable.getLevel());
    LOG.assertTrue(oldLibrary != null);
    final Library newLibrary = doCopy(oldLibrary);
    if (newLibrary == null)
        return;
    final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement);
    for (ProjectStructureElementUsage usage : usages) {
        usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary));
    }
    if (!myCopy) {
        mySourceConfigurable.removeLibrary(libraryElement);
    }
    ProjectStructureConfigurable.getInstance(myProject).selectProjectOrGlobalLibrary(newLibrary, true);
}
Also used : ProjectStructureElementUsage(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Library(com.intellij.openapi.roots.libraries.Library) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)

Example 7 with ProjectStructureElement

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

the class ArtifactsStructureConfigurable method init.

public void init(StructureConfigurableContext context, ModuleStructureConfigurable moduleStructureConfigurable, ProjectLibrariesConfigurable projectLibrariesConfig, GlobalLibrariesConfigurable globalLibrariesConfig) {
    super.init(context);
    myPackagingEditorContext = new ArtifactsStructureConfigurableContextImpl(myContext, myProject, myDefaultSettings, new ArtifactAdapter() {

        @Override
        public void artifactAdded(@NotNull Artifact artifact) {
            final MyNode node = addArtifactNode(artifact);
            selectNodeInTree(node);
            myContext.getDaemonAnalyzer().queueUpdate(myPackagingEditorContext.getOrCreateArtifactElement(artifact));
        }
    });
    context.getModulesConfigurator().addAllModuleChangeListener(new ModuleEditor.ChangeListener() {

        @Override
        public void moduleStateChanged(ModifiableRootModel moduleRootModel) {
            for (ProjectStructureElement element : getProjectStructureElements()) {
                myContext.getDaemonAnalyzer().queueUpdate(element);
            }
        }
    });
    final ItemsChangeListener listener = new ItemsChangeListener() {

        @Override
        public void itemChanged(@Nullable Object deletedItem) {
            if (deletedItem instanceof Library || deletedItem instanceof Module) {
                onElementDeleted();
            }
        }

        @Override
        public void itemsExternallyChanged() {
        }
    };
    moduleStructureConfigurable.addItemsChangeListener(listener);
    projectLibrariesConfig.addItemsChangeListener(listener);
    globalLibrariesConfig.addItemsChangeListener(listener);
    context.addLibraryEditorListener(new LibraryEditorListener() {

        @Override
        public void libraryRenamed(@NotNull Library library, String oldName, String newName) {
            final Artifact[] artifacts = myPackagingEditorContext.getArtifactModel().getArtifacts();
            for (Artifact artifact : artifacts) {
                updateLibraryElements(artifact, library, oldName, newName);
            }
        }
    });
}
Also used : LibraryEditorListener(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) NotNull(org.jetbrains.annotations.NotNull) ModuleEditor(com.intellij.openapi.roots.ui.configuration.ModuleEditor) InvalidArtifact(com.intellij.packaging.impl.artifacts.InvalidArtifact) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with ProjectStructureElement

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

the class ErrorPaneConfigurable method refresh.

public void refresh() {
    myAlarm.cancelAllRequests();
    myAlarm.addRequest(() -> {
        final String header = "<html>" + "<header><style type='text/css'>" + "body {" + "  color: #" + ColorUtil.toHex(new JBColor(Gray.x33, UIUtil.getLabelForeground())) + ";" + "  font-family: '" + UIUtil.getLabelFont().getName() + ",serif';" + "  font-size: " + UIUtil.getLabelFont().getSize() + ";" + "}" + "li {" + "  margin-bottom: 5;" + "}" + "ol {" + "}" + "a {" + " text-decoration: none;" + "}" + "</style>" + "</header>" + "<body>";
        final StringBuilder html = new StringBuilder(header);
        int i = 0;
        html.append("<ol>");
        ConfigurationError[] errors;
        int currentStamp;
        synchronized (myLock) {
            errors = myErrors.toArray(new ConfigurationError[0]);
            currentStamp = myComputedErrorsStamp;
        }
        for (ConfigurationError error : errors) {
            i++;
            if (i > 100)
                break;
            html.append("<li>");
            String description;
            if (error instanceof ProjectConfigurationProblem) {
                //todo[nik] pass ProjectStructureProblemDescription directly and get rid of ConfigurationError at all
                ProjectStructureProblemDescription problemDescription = ((ProjectConfigurationProblem) error).getProblemDescription();
                description = problemDescription.getDescription();
                if (description == null) {
                    ProjectStructureElement place = problemDescription.getPlace().getContainingElement();
                    description = XmlStringUtil.convertToHtmlContent(problemDescription.getMessage(false));
                    if (problemDescription.canShowPlace()) {
                        description = place.getTypeName() + " <a href='http://navigate/" + i + "'>" + XmlStringUtil.convertToHtmlContent(place.getPresentableName()) + "</a>: " + StringUtil.decapitalize(description);
                    }
                } else {
                    description = XmlStringUtil.convertToHtmlContent(description);
                }
            } else {
                description = XmlStringUtil.convertToHtmlContent(error.getDescription());
            }
            if (error.canBeFixed()) {
                description += " <a href='http://fix/" + i + "'>[Fix]</a>";
            }
            html.append(description).append("</li>");
        }
        html.append("</ol></body></html>");
        myContentUpdateQueue.queue(new ShowErrorsUpdate(currentStamp, html.toString()));
        if (myOnErrorsChanged != null) {
            myOnErrorsChanged.run();
        }
    }, 100);
}
Also used : ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) ProjectConfigurationProblem(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem) ProjectStructureProblemDescription(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

ProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement)8 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)2 Library (com.intellij.openapi.roots.libraries.Library)2 LibraryProjectStructureElement (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)2 ProjectStructureElementUsage (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 Module (com.intellij.openapi.module.Module)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)1 LibraryEditorListener (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditorListener)1 ProjectConfigurationProblem (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem)1 ProjectStructureDaemonAnalyzer (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer)1 ProjectStructureDaemonAnalyzerListener (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzerListener)1 ProjectStructureProblemDescription (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription)1 ProjectStructureProblemsHolderImpl (com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemsHolderImpl)1 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)1 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1 InvalidArtifact (com.intellij.packaging.impl.artifacts.InvalidArtifact)1 JBColor (com.intellij.ui.JBColor)1