[groovy] clean up GroovyPsiManager
[idea/community.git] / java / idea-ui / src / com / intellij / openapi / roots / ui / configuration / projectRoot / daemon / LibraryProjectStructureElement.java
index 58ca6ccb07f8c97a473370f4623280e9c8726f6c..6fe64af8b310a876acf9739a824ac052a35f4cd3 100644 (file)
@@ -19,19 +19,17 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibraryConfigurab
 import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
 import com.intellij.openapi.ui.NamedConfigurable;
 import com.intellij.openapi.util.ActionCallback;
+import com.intellij.openapi.util.NlsSafe;
 import com.intellij.openapi.util.text.HtmlBuilder;
 import com.intellij.openapi.util.text.HtmlChunk;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.util.PathUtil;
-import com.intellij.xml.util.XmlStringUtil;
+import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 
 public class LibraryProjectStructureElement extends ProjectStructureElement {
   private final Library myLibrary;
@@ -65,7 +63,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
                                   @NotNull OrderRootType type, String rootName, final ProjectStructureProblemType problemType) {
     final List<String> invalidUrls = library.getInvalidRootUrls(type);
     if (!invalidUrls.isEmpty()) {
-      final String description = createInvalidRootsDescription(invalidUrls, rootName, library.getName());
+      final HtmlChunk description = createInvalidRootsDescription(invalidUrls, rootName, library.getName());
       final PlaceInProjectStructure place = createPlace();
       final String message = JavaUiBundle.message("project.roots.error.message.invalid.roots", rootName, invalidUrls.size());
       ProjectStructureProblemDescription.ProblemLevel level = library.getTable().getTableLevel().equals(LibraryTablesRegistrar.PROJECT_LEVEL)
@@ -77,17 +75,22 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
     }
   }
 
-  private static String createInvalidRootsDescription(List<String> invalidClasses, String rootName, String libraryName) {
+  private static HtmlChunk createInvalidRootsDescription(List<String> invalidClasses, String rootName, @NlsSafe String libraryName) {
     HtmlBuilder buffer = new HtmlBuilder();
     final String name = StringUtil.escapeXmlEntities(libraryName);
-    buffer.append("Library ");
-    buffer.appendLink("http://library/"+name, name);
-    buffer.append(" has broken " + rootName + " " + StringUtil.pluralize("path", invalidClasses.size()) + ":");
+    final HtmlChunk.Element link = HtmlChunk.link("http://library/" + name, name);
+    buffer.appendRaw(
+      JavaUiBundle.message("library.project.structure.invalid.roots.description",
+                           link,
+                           rootName,
+                           invalidClasses.size()
+      )
+    );
     for (String url : invalidClasses) {
       buffer.br().nbsp(2);
       buffer.append(PathUtil.toPresentableUrl(url));
     }
-    return buffer.wrapWith("html").toString();
+    return buffer.toFragment();
   }
 
   @NotNull
@@ -137,10 +140,17 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
   @Override
   public ProjectStructureProblemDescription createUnusedElementWarning() {
     final List<ConfigurationErrorQuickFix> fixes = Arrays.asList(new AddLibraryToDependenciesFix(), new RemoveLibraryFix(), new RemoveAllUnusedLibrariesFix());
-    String libraryName = HtmlChunk.link("http://library/" + myLibrary.getName(), myLibrary.getName()).toString();
-    return new ProjectStructureProblemDescription(XmlStringUtil.wrapInHtml("Library " + libraryName + " is not used"), null, createPlace(),
-                                                  ProjectStructureProblemType.unused("unused-library"), ProjectStructureProblemDescription.ProblemLevel.PROJECT,
-                                                  fixes, false);
+    final String name = Objects.toString(myLibrary.getName());
+    final String libraryName = HtmlChunk.link("http://library/" + name, name).toString();
+
+    final String result = JavaUiBundle.message("library.0.is.not.used", libraryName);
+    return new ProjectStructureProblemDescription(result,
+                                                  HtmlChunk.empty(),
+                                                  createPlace(),
+                                                  ProjectStructureProblemType.unused("unused-library"),
+                                                  ProjectStructureProblemDescription.ProblemLevel.PROJECT,
+                                                  fixes,
+                                                  false);
   }
 
   @Override
@@ -149,8 +159,8 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
   }
 
   @Override
-  public String getTypeName() {
-    return "Library";
+  public @Nls(capitalization = Nls.Capitalization.Sentence) String getTypeName() {
+    return JavaUiBundle.message("configurable.library.prefix");
   }
 
   @Override
@@ -164,7 +174,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
     private final List<String> myInvalidUrls;
 
     RemoveInvalidRootsQuickFix(Library library, OrderRootType type, List<String> invalidUrls) {
-      super("Remove invalid " + StringUtil.pluralize("root", invalidUrls.size()));
+      super(JavaUiBundle.message("label.remove.invalid.roots", invalidUrls.size()));
       myLibrary = library;
       myType = type;
       myInvalidUrls = invalidUrls;
@@ -192,7 +202,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
 
   private final class AddLibraryToDependenciesFix extends ConfigurationErrorQuickFix {
     private AddLibraryToDependenciesFix() {
-      super("Add to Dependencies...");
+      super(JavaUiBundle.message("label.add.to.dependencies"));
     }
 
     @Override
@@ -203,7 +213,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
 
   private final class RemoveLibraryFix extends ConfigurationErrorQuickFix {
     private RemoveLibraryFix() {
-      super("Remove Library");
+      super(JavaUiBundle.message("label.remove.library"));
     }
 
     @Override
@@ -214,7 +224,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
 
   private final class RemoveAllUnusedLibrariesFix extends ConfigurationErrorQuickFix {
     private RemoveAllUnusedLibrariesFix() {
-      super("Remove All Unused Libraries");
+      super(JavaUiBundle.message("label.remove.all.unused.libraries"));
     }
 
     @Override