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


Java FileChooserDescriptor.putUserData方法代碼示例

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


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

示例1: getHomeChooserDescriptor

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public FileChooserDescriptor getHomeChooserDescriptor() {
  final FileChooserDescriptor baseDescriptor = super.getHomeChooserDescriptor();
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(baseDescriptor) {
    @Override
    public void validateSelectedFiles(VirtualFile[] files) throws Exception {
      if (files.length > 0 && !JrtFileSystem.isSupported()) {
        String path = files[0].getPath();
        if (JrtFileSystem.isModularJdk(path) || JrtFileSystem.isModularJdk(adjustSelectedSdkHome(path))) {
          throw new Exception(LangBundle.message("jrt.not.available.message"));
        }
      }
      baseDescriptor.validateSelectedFiles(files);
    }
  };
  descriptor.putUserData(KEY, Boolean.TRUE);
  return descriptor;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:JavaSdkImpl.java

示例2: actionPerformed

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = e.getProject();
  final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
  final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
  descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);

  FileChooser.chooseFiles(descriptor, project, VfsUtil.getUserHomeDir(), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> files) {
      for (VirtualFile file : files) {
        if (!descriptor.isFileSelectable(file)) {
          String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
          Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
          return;
        }
      }
      doOpenFile(project, files);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:OpenFileAction.java

示例3: actionPerformed

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getProject();
  final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
  final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
  descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);

  chooseFiles(descriptor, project, getUserHomeDir(), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> files) {
      for (VirtualFile file : files) {
        if (!descriptor.isFileSelectable(file)) {
          String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
          Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
          return;
        }
      }
      doOpenFile(project, files);
    }
  });

}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:AndroidOpenFileAction.java

示例4: selectRoots

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
protected List<OrderRoot> selectRoots(@Nullable VirtualFile initialSelection) {
  final String name = getLibraryEditor().getName();
  final FileChooserDescriptor chooserDescriptor = myDescriptor.createAttachFilesChooserDescriptor(name);
  if (myContextModule != null) {
    chooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myContextModule);
  }
  final VirtualFile[] files = FileChooser.chooseFiles(chooserDescriptor, myPanel, myProject, initialSelection);
  if (files.length == 0) return Collections.emptyList();

  return RootDetectionUtil.detectRoots(Arrays.asList(files), myPanel, myProject, myDescriptor);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:LibraryRootsComponent.java

示例5: selectFiles

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public VirtualFile[] selectFiles(final @NotNull JComponent parent, @Nullable VirtualFile initialSelection,
                                 final @Nullable Module contextModule, @NotNull LibraryEditor libraryEditor) {
  final FileChooserDescriptor chooserDescriptor = createChooserDescriptor();
  chooserDescriptor.setTitle(getChooserTitle(libraryEditor.getName()));
  chooserDescriptor.setDescription(getChooserDescription());
  if (contextModule != null) {
    chooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, contextModule);
  }
  return FileChooser.chooseFiles(chooserDescriptor, parent, contextModule != null ? contextModule.getProject() : null, initialSelection);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:ChooserBasedAttachRootButtonDescriptor.java

示例6: AddContentEntryAction

import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
public AddContentEntryAction() {
  super(ProjectBundle.message("module.paths.add.content.action"),
        ProjectBundle.message("module.paths.add.content.action.description"), AllIcons.Modules.AddContentEntry);
  myDescriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
    @Override
    public void validateSelectedFiles(VirtualFile[] files) throws Exception {
      validateContentEntriesCandidates(files);
    }
  };
  myDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, getModule());
  myDescriptor.setTitle(ProjectBundle.message("module.paths.add.content.title"));
  myDescriptor.setDescription(ProjectBundle.message("module.paths.add.content.prompt"));
  myDescriptor.putUserData(FileChooserKeys.DELETE_ACTION_AVAILABLE, false);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:CommonContentEntriesEditor.java


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