Java Code Examples for com.intellij.openapi.project.ProjectBundle#message()

The following examples show how to use com.intellij.openapi.project.ProjectBundle#message() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryClasspathTableItem.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public String getTooltipText() {
  final Library library = myEntry.getLibrary();
  if (library == null) return null;

  final String name = library.getName();
  if (name != null) {
    final List<String> invalidUrls = ((LibraryEx)library).getInvalidRootUrls(BinariesOrderRootType.getInstance());
    if (!invalidUrls.isEmpty()) {
      return ProjectBundle.message("project.roots.tooltip.library.has.broken.paths", name, invalidUrls.size());
    }
  }

  final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
  if (descriptions.isEmpty()) return null;

  return XmlStringUtil.wrapInHtml(StringUtil.join(descriptions, "<br>"));
}
 
Example 2
Source File: ScopeChooserConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void checkApply(Set<MyNode> rootNodes, String prefix, String title) throws ConfigurationException {
  super.checkApply(rootNodes, prefix, title);
  final Set<String> predefinedScopes = new HashSet<String>();
  for (CustomScopesProvider scopesProvider : myProject.getExtensions(CustomScopesProvider.CUSTOM_SCOPES_PROVIDER)) {
    for (NamedScope namedScope : scopesProvider.getCustomScopes()) {
      predefinedScopes.add(namedScope.getName());
    }
  }
  for (MyNode rootNode : rootNodes) {
    for (int i = 0; i < rootNode.getChildCount(); i++) {
      final MyNode node = (MyNode)rootNode.getChildAt(i);
      final NamedConfigurable scopeConfigurable = node.getConfigurable();
      final String name = scopeConfigurable.getDisplayName();
      if (predefinedScopes.contains(name)) {
        selectNodeInTree(node);
        throw new ConfigurationException("Scope name equals to predefined one", ProjectBundle.message("rename.scope.title"));
      }
    }
  }
}
 
Example 3
Source File: ModuleLibraryOrderEntryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public String getPresentableName() {
  final String name = myLibrary.getName();
  if (name != null) {
    return name;
  }
  else {
    if (myLibrary instanceof LibraryEx && ((LibraryEx)myLibrary).isDisposed()) {
      return "<unknown>";
    }

    final String[] urls = myLibrary.getUrls(BinariesOrderRootType.getInstance());
    if (urls.length > 0) {
      String url = urls[0];
      return PathUtil.toPresentableUrl(url);
    }
    else {
      return ProjectBundle.message("library.empty.library.item");
    }
  }
}
 
Example 4
Source File: GeneralProjectSettingsElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void check(ProjectStructureProblemsHolder problemsHolder) {
  final Graph<Chunk<ModuleRootModel>> graph = ModuleCompilerUtil.toChunkGraph(myContext.getModulesConfigurator().createGraphGenerator());
  final Collection<Chunk<ModuleRootModel>> chunks = graph.getNodes();
  List<String> cycles = new ArrayList<String>();
  for (Chunk<ModuleRootModel> chunk : chunks) {
    final Set<ModuleRootModel> modules = chunk.getNodes();
    List<String> names = new ArrayList<String>();
    for (ModuleRootModel model : modules) {
      names.add(model.getModule().getName());
    }
    if (modules.size() > 1) {
      cycles.add(StringUtil.join(names, ", "));
    }
  }
  if (!cycles.isEmpty()) {
    final Project project = myContext.getProject();
    final PlaceInProjectStructureBase place = new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createModulesPlace(), this);
    final String message;
    final String description;
    if (cycles.size() > 1) {
      message = "Circular dependencies";
      @NonNls final String br = "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
      StringBuilder cyclesString = new StringBuilder();
      for (int i = 0; i < cycles.size(); i++) {
        cyclesString.append(br).append(i + 1).append(". ").append(cycles.get(i));
      }
      description = ProjectBundle.message("module.circular.dependency.warning.description", cyclesString);
    }
    else {
      message = ProjectBundle.message("module.circular.dependency.warning.short", cycles.get(0));
      description = null;
    }
    problemsHolder.registerProblem(new ProjectStructureProblemDescription(message, description, place,
                                                                          ProjectStructureProblemType.warning("module-circular-dependency"),
                                                                          Collections.<ConfigurationErrorQuickFix>emptyList()));
  }
}
 
Example 5
Source File: ProjectLoadingErrorsNotifierImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void fireNotifications() {
  final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<ConfigurationErrorType, ConfigurationErrorDescription>();
  synchronized (myLock) {
    if (myErrors.isEmpty()) return;
    descriptionsMap.putAllValues(myErrors);
    myErrors.clear();
  }

  for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
    final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
    if (descriptions.isEmpty()) continue;

    final String invalidElements = getInvalidElementsString(type, descriptions);
    final String errorText = ProjectBundle.message("error.message.configuration.cannot.load") + " " + invalidElements + " <a href=\"\">Details...</a>";

    Notifications.Bus.notify(new Notification("Project Loading Error", "Error Loading Project", errorText, NotificationType.ERROR, new NotificationListener() {
      @Override
      public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
        final List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, new Condition<ConfigurationErrorDescription>() {
          @Override
          public boolean value(ConfigurationErrorDescription errorDescription) {
            return errorDescription.isValid();
          }
        });
        RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions);

        notification.expire();
      }
    }), myProject);
  }

}
 
