當前位置: 首頁>>代碼示例>>Java>>正文


Java FileChooserDescriptor.setRoots方法代碼示例

本文整理匯總了Java中com.intellij.openapi.fileChooser.FileChooserDescriptor.setRoots方法的典型用法代碼示例。如果您正苦於以下問題:Java FileChooserDescriptor.setRoots方法的具體用法?Java FileChooserDescriptor.setRoots怎麽用?Java FileChooserDescriptor.setRoots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.fileChooser.FileChooserDescriptor的用法示例。


在下文中一共展示了FileChooserDescriptor.setRoots方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDirectory

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
public static PsiDirectory createDirectory(Project project, String title, String description) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle(title);
    descriptor.setShowFileSystemRoots(false);
    descriptor.setDescription(description);
    descriptor.setHideIgnored(true);
    descriptor.setRoots(project.getBaseDir());
    descriptor.setForcedToUseIdeaFileChooser(true);
    VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
    if(Objects.isNull(file)){
        Messages.showInfoMessage("Cancel " + title, "Error");
        return null;
    }

    PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(file);
    if(PsiDirectoryFactory.getInstance(project).isPackage(psiDirectory)){
        return psiDirectory;
    }else {
        Messages.showInfoMessage("請選擇正確的 package 路徑。", "Error");
        return createDirectory(project, title, description);
    }
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:23,代碼來源:PsiUtil.java

示例2: createExcludedConfigurable

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
private static ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
  final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
  final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
    public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
      return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
    }
  };

  List<VirtualFile> allContentRoots = new ArrayList<VirtualFile>();
  for (final Module module: ModuleManager.getInstance(project).getModules()) {
    final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots();
    Collections.addAll(allContentRoots, moduleContentRoots);
  }
  descriptor.setRoots(allContentRoots);
  return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:ValidationConfigurable.java

示例3: setupUrlField

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field, @NotNull final Project project) {
  FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    @Override
    public boolean isFileSelectable(VirtualFile file) {
      return HtmlUtil.isHtmlFile(file) || virtualFileToUrl(file, project) != null;
    }
  };
  descriptor.setTitle(XmlBundle.message("javascript.debugger.settings.choose.file.title"));
  descriptor.setDescription(XmlBundle.message("javascript.debugger.settings.choose.file.subtitle"));
  descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());

  field.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
    @NotNull
    @Override
    protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
      if (chosenFile.isDirectory()) {
        return chosenFile.getPath();
      }

      Url url = virtualFileToUrl(chosenFile, project);
      return url == null ? chosenFile.getUrl() : url.toDecodedForm();
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:StartBrowserPanel.java

示例4: createExcludedConfigurable

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
  final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
  final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
    @Override
    public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
      return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
    }
  };
  descriptor.setRoots(ContainerUtil.concat(
    ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {
      @Override
      public List<VirtualFile> fun(final Module module) {
        return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
      }
    })));
  return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:GroovyCompilerConfigurable.java

示例5: actionPerformed

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
  descriptor.setTitle("Exclude from Library");
  descriptor.setDescription("Select directories which should be excluded from the library content. Content of excluded directories won't be processed by IDE.");
  Set<VirtualFile> roots = getNotExcludedRoots();
  descriptor.setRoots(roots.toArray(new VirtualFile[roots.size()]));
  if (roots.size() < 2) {
    descriptor.withTreeRootVisible(true);
  }
  VirtualFile toSelect = null;
  for (Object o : getSelectedElements()) {
    Object itemElement = o instanceof ExcludedRootElement ? ((ExcludedRootElement)o).getParentDescriptor() : o;
    if (itemElement instanceof ItemElement) {
      toSelect = VirtualFileManager.getInstance().findFileByUrl(((ItemElement)itemElement).getUrl());
      break;
    }
  }
  final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myPanel, myProject, toSelect);
  if (files.length > 0) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        for (VirtualFile file : files) {
          getLibraryEditor().addExcludedRoot(file.getUrl());
        }
      }
    });
    myLastChosen = files[0];
    libraryChanged(true);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:33,代碼來源:LibraryRootsComponent.java

示例6: actionPerformed

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
  Module module = myContext.getModule();
  final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();

  if (contentRoots.length == 0) {
    return;
  }
  VirtualFile initialFile = null;
  String path = myTextField.getText().trim();
  if (path.length() == 0) {
    path = myDefaultPath;
  }
  if (path != null) {
    initialFile = LocalFileSystem.getInstance().findFileByPath(path);
  }
  if (initialFile == null) {
    ModuleRootManager manager = ModuleRootManager.getInstance(module);
    VirtualFile[] sourceRoots = manager.getSourceRoots();
    if (sourceRoots.length > 0) {
      initialFile = sourceRoots[0];
    }
    else {
      initialFile = module.getModuleFile();
      if (initialFile == null) {
        String p = AndroidRootUtil.getModuleDirPath(myContext.getModule());
        if (p != null) {
          initialFile = LocalFileSystem.getInstance().findFileByPath(p);
        }
      }
    }
  }
  final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  descriptor.setRoots(contentRoots);
  VirtualFile file = FileChooser.chooseFile(descriptor, myContentPanel, myContext.getProject(), initialFile);
  if (file != null) {
    myTextField.setText(FileUtil.toSystemDependentName(file.getPath()));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:AndroidFacetEditorTab.java

示例7: addFileDependency

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
private void addFileDependency() {
  FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, true, false, false);
  VirtualFile buildFile = myGradleBuildFile.getFile();
  VirtualFile parent = buildFile.getParent();
  descriptor.setRoots(parent);
  VirtualFile virtualFile = FileChooser.chooseFile(descriptor, myProject, null);
  if (virtualFile != null) {
    String path = VfsUtilCore.getRelativePath(virtualFile, parent, '/');
    if (path == null) {
      path = virtualFile.getPath();
    }
    myModel.addItem(new ModuleDependenciesTableItem(new Dependency(Dependency.Scope.COMPILE, Dependency.Type.FILES, path)));
  }
  myModel.fireTableDataChanged();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:ModuleDependenciesPanel.java

示例8: doAdd

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
private void doAdd() {
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true);
  final ModuleRootModel rootModel = myContext.getRootModel();
  descriptor.setRoots(rootModel.getSourceRoots(JavaModuleSourceRootTypes.SOURCES));
  final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myContext.getProject(), null);
  for (VirtualFile file : files) {
    myFilesListModel.addElement(file.getPath());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:AppEngineFacetEditor.java


注:本文中的com.intellij.openapi.fileChooser.FileChooserDescriptor.setRoots方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。