Example #1
1
 public static String getFileChooserDescription(final Project project) {
   ProjectImportProvider[] providers =
       ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions();
   List<ProjectImportProvider> list =
       ContainerUtil.filter(
           providers,
           new Condition<ProjectImportProvider>() {
             @Override
             public boolean value(ProjectImportProvider provider) {
               return project != null || provider.canCreateNewProject();
             }
           });
   StringBuilder builder = new StringBuilder("<html>Select ");
   boolean first = true;
   if (list.size() > 1) {
     for (ProjectImportProvider provider : list) {
       String sample = provider.getFileSample();
       if (sample != null) {
         if (!first) {
           builder.append(", <br>");
         } else {
           first = false;
         }
         builder.append(sample);
       }
     }
   }
   builder.append(".</html>");
   return builder.toString();
 }
Example #2
0
  @Nullable
  public static AddModuleWizard selectFileAndCreateWizard(
      final Project project, Component dialogParent) {
    FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    descriptor.setHideIgnored(false);
    descriptor.setTitle("Select File or Directory to Import");
    ProjectImportProvider[] providers =
        ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions();
    String description = getFileChooserDescription(project);
    descriptor.setDescription(description);

    return selectFileAndCreateWizard(project, dialogParent, descriptor, providers);
  }