Example 6
Source File: StorageUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static VirtualFile getOrCreateVirtualFile(@Nullable Object requestor, @Nonnull File ioFile) throws IOException {
  VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
  if (virtualFile == null) {
    File parentFile = ioFile.getParentFile();
    // need refresh if the directory has just been created
    VirtualFile parentVirtualFile = parentFile == null ? null : LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentFile);
    if (parentVirtualFile == null) {
      throw new IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile == null ? ioFile.getPath() : parentFile.getPath()));
    }
    virtualFile = parentVirtualFile.createChildData(requestor, ioFile.getName());
  }
  return virtualFile;
}
 
Example 7
Source File: ProjectMacrosUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean showMacrosConfigurationDialog(Project project, final Collection<String> undefinedMacros) {
  final String text = ProjectBundle.message("project.load.undefined.path.variables.message");
  final Application application = ApplicationManager.getApplication();
  if (application.isHeadlessEnvironment() || application.isUnitTestMode()) {
    throw new RuntimeException(text + ": " + StringUtil.join(undefinedMacros, ", "));
  }
  final UndefinedMacrosConfigurable configurable =
    new UndefinedMacrosConfigurable(text, undefinedMacros);
  final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
  editor.show();
  return editor.isOK();
}
 
Example 8
Source File: TestResourceContentFolderTypeProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getName() {
  return ProjectBundle.message("module.toggle.test.resources.action");
}
 
Example 9
Source File: ProductionResourceContentFolderTypeProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getName() {
  return ProjectBundle.message("module.toggle.resources.action");
}
 
Example 10
Source File: BuildElementsEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getDisplayName() {
  return ProjectBundle.message("output.tab.title");
}
 
Example 11
Source File: ModuleDeleteProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String getConfirmationText(Module[] modules, String names) {
  return ProjectBundle.message("module.remove.confirmation.prompt", names, modules.length);
}
 
Example 12
Source File: ProjectLibrariesConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String getAddText() {
  return ProjectBundle.message("add.new.project.library.text");
}
 
Example 13
Source File: RenamePackagingElementAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RenamePackagingElementAction(ArtifactEditorEx artifactEditor) {
  super(ProjectBundle.message("action.name.rename.packaging.element"));
  registerCustomShortcutSet(CommonShortcuts.getRename(), artifactEditor.getLayoutTreeComponent().getTreePanel());
  myArtifactEditor = artifactEditor;
}
 
Example 14
Source File: BaseSdkEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
private String getHomeFieldLabelValue() {
  return ProjectBundle.message("sdk.configure.type.home.path", ((SdkType)mySdk.getSdkType()).getPresentableName());
}
 
Example 15
Source File: ContentEntriesEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void validateContentEntriesCandidates(VirtualFile[] files) throws Exception {
  for (final VirtualFile file : files) {
    // check for collisions with already existing entries
    for (final ContentEntry contentEntry : myEntryToEditorMap.keySet()) {
      final VirtualFile contentEntryFile = contentEntry.getFile();
      if (contentEntryFile == null) {
        continue;  // skip invalid entry
      }
      if (contentEntryFile.equals(file)) {
        throw new Exception(ProjectBundle.message("module.paths.add.content.already.exists.error", file.getPresentableUrl()));
      }
      if (VfsUtilCore.isAncestor(contentEntryFile, file, true)) {
        // intersection not allowed
        throw new Exception(
          ProjectBundle.message("module.paths.add.content.intersect.error", file.getPresentableUrl(),
                                contentEntryFile.getPresentableUrl()));
      }
      if (VfsUtilCore.isAncestor(file, contentEntryFile, true)) {
        // intersection not allowed
        throw new Exception(
          ProjectBundle.message("module.paths.add.content.dominate.error", file.getPresentableUrl(),
                                contentEntryFile.getPresentableUrl()));
      }
    }
    // check if the same root is configured for another module
    final Module[] modules = myModulesProvider.getModules();
    for (final Module module : modules) {
      if (myModuleName.equals(module.getName())) {
        continue;
      }
      ModuleRootModel rootModel = myModulesProvider.getRootModel(module);
      LOG.assertTrue(rootModel != null);
      final VirtualFile[] moduleContentRoots = rootModel.getContentRoots();
      for (VirtualFile moduleContentRoot : moduleContentRoots) {
        if (file.equals(moduleContentRoot)) {
          throw new Exception(
            ProjectBundle.message("module.paths.add.content.duplicate.error", file.getPresentableUrl(), module.getName()));
        }
      }
    }
  }
}
 
Example 16
Source File: ModuleLibraryTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getDescription() {
  return ProjectBundle.message("libraries.node.text.module");
}
 
Example 17
Source File: ArtifactsStructureConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nls
public String getDisplayName() {
  return ProjectBundle.message("display.name.artifacts");
}
 
Example 18
Source File: DocumentationOrderRootTypeUIFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public DocumentationPathsEditor(Sdk sdk) {
  super(ProjectBundle.message("library.javadocs.node"), DocumentationOrderRootType.getInstance(), FileChooserDescriptorFactory.createMultipleJavaPathDescriptor(), sdk);
  mySdk = sdk;
}
 
Example 19
Source File: ProjectLibraryTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getLibraryTableEditorTitle() {
  return ProjectBundle.message("library.configure.project.title");
}
 
Example 20
Source File: ExtractArtifactAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ExtractArtifactAction(ArtifactEditorEx editor) {
  super(ProjectBundle.message("action.name.extract.artifact"), editor);
}