mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
'Problems' view in 'Project Structure': properly extract navigatable part from error message to show hyperlinks not only for module names but for libraries and artifacts as well
This commit is contained in:
+18
-9
@@ -20,6 +20,9 @@ import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectConfigurationProblem;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemDescription;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
@@ -28,6 +31,7 @@ import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -156,16 +160,21 @@ public class ErrorPaneConfigurable extends JPanel implements Configurable, Dispo
|
||||
i++;
|
||||
if (i > 100) break;
|
||||
html.append("<li>");
|
||||
String description = error.getDescription();
|
||||
if (description.startsWith("<html>") && description.endsWith("</html>")) {
|
||||
description = description.substring(6, description.length() - 7);
|
||||
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 = place.getTypeName() + " <a href='http://navigate/" + i + "'>" + place.getPresentableName() + "</a>: " + problemDescription.getMessage(false);
|
||||
}
|
||||
else {
|
||||
description = XmlStringUtil.stripHtml(description);
|
||||
}
|
||||
}
|
||||
if (description.startsWith("Module '")) {
|
||||
final int start = 8;
|
||||
final int end = description.indexOf("'", 9);
|
||||
final String moduleName = description.substring(start, end);
|
||||
description = "Module <a href='http://module/" + StringUtil.escapeXml(moduleName) + "'>" + StringUtil.escapeXml(moduleName) + "</a> " + description.substring(
|
||||
end + 1);
|
||||
else {
|
||||
description = XmlStringUtil.stripHtml(error.getDescription());
|
||||
}
|
||||
if (error.canBeFixed()) {
|
||||
description += " <a href='http://fix/" + i + "'>[Fix]</a>";
|
||||
|
||||
+6
-1
@@ -48,10 +48,15 @@ public class GeneralProjectSettingsElement extends ProjectStructureElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
public String getPresentableText() {
|
||||
return "Project";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return ProjectStructureConfigurable.getInstance(myContext.getProject()).getProjectConfig().getProjectName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Project";
|
||||
|
||||
+8
-4
@@ -52,6 +52,7 @@ import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.ui.InsertPathAction;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -252,7 +253,7 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
myProjectJdkConfigurable.apply();
|
||||
|
||||
if (myProjectName != null) {
|
||||
((ProjectEx)myProject).setProjectName(myProjectName.getText().trim());
|
||||
((ProjectEx)myProject).setProjectName(getProjectName());
|
||||
if (myDetailsComponent != null) myDetailsComponent.setText(getBannerSlogan());
|
||||
}
|
||||
}
|
||||
@@ -305,13 +306,16 @@ public class ProjectConfigurable extends ProjectStructureElementConfigurable<Pro
|
||||
if (!Comparing.strEqual(FileUtil.toSystemIndependentName(VfsUtilCore.urlToPath(compilerOutput)),
|
||||
FileUtil.toSystemIndependentName(myProjectCompilerOutput.getText()))) return true;
|
||||
if (myProjectJdkConfigurable.isModified()) return true;
|
||||
if (myProjectName != null) {
|
||||
if (!myProjectName.getText().trim().equals(myProject.getName())) return true;
|
||||
}
|
||||
if (!getProjectName().equals(myProject.getName())) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getProjectName() {
|
||||
return myProjectName != null ? myProjectName.getText().trim() : myProject.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getOriginalCompilerOutputUrl() {
|
||||
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class ArtifactProjectStructureElement extends ProjectStructureElement {
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "Artifact '" + getActualArtifactName() + "'";
|
||||
return getActualArtifactName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
|
||||
sb.append(usagesOfType.size()).append(" ").append(StringUtil.decapitalize(StringUtil.pluralize(type)));
|
||||
}
|
||||
else {
|
||||
sb.append(StringUtil.decapitalize(usagesOfType.iterator().next().getContainingElement().getPresentableName()));
|
||||
sb.append(StringUtil.decapitalize(usagesOfType.iterator().next().getContainingElement().getPresentableText()));
|
||||
}
|
||||
}
|
||||
firstLibraryWithUsageName = library.getName();
|
||||
|
||||
+6
-1
@@ -44,10 +44,15 @@ public class FacetProjectStructureElement extends ProjectStructureElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
public String getPresentableText() {
|
||||
return "Facet '" + myFacet.getName() + "' in module '" + myFacet.getModule().getName() + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return myFacet.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "Facet";
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "Library '" + myLibrary.getName() + "'";
|
||||
return myLibrary.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ public class ModuleProjectStructureElement extends ProjectStructureElement {
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "Module '" + myModule.getName() + "'";
|
||||
return myModule.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-1
@@ -26,7 +26,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class ProjectConfigurationProblem extends ConfigurationError {
|
||||
public class ProjectConfigurationProblem extends ConfigurationError {
|
||||
private final ProjectStructureProblemDescription myDescription;
|
||||
private final Project myProject;
|
||||
|
||||
@@ -51,6 +51,11 @@ class ProjectConfigurationProblem extends ConfigurationError {
|
||||
return descriptionString != null ? descriptionString : description.getMessage(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProjectStructureProblemDescription getProblemDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignore(boolean ignored) {
|
||||
super.ignore(ignored);
|
||||
|
||||
+4
@@ -16,6 +16,10 @@ public abstract class ProjectStructureElement {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return getTypeName() + " '" + getPresentableName() + "'";
|
||||
}
|
||||
|
||||
public abstract String getPresentableName();
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-1
@@ -63,7 +63,7 @@ public class ProjectStructureProblemDescription {
|
||||
|
||||
public String getMessage(final boolean includePlace) {
|
||||
if (includePlace && myCanShowPlace) {
|
||||
return myPlace.getContainingElement().getPresentableName() + ": " + StringUtil.decapitalize(myMessage);
|
||||
return myPlace.getContainingElement().getPresentableText() + ": " + StringUtil.decapitalize(myMessage);
|
||||
}
|
||||
return myMessage;
|
||||
}
|
||||
@@ -81,6 +81,7 @@ public class ProjectStructureProblemDescription {
|
||||
return myProblemType.getSeverity();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PlaceInProjectStructure getPlace() {
|
||||
return myPlace;
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class SdkProjectStructureElement extends ProjectStructureElement {
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return "SDK '" + mySdk.getName() + "'";
|
||||
return mySdk.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user