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);
}
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);
}
}
});
}
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);
}
Aggregations