public static void showNow() {
   if (ourInstance == null) {
     IdeFrame frame =
         EP.getExtensions().length == 0 ? new WelcomeFrame() : EP.getExtensions()[0].createFrame();
     if (SystemInfo.isLinux) {
       ApplicationMenu.tryInstall(((JFrame) frame));
     }
     ((JFrame) frame).setVisible(true);
     ourInstance = frame;
   }
 }
  public static void showDialogAndAddLibraryToDependencies(
      final Library library, final Project project, boolean allowEmptySelection) {
    for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
      if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
        return;
      }
    }

    final ModuleStructureConfigurable moduleStructureConfigurable =
        ModuleStructureConfigurable.getInstance(project);
    final List<Module> modules =
        LibraryEditingUtil.getSuitableModules(
            moduleStructureConfigurable, ((LibraryEx) library).getKind(), library);
    if (modules.isEmpty()) return;
    final ChooseModulesDialog dlg =
        new ChooseModulesDialog(
            moduleStructureConfigurable.getProject(),
            modules,
            ProjectBundle.message("choose.modules.dialog.title"),
            ProjectBundle.message("choose.modules.dialog.description", library.getName()));
    if (dlg.showAndGet()) {
      final List<Module> chosenModules = dlg.getChosenElements();
      for (Module module : chosenModules) {
        moduleStructureConfigurable.addLibraryOrderEntry(module, library);
      }
    }
  }
Example #3
0
 @Nullable
 public static MvcFramework getInstanceBySdk(@NotNull Module module) {
   for (final MvcFramework framework : EP_NAME.getExtensions()) {
     if (framework.getSdkRoot(module) != null) {
       return framework;
     }
   }
   return null;
 }
Example #4
0
 @Nullable
 public static MvcFramework findCommonPluginModuleFramework(Module module) {
   for (MvcFramework framework : EP_NAME.getExtensions()) {
     if (framework.isCommonPluginsModule(module)) {
       return framework;
     }
   }
   return null;
 }
 public static void check(
     ProjectStructureElement element, ProjectStructureProblemsHolder problemsHolder) {
   for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
     if (validator.checkElement(element, problemsHolder)) {
       return;
     }
   }
   element.check(problemsHolder);
 }
 public static List<RenamePsiElementProcessor> allForElement(@NotNull PsiElement element) {
   final List<RenamePsiElementProcessor> result = new ArrayList<>();
   for (RenamePsiElementProcessor processor : EP_NAME.getExtensions()) {
     if (processor.canProcessElement(element)) {
       result.add(processor);
     }
   }
   return result;
 }
 public static List<ProjectStructureElementUsage> getUsagesInElement(
     final ProjectStructureElement element) {
   for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
     List<ProjectStructureElementUsage> usages = validator.getUsagesIn(element);
     if (usages != null) {
       return usages;
     }
   }
   return element.getUsagesInElement();
 }
 /**
  * Finds extensions supporting the given <code>schemeClass</code>
  *
  * @param schemeClass The class of the scheme to search extensions for.
  * @return A collection of importers capable of importing schemes of the given class. An empty
  *     collection is returned if there are no matching importers.
  */
 @NotNull
 public static <S extends Scheme> Collection<SchemeImporterEP<S>> getExtensions(
     Class<S> schemeClass) {
   List<SchemeImporterEP<S>> importers = new ArrayList<SchemeImporterEP<S>>();
   for (SchemeImporterEP<?> importerEP : EP_NAME.getExtensions()) {
     if (schemeClass.getName().equals(importerEP.schemeClass)) {
       //noinspection unchecked
       importers.add((SchemeImporterEP<S>) importerEP);
     }
   }
   return importers;
 }
  public static List<MavenImporter> getSuitableImporters(MavenProject p) {
    List<MavenImporter> result = null;
    Set<ModuleType> moduleTypes = null;

    for (MavenImporter importer : EXTENSION_POINT_NAME.getExtensions()) {
      if (importer.isApplicable(p)) {
        if (result == null) {
          result = new ArrayList<MavenImporter>();
          moduleTypes = new THashSet<ModuleType>();
        }

        result.add(importer);
        moduleTypes.add(importer.getModuleType());
      }
    }

    if (result == null) {
      return Collections.emptyList();
    }

    if (moduleTypes.size() <= 1) {
      return result;
    }

    // This code is reached when several importers say that they are applicable but they want to
    // have different module types.
    // Now we select one module type and return only those importers that are ok with it.
    // If possible - return at least one importer that explicitly supports packaging of the given
    // maven project.
    ModuleType moduleType = result.get(0).getModuleType();
    List<String> supportedPackagings = new ArrayList<String>();
    for (MavenImporter importer : result) {
      supportedPackagings.clear();
      importer.getSupportedPackagings(supportedPackagings);
      if (supportedPackagings.contains(p.getPackaging())) {
        moduleType = importer.getModuleType();
        break;
      }
    }

    final ModuleType finalModuleType = moduleType;
    return ContainerUtil.filter(
        result,
        new Condition<MavenImporter>() {
          public boolean value(final MavenImporter importer) {
            return importer.getModuleType() == finalModuleType;
          }
        });
  }
  private static void ensureInit() {
    if (ourClassSpecifiedContributors != null) return;

    MultiMap<String, NonCodeMembersContributor> contributorMap =
        new MultiMap<String, NonCodeMembersContributor>();

    for (final NonCodeMembersContributor contributor : EP_NAME.getExtensions()) {
      contributorMap.putValue(contributor.getParentClassName(), contributor);
    }

    Collection<NonCodeMembersContributor> allTypeContributors = contributorMap.remove(null);
    ourAllTypeContributors =
        allTypeContributors.toArray(new NonCodeMembersContributor[allTypeContributors.size()]);
    ourClassSpecifiedContributors = contributorMap;
  }